Kaynağa Gözat

replace patient.singleByCode 2 singleByCodeWithUserCode

Melon 1 yıl önce
ebeveyn
işleme
29fef8b3ee

+ 3 - 2
lib/managers/data_sync.dart

@@ -125,10 +125,11 @@ class DataSyncManager implements IDataSyncManager {
   Future<bool> syncPatientAllData(String patientCode) async {
     PatientEntity? patientEntity;
     try {
-      patientEntity = await db.repositories.patient.singleByCode(patientCode);
+      patientEntity = await db.repositories.patient
+          .singleByCodeWithUserCode(patientCode, Store.user.userCode!);
     } catch (e) {
       logger.e(
-          "DataSyncManager.syncPatientAllData db.singleByCode-$patientCode error.",
+          "DataSyncManager.syncPatientAllData db.singleByCodeWithUserCode-$patientCode error.",
           e);
     }
     if (patientEntity == null) {

+ 8 - 5
lib/managers/patient.dart

@@ -69,7 +69,8 @@ class PatientManager implements IPatientManager {
     try {
       if (kIsOnline && !kIsWeb) {
         //在线状态,先查询是否存在本地未提交数据
-        final entity = await db.repositories.patient.singleByCode(code);
+        final entity = await db.repositories.patient
+            .singleByCodeWithUserCode(code, Store.user.userCode!);
         if (entity != null &&
             entity.dataJson.isNotEmpty &&
             entity.syncState != OfflineDataSyncState.success) {
@@ -172,7 +173,8 @@ class PatientManager implements IPatientManager {
 
   Future<PatientEntity?> _checkPatientExist(String code) async {
     try {
-      final entity = await db.repositories.patient.singleByCode(code);
+      final entity = await db.repositories.patient
+          .singleByCodeWithUserCode(code, Store.user.userCode!);
       return entity;
     } catch (e) {
       logger.e(
@@ -359,7 +361,8 @@ class PatientManager implements IPatientManager {
   Future<bool> removePatient(String code) async {
     bool result = false;
     try {
-      final entity = await db.repositories.patient.singleByCode(code);
+      final entity = await db.repositories.patient
+          .singleByCodeWithUserCode(code, Store.user.userCode!);
       if (entity != null) {
         result = await db.repositories.patient.delete(entity.id);
         if (!result) {
@@ -409,8 +412,8 @@ class PatientManager implements IPatientManager {
   }
 
   Future<void> _syncCloud2Offline(PatientDTO dto) async {
-    PatientEntity? entity =
-        await db.repositories.patient.singleByCode(dto.code!);
+    PatientEntity? entity = await db.repositories.patient
+        .singleByCodeWithUserCode(dto.code!, Store.user.userCode!);
     if (entity == null) {
       entity = PatientEntity();
       entity.isValid = true;

+ 4 - 2
lib/mock/services/patient.dart

@@ -95,7 +95,8 @@ class PatientServiceMock extends VitalPatientService {
   @override
   Future<PatientDTO> getPatientDetailAsync(GetPatientRequest request) async {
     final code = request.code!;
-    final entity = await db.repositories.patient.singleByCode(code);
+    final entity = await db.repositories.patient
+        .singleByCodeWithUserCode(code, Store.user.userCode!);
     if (entity == null || entity.dataJson.isEmpty) {
       throw JsonRpcException(code: -1, message: "Offline patient not found");
     }
@@ -154,7 +155,8 @@ class PatientServiceMock extends VitalPatientService {
 
   Future<PatientEntity?> _checkPatientExist(String code) async {
     try {
-      final entity = await db.repositories.patient.singleByCode(code);
+      final entity = await db.repositories.patient
+          .singleByCodeWithUserCode(code, Store.user.userCode!);
       return entity;
     } catch (e) {
       logger.e(