Skip to content

Commit

Permalink
Add "realistic" test and fix handling of string-coded systemless results
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Dec 17, 2024
1 parent d5bf7b9 commit b996fed
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Message processMessage(Message message) throws ApplicationException, HL7E
return response;
}
catch (ClassCastException ex) {
LOGGER.warn("Error casting " + message.getClass().getName() + " to ORU_R01", ex);
LOGGER.warn("Error casting {} to ORU_R01", message.getClass().getName(), ex);
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.invalidMessageType ",
new Object[] { message.getClass().getName() }, null), ex);
}
Expand All @@ -104,7 +104,7 @@ public Message processMessage(Message message) throws ApplicationException, HL7E
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.WhileProcessing"), ex);
}
catch (Exception e) {
LOGGER.error("Could not process message!\n" + e.getMessage());
LOGGER.error("Could not process message! {}", e.getMessage(), e);
}

return null;
Expand Down Expand Up @@ -137,7 +137,7 @@ private Message processOruR01(ORU_R01 message) throws HL7Exception, ApplicationE

ORU_R01_PATIENT_RESULT patientResult = message.getPATIENT_RESULT();
int numObr = patientResult.getORDER_OBSERVATIONReps();
LOGGER.debug("Patient result {}", patientResult.toString());
LOGGER.debug("Patient result {}", patientResult);
LOGGER.debug("# Observation results returned {}", numObr);
PV1 pv1 = patientResult.getPATIENT().getVISIT().getPV1();
LOGGER.debug("PV1 Time {}", pv1.getAdmitDateTime().getTime());
Expand All @@ -149,10 +149,8 @@ private Message processOruR01(ORU_R01 message) throws HL7Exception, ApplicationE
LOGGER.debug("Alternate Visit Id - Identifier type code {}", pv1.getAlternateVisitID()
.getCx5_IdentifierTypeCode().getValue());
for (int i = 0; i < numObr; i++) {

LOGGER.debug("Processing OBR {}", i);
LOGGER.debug(" of {}", numObr);

LOGGER.debug("Processing OBR {} of {}", i + 1, numObr);

ORU_R01_ORDER_OBSERVATION orderObs = patientResult.getORDER_OBSERVATION(i);
OBR obr = orderObs.getOBR();
// OBR values
Expand Down Expand Up @@ -271,14 +269,15 @@ protected Concept getConcept(String hl7ConceptId, String codingSystem, String ui
try {
conceptId = Integer.valueOf(hl7ConceptId);
} catch (NumberFormatException e) {
if (hl7ConceptId.equals("D??tect??")) {
if (hl7ConceptId.equals("Détecté")) {
LOGGER.info("this is the value text 2 : " + hl7ConceptId);
conceptId = Integer.valueOf(DETECTED_CODED_VALUE);
} else if (hl7ConceptId.equals("Non-D??tect??")) {
} else if (hl7ConceptId.equals("Non-Détecté")) {
LOGGER.info("this is the value text 3 : " + hl7ConceptId);
conceptId = Integer.valueOf(NOT_DETECTED_CODED_VALUE);
}
}
}
}

return Context.getConceptService().getConcept(conceptId);
} else {
// the concept is not local, look it up in our mapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,25 @@ public void processMessage_shouldParseObsAndNotReturnNull() throws HL7Exception,
Message message1 = oruR01Handler.processMessage(message);
assertNotNull(message);
}

@Test
public void processMessage_shouldProcessMessageToObs() throws Exception {
executeDataSet(DATASET);

String hl7Message = "MSH|^~\\&|||||20241216090516-0500||ORU^R01|00000000|P|2.5\n" +
"PID||33118500^^^^MR^112123|33118500^^^^MR^112123||WASHINGTONN^GLENN||20000601|M||U|^4èME LA MONTAGNE^JEAN RABEL^NRO|||||||^7a732da7-f3a8-40fe-b9eb-c8a058de9497\n" +
"PV1||R|11223||||11223^OPAP^PRESTATAIRE^^^^^^^^^^L||||||||||^^^^^^^^^^^^L|||||||||||||||||||||||||||20241216||||||290fb4d0-2ae6-40bd-a058-436acea3d881^f037e97b-471e-4898-a07c-b8e169e0ddc4^^b181ab58-e4fb-4b47-bc69-f0c05dd473cd^7a732da7-f3a8-40fe-b9eb-c8a058de9497\n" +
"ORC|RE|11223-53-440|1|C8160001|||^^^202412160558-0500^^R||202412160558|HISTC||11223^OPAP^PRESTATAIRE^^^^^^^^^^L|11223\n" +
"OBR|1|11223-53-440|1|f037e97b-471e-4898-a07c-b8e169e0ddc4|||202412160558|||HISTC|N|||202412160600||11223^OPAP^PRESTATAIRE^^^^^^^^^^L||||||202412160905-0500|||F||^^^202412160558-0500^^R|||||||DIG\n" +
"OBX|1|CE|44871-2^^LN^LVH2P^ADN VIH-1, PCR-2^L|0|Détecté|||*|||F|||202412160601||DIG|||202412160905";
hl7Message = hl7Message.replaceFirst(ORUR01_ORU_R01, ORU_R01);
hl7Message = hl7Message.replaceFirst(VERSION_251, VERSION_25);
hl7Message = hl7Message.replace("\n", Character.toString((char) 13));
hl7Message = hl7Message.replaceAll("\\[[0-9]{4}\\]", "");

Message message = new PipeParser().parse(hl7Message);
OruR01Handler oruR01Handler = new OruR01Handler();

Message ack = oruR01Handler.processMessage(message);
}
}
15 changes: 15 additions & 0 deletions api/src/test/resources/lab-dataset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
concept_id="162929" uuid="278664ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB" concept_map_type_id="1"
creator="1" date_created="2005-01-06 00:00:00"/>

<concept_reference_term concept_reference_term_id="278666" creator="1" date_created="2005-01-06 00:00:00"
concept_source_id="6" code="44871-2" uuid=" 3cd1e7d8-0645-4469-bdd2-4c7b607eedc0 "
retired="0"/>

<concept_reference_map concept_reference_term_id="278666" concept_map_id="278666"
concept_id="856" uuid="278666ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB" concept_map_type_id="1"
creator="1" date_created="2005-01-06 00:00:00"/>

<!-- Birth Place -->
<concept concept_id="21399" retired="0" date_created="2005-01-06 00:00:00" is_set="1"/>
<concept concept_id="21400" retired="0" date_created="2005-01-06 00:00:00" is_set="0"/>
Expand Down Expand Up @@ -184,5 +192,12 @@
location_id="2"
uuid="549c78dc-31da-11e8-acac-c3add5b19973"/>

<encounter encounter_id="22"
patient_id="10" encounter_type="22"
encounter_datetime="2018-03-28 17:16:07"
creator="1" date_created="2005-01-06 00:00:00" voided="0"
location_id="2"
uuid="7a732da7-f3a8-40fe-b9eb-c8a058de9497"/>


</dataset>

0 comments on commit b996fed

Please sign in to comment.