From 8ae8fadcfaa792dced8eefefeade0b101e83b4e5 Mon Sep 17 00:00:00 2001 From: himeshr Date: Fri, 9 Feb 2024 18:03:22 +0530 Subject: [PATCH] #1291 | During entity service updateObservations, use whole object to ensure all modifications are saved including profile-pic which is outside observations, but with Realm.UpdateMode.Modified flag, to only effect delta change on the realmDB --- packages/openchs-android/src/service/EncounterService.js | 2 +- packages/openchs-android/src/service/IndividualService.js | 5 +---- .../openchs-android/src/service/ProgramEnrolmentService.js | 5 +---- .../src/service/program/ProgramEncounterService.js | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/openchs-android/src/service/EncounterService.js b/packages/openchs-android/src/service/EncounterService.js index 1478dae0e..e9e5f4e43 100644 --- a/packages/openchs-android/src/service/EncounterService.js +++ b/packages/openchs-android/src/service/EncounterService.js @@ -103,7 +103,7 @@ class EncounterService extends BaseService { ObservationsHolder.convertObsForSave(encounter.cancelObservations); const db = this.db; this.db.write(() => { - db.create(Encounter.schema.name, encounter, true); + db.create(Encounter.schema.name, encounter, Realm.UpdateMode.Modified); db.create(EntityQueue.schema.name, EntityQueue.create(encounter, Encounter.schema.name)); }); } diff --git a/packages/openchs-android/src/service/IndividualService.js b/packages/openchs-android/src/service/IndividualService.js index 9407cf329..076164243 100644 --- a/packages/openchs-android/src/service/IndividualService.js +++ b/packages/openchs-android/src/service/IndividualService.js @@ -109,10 +109,7 @@ class IndividualService extends BaseService { const db = this.db; this.db.write(() => { ObservationsHolder.convertObsForSave(individual.observations); - db.create(Individual.schema.name, { - uuid: individual.uuid, - observations: individual.observations - }, Realm.UpdateMode.Modified); + db.create(Individual.schema.name, individual, Realm.UpdateMode.Modified); db.create(EntityQueue.schema.name, EntityQueue.create(individual, Individual.schema.name)); }); } diff --git a/packages/openchs-android/src/service/ProgramEnrolmentService.js b/packages/openchs-android/src/service/ProgramEnrolmentService.js index a9af59c26..70979af4c 100644 --- a/packages/openchs-android/src/service/ProgramEnrolmentService.js +++ b/packages/openchs-android/src/service/ProgramEnrolmentService.js @@ -64,10 +64,7 @@ class ProgramEnrolmentService extends BaseService { const db = this.db; this.db.write(() => { ProgramEnrolmentService.convertObsForSave(programEnrolment); - db.create(ProgramEnrolment.schema.name, { - uuid: programEnrolment.uuid, - observations: programEnrolment.observations - }, Realm.UpdateMode.Modified); + db.create(ProgramEnrolment.schema.name, programEnrolment, Realm.UpdateMode.Modified); db.create(EntityQueue.schema.name, EntityQueue.create(programEnrolment, ProgramEnrolment.schema.name)); }); } diff --git a/packages/openchs-android/src/service/program/ProgramEncounterService.js b/packages/openchs-android/src/service/program/ProgramEncounterService.js index d93459ea9..629c3ad89 100644 --- a/packages/openchs-android/src/service/program/ProgramEncounterService.js +++ b/packages/openchs-android/src/service/program/ProgramEncounterService.js @@ -107,7 +107,7 @@ class ProgramEncounterService extends BaseService { ObservationsHolder.convertObsForSave(programEncounter.cancelObservations); const db = this.db; this.db.write(() => { - db.create(ProgramEncounter.schema.name, programEncounter, true); + db.create(ProgramEncounter.schema.name, programEncounter, Realm.UpdateMode.Modified); db.create(EntityQueue.schema.name, EntityQueue.create(programEncounter, ProgramEncounter.schema.name)); }); }