|
@@ -54,9 +54,11 @@ class DiagnosisManager implements IDiagnosisManager {
|
|
|
List<DiagnosisAggregationRecordModel> records =
|
|
|
<DiagnosisAggregationRecordModel>[];
|
|
|
List<DiagnosisEntity> localRecords = [];
|
|
|
- localRecords = await db.repositories.diagnosis
|
|
|
- .getNotUploadedListByPatientCode(patientCode, Store.user.userCode!);
|
|
|
- if (!kIsOnline) {
|
|
|
+
|
|
|
+ if (kIsOnline) {
|
|
|
+ localRecords = await db.repositories.diagnosis
|
|
|
+ .getNotUploadedListByPatientCode(patientCode, Store.user.userCode!);
|
|
|
+ } else {
|
|
|
localRecords = await db.repositories.diagnosis
|
|
|
.getListByPatientCode(patientCode, userCode: Store.user.userCode!);
|
|
|
}
|
|
@@ -69,6 +71,7 @@ class DiagnosisManager implements IDiagnosisManager {
|
|
|
key: key, diagnosisData: jsonEncode(data[key])));
|
|
|
}
|
|
|
records.add(DiagnosisAggregationRecordModel(
|
|
|
+ appDataId: element.code,
|
|
|
patientCode: element.patientCode,
|
|
|
patientName: currentPatient.patientName,
|
|
|
doctorName: Store.user.displayName,
|
|
@@ -217,12 +220,20 @@ class DiagnosisManager implements IDiagnosisManager {
|
|
|
@override
|
|
|
Future<bool> removeDiagnosis(String appDataId) async {
|
|
|
try {
|
|
|
- final result = await rpc.vitalDiagnosis.removeDiagnosisByAppDataIdAsync(
|
|
|
- RemoveDiagnosisByAppDataIdRequest(
|
|
|
- token: Store.user.token,
|
|
|
- appDataId: appDataId,
|
|
|
- ),
|
|
|
- );
|
|
|
+ bool result = false;
|
|
|
+ final entity = await db.repositories.diagnosis.singleByCode(appDataId);
|
|
|
+ if (entity != null) {
|
|
|
+ result = await db.repositories.diagnosis.delete(entity.id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (result && kIsOnline) {
|
|
|
+ result = await rpc.vitalDiagnosis.removeDiagnosisByAppDataIdAsync(
|
|
|
+ RemoveDiagnosisByAppDataIdRequest(
|
|
|
+ token: Store.user.token,
|
|
|
+ appDataId: appDataId,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
return result;
|
|
|
} catch (e) {
|
|
|
logger.e("DiagnosisManager remove diagnosis-$appDataId error.", e);
|