Search in sources :

Example 1 with HL7DataExtractor

use of io.github.linuxforhealth.hl7.parsing.HL7DataExtractor in project hl7v2-fhir-converter by LinuxForHealth.

the class SegmentUtilTest method test_single_segment.

@Test
void test_single_segment() throws HL7Exception {
    Message hl7message = getMessage(hl7ADTmessage);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    SegmentGroup segmentGroup = SegmentExtractorUtil.extractSegmentNonGroups("OBX", new ArrayList<>(), hl7DTE).get(0);
    assertThat(segmentGroup).isNotNull();
    Segment s = (Segment) segmentGroup.getSegments().get(0);
    ParsingResult<Type> type = hl7DTE.getType(s, 5, 0);
    assertThat(Hl7DataHandlerUtil.getStringValue(type.getValue())).isEqualTo(ECHOCARDIOGRAPHIC_REPORT);
    assertThat(segmentGroup.getAdditionalSegments()).isEmpty();
}
Also used : Type(ca.uhn.hl7v2.model.Type) Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) ArrayList(java.util.ArrayList) SegmentGroup(io.github.linuxforhealth.hl7.message.util.SegmentGroup) Segment(ca.uhn.hl7v2.model.Segment) Test(org.junit.jupiter.api.Test)

Example 2 with HL7DataExtractor

use of io.github.linuxforhealth.hl7.parsing.HL7DataExtractor in project hl7v2-fhir-converter by LinuxForHealth.

the class SegmentUtilTest method test_single_segment_with_additional_segment.

@Test
void test_single_segment_with_additional_segment() throws HL7Exception {
    Message hl7message = getMessage(hl7ADTmessage);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    SegmentGroup segmentGroup = SegmentExtractorUtil.extractSegmentNonGroups("OBX", Lists.newArrayList(new HL7Segment("PV1")), hl7DTE).get(0);
    assertThat(segmentGroup).isNotNull();
    Segment s = (Segment) segmentGroup.getSegments().get(0);
    ParsingResult<Type> type = hl7DTE.getType(s, 5, 0);
    assertThat(Hl7DataHandlerUtil.getStringValue(type.getValue())).isEqualTo(ECHOCARDIOGRAPHIC_REPORT);
    assertThat(segmentGroup.getAdditionalSegments()).hasSize(1);
    Segment pv1 = (Segment) segmentGroup.getAdditionalSegments().get("PV1").get(0);
    assertThat(pv1.isEmpty()).isFalse();
    assertThat(pv1.getName()).isEqualTo("PV1");
}
Also used : Type(ca.uhn.hl7v2.model.Type) Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) SegmentGroup(io.github.linuxforhealth.hl7.message.util.SegmentGroup) Segment(ca.uhn.hl7v2.model.Segment) Test(org.junit.jupiter.api.Test)

Example 3 with HL7DataExtractor

use of io.github.linuxforhealth.hl7.parsing.HL7DataExtractor in project hl7v2-fhir-converter by LinuxForHealth.

the class SegmentUtilTest method test_VUX_rep.

@Test
void test_VUX_rep() throws HL7Exception {
    String hl7VUXmessageRep = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.5.1|||NE|AL||||||RI543763\r" + "PID|1||432155^^^^MR||Patient^Johnny^New^^^^L|Smith^Sally|20130414|M||2106-3^White^HL70005|123 Any St^^Somewhere^WI^54000^^M\r" + "NK1|1|Patient^Sally|MTH^mother^HL70063|123 Any St^^Somewhere^WI^54000^^M|^PRN^PH^^^608^5551212|||||||||||19820517||||eng^English^ISO639\r" + "ORC|RE||197023|||||||^Clerk^Myron|||||||RI2050\r" + "RXA|0|1|20130415|20130415|31^Hep B Peds NOS^CVX|999|||01^historical record^NIP001||||||||\r" + "ORC|RE||197027|||||||^Clerk^Myron||MD67895^Pediatric^MARY^^^^MD^^RIA|||||RI2050\r" + "RXA|0|1|20130531|20130531|48^HIB PRP-T^CVX|0.5|ML^^ISO+||00^new immunization record^NIP001|^Sticker^Nurse|^^^RI2050||||33k2a|20131210|PMC^sanofi^MVX|||CP|A\r" + "RXR|C28161^IM^NCIT^IM^INTRAMUSCULAR^HL70162|RT^right thigh^HL70163\r" + "OBX|1|CE|64994-7^vaccine fund pgm elig cat^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064||||||F|||20130531|||VXC40^per imm^CDCPHINVS\r" + "OBX|2|CE|30956-7^Vaccine Type^LN|2|48^HIB PRP-T^CVX||||||F|||20130531\r" + "OBX|3|TS|29768-9^VIS Publication Date^LN|2|19981216||||||F|||20130531\r" + "OBX|4|TS|29769-7^VIS Presentation Date^LN|2|20130531||||||F|||20130531\r";
    Message hl7message = getMessage(hl7VUXmessageRep);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    ArrayList<String> ORDER_GROUP_VUX = Lists.newArrayList("ORDER");
    ArrayList<String> OBSERVATION_GROUP_VUX = Lists.newArrayList("ORDER", "OBSERVATION");
    List<SegmentGroup> segmentGroups = SegmentExtractorUtil.extractSegmentGroups(ORDER_GROUP_VUX, "RXA", Lists.newArrayList(new HL7Segment(OBSERVATION_GROUP_VUX, "OBX", true), new HL7Segment(ORDER_GROUP_VUX, "RXR", true)), hl7DTE, Lists.newArrayList("ORDER"));
    assertThat(segmentGroups).hasSize(2);
    SegmentGroup segmentGroup1 = segmentGroups.get(0);
    assertThat(segmentGroup1).isNotNull();
    Segment s = (Segment) segmentGroup1.getSegments().get(0);
    ParsingResult<Type> type = hl7DTE.getType(s, 4, 0);
    assertThat(Hl7DataHandlerUtil.getStringValue(type.getValue())).isEqualTo("20130415");
    assertThat(segmentGroup1.getAdditionalSegments()).isEmpty();
    SegmentGroup segmentGroup2 = segmentGroups.get(1);
    assertThat(segmentGroup2).isNotNull();
    Segment s2 = (Segment) segmentGroup2.getSegments().get(0);
    ParsingResult<Type> type2 = hl7DTE.getType(s2, 4, 0);
    assertThat(Hl7DataHandlerUtil.getStringValue(type2.getValue())).isEqualTo("20130531");
    assertThat(segmentGroup2.getAdditionalSegments()).hasSize(2);
    List<Structure> obxs = segmentGroup2.getAdditionalSegments().get("OBX");
    assertThat(obxs).hasSize(4);
    ParsingResult<Type> obx3 = hl7DTE.getType((Segment) obxs.get(0), 3, 0);
    assertThat(Hl7DataHandlerUtil.getStringValue(obx3.getValue())).isEqualTo("64994-7");
    Segment rxr = (Segment) segmentGroup2.getAdditionalSegments().get("RXR").get(0);
    ParsingResult<Type> rxr1 = hl7DTE.getType(rxr, 1, 0);
    assertThat(Hl7DataHandlerUtil.getStringValue(rxr1.getValue())).isEqualTo("C28161");
}
Also used : Type(ca.uhn.hl7v2.model.Type) Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) SegmentGroup(io.github.linuxforhealth.hl7.message.util.SegmentGroup) Structure(ca.uhn.hl7v2.model.Structure) Segment(ca.uhn.hl7v2.model.Segment) Test(org.junit.jupiter.api.Test)

Example 4 with HL7DataExtractor

use of io.github.linuxforhealth.hl7.parsing.HL7DataExtractor in project hl7v2-fhir-converter by LinuxForHealth.

the class SegmentUtilTest method test_parent_repeat.

@Test
void test_parent_repeat() throws HL7Exception {
    Message hl7message = getMessage(messageRepeat);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    List<SegmentGroup> segmentGroups = SegmentExtractorUtil.extractSegmentGroups(ORDER_GROUP_LIST, "OBX", Lists.newArrayList(), hl7DTE, Lists.newArrayList());
    assertThat(segmentGroups).isNotEmpty().hasSize(4);
    validateEachGroup(hl7DTE, segmentGroups.get(0), 1, 0, ECHOCARDIOGRAPHIC_REPORT);
    validateEachGroup(hl7DTE, segmentGroups.get(1), 1, 0, NORMAL_LV_CHAMBER_SIZE_WITH_MILD_CONCENTRIC_LVH);
    validateEachGroup(hl7DTE, segmentGroups.get(2), 1, 0, "ECHOCARDIOGRAPHIC REPORT2");
    validateEachGroup(hl7DTE, segmentGroups.get(3), 1, 0, "NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH 3");
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) SegmentGroup(io.github.linuxforhealth.hl7.message.util.SegmentGroup) Test(org.junit.jupiter.api.Test)

Example 5 with HL7DataExtractor

use of io.github.linuxforhealth.hl7.parsing.HL7DataExtractor in project hl7v2-fhir-converter by LinuxForHealth.

the class SegmentUtilTest method test_repeating_primary_segment_with_repeating_parent_group.

@Test
void test_repeating_primary_segment_with_repeating_parent_group() throws HL7Exception {
    String message = "MSH|^~\\\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|ORU^R01|MSGID000005|T|2.6\r" + "PID||45483|45483||SMITH^SUZIE^||20160813|M|||123 MAIN STREET^^SCHENECTADY^NY^12345||(123)456-7890|||||^^^T||||||||||||\r" + "OBR|1||986^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|112^Final Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3068^JOHN^Paul^J|\r" + "OBX|1|ST|TS-F-01-007^Endocrine Disorders 7^L||obs report||||||F\r" + "OBX|2|ST|TS-F-01-008^Endocrine Disorders 8^L||ECHOCARDIOGRAPHIC REPORT||||||F\r" + "OBR|1||98^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|113^Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3065^Mahoney^Paul^J|\r" + "OBX|1|CWE|625-4^Bacteria identified in Stool by Culture^LN^^^^2.33^^result1|1|27268008^Salmonella^SCT^^^^20090731^^Salmonella species|||A^A^HL70078^^^^2.5|||P|||20120301|||^^^^^^^^Bacterial Culture||201203140957||||||\r" + "OBX|2|ST|TS-F-01-002^Endocrine Disorders^L||ECHOCARDIOGRAPHIC REPORT Group 2||||||F\r";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    List<String> orderGroupList = Lists.newArrayList("PATIENT_RESULT", "ORDER_OBSERVATION");
    List<String> observationGroupList = Lists.newArrayList("PATIENT_RESULT", "ORDER_OBSERVATION", "OBSERVATION");
    List<String> specimenGroupList = Lists.newArrayList("PATIENT_RESULT", "ORDER_OBSERVATION", "SPECIMEN");
    List<HL7Segment> additionalSegments = Lists.newArrayList(new HL7Segment(orderGroupList, "OBR", true), new HL7Segment(observationGroupList, "NTE", true), new HL7Segment(specimenGroupList, "SPM", true), new HL7Segment(orderGroupList, "MSH", false));
    List<SegmentGroup> segmentGroups = SegmentExtractorUtil.extractSegmentGroups(observationGroupList, "OBX", additionalSegments, hl7DTE, Lists.newArrayList("PATIENT_RESULT", "ORDER_OBSERVATION"));
    assertThat(segmentGroups).isNotEmpty().hasSize(4);
    List<String> firstGroupIds = Lists.newArrayList(segmentGroups.get(0).getGroupId(), segmentGroups.get(1).getGroupId());
    List<String> secondGroupIds = Lists.newArrayList(segmentGroups.get(2).getGroupId(), segmentGroups.get(3).getGroupId());
    // The first two OBX should have the same group ID
    assertThat(firstGroupIds).containsOnly(firstGroupIds.get(0));
    // The second two OBX should have the same group ID
    assertThat(secondGroupIds).containsOnly(secondGroupIds.get(0));
    // The parent should be the ORDER_OBSERVATION group
    assertThat(firstGroupIds.get(0)).contains("ORDER_OBSERVATION");
    assertThat(secondGroupIds.get(0)).contains("ORDER_OBSERVATION");
    // The first group of OBX should have a different ID than the second group of OBX.
    assertThat(firstGroupIds.get(0)).isNotEqualTo(secondGroupIds.get(0));
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) SegmentGroup(io.github.linuxforhealth.hl7.message.util.SegmentGroup) Test(org.junit.jupiter.api.Test)

Aggregations

HL7DataExtractor (io.github.linuxforhealth.hl7.parsing.HL7DataExtractor)34 Message (ca.uhn.hl7v2.model.Message)33 Test (org.junit.jupiter.api.Test)33 HashMap (java.util.HashMap)20 EvaluationResult (io.github.linuxforhealth.api.EvaluationResult)19 SimpleEvaluationResult (io.github.linuxforhealth.core.expression.SimpleEvaluationResult)19 HL7MessageData (io.github.linuxforhealth.hl7.message.HL7MessageData)19 Structure (ca.uhn.hl7v2.model.Structure)18 SegmentGroup (io.github.linuxforhealth.hl7.message.util.SegmentGroup)14 ImmutableMap (com.google.common.collect.ImmutableMap)9 Map (java.util.Map)9 Segment (ca.uhn.hl7v2.model.Segment)7 Type (ca.uhn.hl7v2.model.Type)6 List (java.util.List)6 SimpleCode (io.github.linuxforhealth.core.terminology.SimpleCode)4 EmptyEvaluationResult (io.github.linuxforhealth.core.expression.EmptyEvaluationResult)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 CX (ca.uhn.hl7v2.model.v26.datatype.CX)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1