Search in sources :

Example 1 with SimpleEvaluationResult

use of io.github.linuxforhealth.core.expression.SimpleEvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ExpressionTest method test1_segment_using_valueof.

@Test
void test1_segment_using_valueof() throws IOException {
    String message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|000010016^^^MR~000010017^^^MR~000010018^^^MR|407623|Wood^Patrick^^^MR||19700101|female|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||\r" + "NK1|1|Wood^John^^^MR|Father||999-9999\r" + "NK1|2|Jones^Georgie^^^MSS|MOTHER||999-9999\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getStructure("PID", 0).getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withValueOf("PID.3").withType("String").build();
    Hl7Expression exp = new Hl7Expression(attr);
    Map<String, EvaluationResult> context = new HashMap<>();
    // context.put("PID", new SimpleEvaluationResult(s));
    EvaluationResult value = exp.evaluate(new HL7MessageData(hl7DTE), ImmutableMap.copyOf(context), new SimpleEvaluationResult(s));
    assertThat((String) value.getValue()).isEqualTo("000010016");
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) HL7MessageData(io.github.linuxforhealth.hl7.message.HL7MessageData) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Structure(ca.uhn.hl7v2.model.Structure) EvaluationResult(io.github.linuxforhealth.api.EvaluationResult) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleEvaluationResult

use of io.github.linuxforhealth.core.expression.SimpleEvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.

the class ResourceExpressionTest method test_organization_creation_with_missing_id_and_name_value.

@Test
void test_organization_creation_with_missing_id_and_name_value() throws IOException {
    String message = "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||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|^^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|59785-6^VIS Presentation Date^LN|2|20130531||||||F|||20130531\r" + "OBX|5|ST|48767-8^Annotation^LN|2|Some text from doctor||||||F|||20130531\r";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getAllStructures("ORDER", 0, "RXA").getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withSpecs("RXA.17").withValueOf("resource/Organization").withGenerateList(true).build();
    ResourceExpression exp = new ResourceExpression(attr);
    assertThat(exp.getData()).isNotNull();
    Map<String, EvaluationResult> context = new HashMap<>();
    EvaluationResult value = exp.evaluate(new HL7MessageData(hl7DTE), ImmutableMap.copyOf(context), new SimpleEvaluationResult(s));
    assertThat(value).isNull();
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) HL7MessageData(io.github.linuxforhealth.hl7.message.HL7MessageData) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Structure(ca.uhn.hl7v2.model.Structure) EvaluationResult(io.github.linuxforhealth.api.EvaluationResult) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleEvaluationResult

use of io.github.linuxforhealth.core.expression.SimpleEvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.

the class ResourceExpressionTest method test_picks_next_value_from_rep_if_first_fails_condition_or_check.

@Test
void test_picks_next_value_from_rep_if_first_fails_condition_or_check() throws IOException {
    String message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|^^^MR^SSS^^20091020^20200101~000010017^^^MR~000010018^^^MR|407623|Wood^Patrick^^^MR||19700101|female|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||\r" + "NK1|1|Wood^John^^^MR|Father||999-9999\r" + "NK1|2|Jones^Georgie^^^MSS|MOTHER||999-9999\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getStructure("PID", 0).getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withSpecs("PID.3").withValueOf("datatype/Identifier").build();
    ResourceExpression exp = new ResourceExpression(attr);
    assertThat(exp.getData()).isNotNull();
    Map<String, EvaluationResult> context = new HashMap<>();
    EvaluationResult value = exp.evaluate(new HL7MessageData(hl7DTE), ImmutableMap.copyOf(context), new SimpleEvaluationResult(s));
    assertThat(value).isNotNull();
    Map<String, Object> result = (Map<String, Object>) value.getValue();
    assertThat(result.get("use")).isNull();
    assertThat(result).containsEntry("value", "000010017");
    assertThat(result.get("type")).isNull();
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) EvaluationResult(io.github.linuxforhealth.api.EvaluationResult) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) HL7MessageData(io.github.linuxforhealth.hl7.message.HL7MessageData) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Structure(ca.uhn.hl7v2.model.Structure) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleEvaluationResult

use of io.github.linuxforhealth.core.expression.SimpleEvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.

the class ResourceExpressionTest method test_organization_creation_with_mo_missing_value.

@Test
void test_organization_creation_with_mo_missing_value() throws IOException {
    String message = "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||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|59785-6^VIS Presentation Date^LN|2|20130531||||||F|||20130531\r" + "OBX|5|ST|48767-8^Annotation^LN|2|Some text from doctor||||||F|||20130531\r";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getAllStructures("ORDER", 0, "RXA").getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withSpecs("RXA.17").withValueOf("resource/Organization").withGenerateList(true).build();
    ResourceExpression exp = new ResourceExpression(attr);
    assertThat(exp.getData()).isNotNull();
    Map<String, EvaluationResult> context = new HashMap<>();
    EvaluationResult value = exp.evaluate(new HL7MessageData(hl7DTE), ImmutableMap.copyOf(context), new SimpleEvaluationResult(s));
    List<Map<String, Object>> result = (List<Map<String, Object>>) value.getValue();
    assertThat(result.get(0)).containsEntry("name", "sanofi");
    List<Map<String, Object>> identifiers = (List<Map<String, Object>>) result.get(0).get("identifier");
    assertThat(identifiers.get(0)).containsEntry("value", "PMC");
    LOGGER.debug("result=" + result);
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) EvaluationResult(io.github.linuxforhealth.api.EvaluationResult) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) HL7MessageData(io.github.linuxforhealth.hl7.message.HL7MessageData) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) List(java.util.List) Structure(ca.uhn.hl7v2.model.Structure) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 5 with SimpleEvaluationResult

use of io.github.linuxforhealth.core.expression.SimpleEvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ExpressionTest method test3_field_subcomponent.

@Test
void test3_field_subcomponent() throws IOException {
    String message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|000010016^^^MR~000010017^^^MR~000010018^^^MR|407623|Wood^Patrick^^^MR||19700101|female|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||\r" + "NK1|1|Wood^John^^^MR|Father||999-9999\r" + "NK1|2|Jones^Georgie^^^MSS|MOTHER||999-9999\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getStructure("PID", 0).getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withSpecs("PID.3.1").withType("String").build();
    Hl7Expression exp = new Hl7Expression(attr);
    Map<String, EvaluationResult> context = new HashMap<>();
    // context.put("PID", new SimpleEvaluationResult(s));
    EvaluationResult value = exp.evaluate(new HL7MessageData(hl7DTE), ImmutableMap.copyOf(context), new SimpleEvaluationResult(s));
    assertThat((String) value.getValue()).isEqualTo("000010016");
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) HL7MessageData(io.github.linuxforhealth.hl7.message.HL7MessageData) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Structure(ca.uhn.hl7v2.model.Structure) EvaluationResult(io.github.linuxforhealth.api.EvaluationResult) SimpleEvaluationResult(io.github.linuxforhealth.core.expression.SimpleEvaluationResult) Test(org.junit.jupiter.api.Test)

Aggregations

EvaluationResult (io.github.linuxforhealth.api.EvaluationResult)22 SimpleEvaluationResult (io.github.linuxforhealth.core.expression.SimpleEvaluationResult)22 HashMap (java.util.HashMap)22 Test (org.junit.jupiter.api.Test)21 Message (ca.uhn.hl7v2.model.Message)19 HL7MessageData (io.github.linuxforhealth.hl7.message.HL7MessageData)19 HL7DataExtractor (io.github.linuxforhealth.hl7.parsing.HL7DataExtractor)19 Structure (ca.uhn.hl7v2.model.Structure)18 ImmutableMap (com.google.common.collect.ImmutableMap)10 Map (java.util.Map)10 List (java.util.List)7 EmptyEvaluationResult (io.github.linuxforhealth.core.expression.EmptyEvaluationResult)4 SimpleCode (io.github.linuxforhealth.core.terminology.SimpleCode)4 Segment (ca.uhn.hl7v2.model.Segment)1 Type (ca.uhn.hl7v2.model.Type)1 CX (ca.uhn.hl7v2.model.v26.datatype.CX)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Preconditions (com.google.common.base.Preconditions)1 Lists (com.google.common.collect.Lists)1