Diagnosis is shown on search component even thought it has been previously deleted

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:

Screenshot-20200722095347-467x302

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

1 Like

Thanks @icrc.psousa.

I tested it on QA Ref App with the default Visit Note, and indeed voided diagnoses seem to linger.

@icrc.psousa I think you had already identified the fix, that consists in filtering out voided encounter diagnoses right? I suggest that we open a RA ticket.