Add pricing entry flow and platform admin foundations
This commit is contained in:
@@ -35,17 +35,18 @@ class ClinicJobsRepository {
|
||||
}
|
||||
|
||||
final result = await _pb.collection('jobs').getList(
|
||||
page: page,
|
||||
perPage: limit,
|
||||
filter: filterParts.join(' && '),
|
||||
expand: _listExpand,
|
||||
);
|
||||
page: page,
|
||||
perPage: limit,
|
||||
filter: filterParts.join(' && '),
|
||||
expand: _listExpand,
|
||||
);
|
||||
return (result.items.map((r) => Job.fromJson(r.toJson())).toList()
|
||||
..sort((a, b) => b.dateCreated.compareTo(a.dateCreated)));
|
||||
}
|
||||
|
||||
Future<Job> getJob(String jobId) async {
|
||||
final record = await _pb.collection('jobs').getOne(jobId, expand: _detailExpand);
|
||||
final record =
|
||||
await _pb.collection('jobs').getOne(jobId, expand: _detailExpand);
|
||||
return Job.fromJson(record.toJson());
|
||||
}
|
||||
|
||||
@@ -66,13 +67,15 @@ class ClinicJobsRepository {
|
||||
String? currency,
|
||||
JobWorkflowType? workflowType,
|
||||
bool provaRequired = true,
|
||||
List<String> workflowSteps = const [],
|
||||
}) async {
|
||||
final record = await _pb.collection('jobs').create(body: {
|
||||
'clinic_tenant_id': clinicTenantId,
|
||||
'lab_tenant_id': labTenantId,
|
||||
'patient_code': patientCode,
|
||||
if (patientId != null) 'patient_id': patientId,
|
||||
if (prostheticId != null && prostheticId.isNotEmpty) 'prosthetic_id': prostheticId,
|
||||
if (prostheticId != null && prostheticId.isNotEmpty)
|
||||
'prosthetic_id': prostheticId,
|
||||
'prosthetic_type': prostheticType.value,
|
||||
'member_count': teeth.length,
|
||||
'teeth': teeth,
|
||||
@@ -82,6 +85,7 @@ class ClinicJobsRepository {
|
||||
if (price != null) 'price': price,
|
||||
if (currency != null && currency.isNotEmpty) 'currency': currency,
|
||||
if (workflowType != null) 'workflow_type': workflowType.value,
|
||||
if (workflowSteps.isNotEmpty) 'workflow_steps': workflowSteps,
|
||||
'status': 'pending',
|
||||
'location': 'at_clinic',
|
||||
'prova_required': provaRequired,
|
||||
@@ -126,7 +130,8 @@ class ClinicJobsRepository {
|
||||
return updated;
|
||||
}
|
||||
|
||||
Future<Job> requestRevision(String jobId, Job job, {required String note}) async {
|
||||
Future<Job> requestRevision(String jobId, Job job,
|
||||
{required String note}) async {
|
||||
final record = await _pb.collection('jobs').update(jobId, body: {
|
||||
'location': 'at_lab',
|
||||
});
|
||||
@@ -170,33 +175,42 @@ class ClinicJobsRepository {
|
||||
return Job.fromJson(record.toJson());
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> listApprovedLabs(String clinicTenantId) async {
|
||||
Future<List<Map<String, dynamic>>> listApprovedLabs(
|
||||
String clinicTenantId) async {
|
||||
final result = await _pb.collection('connections').getList(
|
||||
filter: 'clinic_tenant_id = "$clinicTenantId" && status = "approved"',
|
||||
expand: 'lab_tenant_id',
|
||||
perPage: 100,
|
||||
);
|
||||
filter: 'clinic_tenant_id = "$clinicTenantId" && status = "approved"',
|
||||
expand: 'lab_tenant_id',
|
||||
perPage: 100,
|
||||
);
|
||||
return result.items.map((r) {
|
||||
final expand = r.toJson()['expand'] as Map<String, dynamic>?;
|
||||
return expand?['lab_tenant_id'] as Map<String, dynamic>? ?? {'id': r.data['lab_tenant_id']};
|
||||
return expand?['lab_tenant_id'] as Map<String, dynamic>? ??
|
||||
{'id': r.data['lab_tenant_id']};
|
||||
}).toList();
|
||||
}
|
||||
|
||||
Future<List<Job>> listJobsByPatient(String patientId, {int limit = 50}) async {
|
||||
Future<List<Job>> listJobsByPatient(String patientId,
|
||||
{int limit = 50}) async {
|
||||
final result = await _pb.collection('jobs').getList(
|
||||
filter: 'patient_id = "$patientId"',
|
||||
perPage: limit,
|
||||
expand: _listExpand,
|
||||
);
|
||||
filter: 'patient_id = "$patientId"',
|
||||
perPage: limit,
|
||||
expand: _listExpand,
|
||||
);
|
||||
return (result.items.map((r) => Job.fromJson(r.toJson())).toList()
|
||||
..sort((a, b) => b.dateCreated.compareTo(a.dateCreated)));
|
||||
}
|
||||
|
||||
Future<int> countDelivered(String clinicTenantId, {DateTime? from, DateTime? to}) async {
|
||||
final parts = ['clinic_tenant_id = "$clinicTenantId"', 'status = "delivered"'];
|
||||
Future<int> countDelivered(String clinicTenantId,
|
||||
{DateTime? from, DateTime? to}) async {
|
||||
final parts = [
|
||||
'clinic_tenant_id = "$clinicTenantId"',
|
||||
'status = "delivered"'
|
||||
];
|
||||
if (from != null) parts.add('updated >= "${_date(from)}"');
|
||||
if (to != null) parts.add('updated < "${_date(to)}"');
|
||||
final r = await _pb.collection('jobs').getList(perPage: 1, filter: parts.join(' && '));
|
||||
final r = await _pb
|
||||
.collection('jobs')
|
||||
.getList(perPage: 1, filter: parts.join(' && '));
|
||||
return r.totalItems;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user