Hello everyone,
There seems to be a bug on the diagnosis listing. After deleting a Diagnosis, it will remain visible on the frontend as if nothing has changed. It is correctly marked as voided in the database though.
e.g. In the screenshot below, Epilepsy is shown, even though it has been removed:
It seems that, when converting the core diagnosis model object list to the emrapi model, the void information is not considered and the all the diagnosis are converted regardless whether voided or not.
I’ve slightly modified an existing test, by adding a void diagnosis, to illustrate the issue:
@Test
public void testGetExistingDiagnoses() {
// Setup
Diagnosis asthmaDiagnosis = new Diagnosis(existingEncounter, new CodedOrFreeText(null, null, "Asthma"), null, null, null);
Diagnosis malariaDiagnosis = new Diagnosis(existingEncounter, new CodedOrFreeText(null, null, "Malaria"), null, null, null);
Diagnosis voidedEpilepsyDiagnosis = new Diagnosis(existingEncounter, new CodedOrFreeText(null, null, "Epilepsy"), null, null, null);
voidedEpilepsyDiagnosis.setVoided(true);
when(context.getMode()).thenReturn(Mode.EDIT);
when(existingEncounter.getDiagnoses()).thenReturn(
new LinkedHashSet<Diagnosis>(Arrays.asList(asthmaDiagnosis, malariaDiagnosis, voidedEpilepsyDiagnosis)));
// Replay
EncounterDiagnosesElement element = new EncounterDiagnosesElement();
List<Diagnosis> existingDiagnoses = element.getExistingDiagnoses(context);
// Verify
Assert.assertEquals(2, existingDiagnoses.size());
Assert.assertEquals("Asthma", ((Diagnosis) existingDiagnoses.toArray()[0]).getDiagnosis().getNonCoded());
Assert.assertEquals("Malaria", ((Diagnosis) existingDiagnoses.toArray()[1]).getDiagnosis().getNonCoded());
}
Assert.assertEquals(2, existingDiagnoses.size()); Will fail because the voided diagnoses will be also contained within the list.
Not sure if this is a bug or if I’m missing something.
Any feedback will be appreciated. Thanks!
cc @mksd