From a8029c5e1fd40af5061105fad9dfff3d7c46f2ec Mon Sep 17 00:00:00 2001 From: annooritdept <84702832+annooritdept@users.noreply.github.com> Date: Wed, 20 Jul 2022 09:52:59 +0300 Subject: [PATCH 1/2] fix bug getAll missing observations The shortcut on lines 67-69 cause an unexcpected result where, when getAll has numberOfAccessions set, observations for orders will only be attached to orders if their encounter is dated after the last encounter reached by this loop. The solution seems to be to just remove the shortcut. --- .../laborder/service/LabOrderResultsServiceImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java index 6017956bb3..f2c2baa61e 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java @@ -64,9 +64,6 @@ public LabOrderResults getAll(Patient patient, List visits, int numberOfA int currentAccession = 0; for (int count = totalEncounters - 1; count >= 0; count--) { Encounter encounter = encounters.get(count); - if (currentAccession >= numberOfAccessions) { - break; - } EncounterTransaction encounterTransaction = encounterTransactionMapper.map(encounter, false); List existingTestOrders = filterTestOrders(encounterTransaction, encounter, encounterTestOrderUuidMap, null, null, null); From 5b9c47ed71de5b0ad0e32d114e21b54b117d7adc Mon Sep 17 00:00:00 2001 From: annooritdept <84702832+annooritdept@users.noreply.github.com> Date: Wed, 20 Jul 2022 10:05:13 +0300 Subject: [PATCH 2/2] Update LabOrderResultsServiceImpl.java Previous bugfix was wrong, would have ignored numberOfAccessions altogether. This is possibly better. I apologize, I don't have a development system set up to test this. --- .../service/LabOrderResultsServiceImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java index f2c2baa61e..af1545a2bf 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/laborder/service/LabOrderResultsServiceImpl.java @@ -64,17 +64,18 @@ public LabOrderResults getAll(Patient patient, List visits, int numberOfA int currentAccession = 0; for (int count = totalEncounters - 1; count >= 0; count--) { Encounter encounter = encounters.get(count); - EncounterTransaction encounterTransaction = encounterTransactionMapper.map(encounter, false); - List existingTestOrders = filterTestOrders(encounterTransaction, encounter, encounterTestOrderUuidMap, null, null, null); - testOrders.addAll(existingTestOrders); + if (currentAccession < numberOfAccessions) { + List existingTestOrders = filterTestOrders(encounterTransaction, encounter, encounterTestOrderUuidMap, null, null, null); + testOrders.addAll(existingTestOrders); + if (existingTestOrders.size() > 0) { + currentAccession++; + } + } List nonVoidedObservations = filterObservations(encounterTransaction.getObservations(), null, null); observations.addAll(nonVoidedObservations); createAccessionNotesByEncounter(encounterToAccessionNotesMap, encounters, encounter); - mapObservationsWithEncounter(nonVoidedObservations, encounter, encounterObservationMap); - if (existingTestOrders.size() > 0) { - currentAccession++; - } + mapObservationsWithEncounter(nonVoidedObservations, encounter, encounterObservationMap); } List labOrderResults = mapOrdersWithObs(testOrders, observations, encounterTestOrderUuidMap, encounterObservationMap, encounterToAccessionNotesMap);