Search in sources :

Example 1 with SimpleCode

use of io.github.linuxforhealth.core.terminology.SimpleCode in project hl7v2-fhir-converter by LinuxForHealth.

the class SimpleDataValueResolverTest method get_race_value_valid.

@Test
void get_race_value_valid() throws DataTypeException {
    CWE cwe = new CWE(null);
    cwe.getCwe3_NameOfCodingSystem().setValue("HL70005");
    cwe.getCwe1_Identifier().setValue("2028-9");
    cwe.getCwe2_Text().setValue("Asian");
    SimpleCode code = SimpleDataValueResolver.CODING_SYSTEM_V2.apply(cwe);
    assertThat(code.getDisplay()).isEqualTo(V3Race._20289.getDisplay());
    assertThat(code.getCode()).isEqualTo(V3Race._20289.toCode());
    assertThat(code.getSystem()).isEqualTo(V3Race._20289.getSystem());
}
Also used : CWE(ca.uhn.hl7v2.model.v26.datatype.CWE) SimpleCode(io.github.linuxforhealth.core.terminology.SimpleCode) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleCode

use of io.github.linuxforhealth.core.terminology.SimpleCode in project hl7v2-fhir-converter by LinuxForHealth.

the class SimpleDataValueResolverTest method testSubscriberRelationship.

@Test
void testSubscriberRelationship() {
    // Check supported known input code (from table 0063) REVERSES the relationship.  See notes in v2ToFhirMapping.
    SimpleCode coding = SimpleDataValueResolver.SUBSCRIBER_RELATIONSHIP_IN117.apply("CHD");
    assertThat(coding).isNotNull();
    assertThat(coding.getCode()).isEqualTo("parent");
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/subscriber-relationship");
    assertThat(coding.getDisplay()).isEqualTo("Parent");
    // Check supported known input code (from table 0344)
    // is child
    coding = SimpleDataValueResolver.SUBSCRIBER_RELATIONSHIP_IN272.apply("04");
    assertThat(coding).isNotNull();
    assertThat(coding.getCode()).isEqualTo("child");
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/subscriber-relationship");
    assertThat(coding.getDisplay()).isEqualTo("Child");
    // Check unsupported unknown input codes
    // Because GOAT has no mapping, we pass it without a system.
    coding = SimpleDataValueResolver.POLICYHOLDER_RELATIONSHIP_IN117.apply("GOAT");
    assertThat(coding.getCode()).isEqualTo("GOAT");
    assertThat(coding.getSystem()).isNull();
    assertThat(coding.getDisplay()).isNull();
    // Because GOAT has no mapping, we pass it without a system.
    coding = SimpleDataValueResolver.POLICYHOLDER_RELATIONSHIP_IN272.apply("GOAT");
    assertThat(coding.getCode()).isEqualTo("GOAT");
    assertThat(coding.getSystem()).isNull();
    assertThat(coding.getDisplay()).isNull();
}
Also used : SimpleCode(io.github.linuxforhealth.core.terminology.SimpleCode) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleCode

use of io.github.linuxforhealth.core.terminology.SimpleCode in project hl7v2-fhir-converter by LinuxForHealth.

the class SimpleDataValueResolverTest method testMaritalStatusValueNonValid.

@Test
void testMaritalStatusValueNonValid() {
    String gen = "ZZZ";
    SimpleCode code = SimpleDataValueResolver.MARITAL_STATUS.apply(gen);
    assertThat(code).isNotNull();
    assertThat(code.getCode()).isNull();
    String theSystem = V3MaritalStatus.M.getSystem();
    assertThat(code.getSystem()).isEqualTo(theSystem);
    assertThat(code.getDisplay()).containsPattern("Invalid.*ZZZ.*" + theSystem);
}
Also used : SimpleCode(io.github.linuxforhealth.core.terminology.SimpleCode) Test(org.junit.jupiter.api.Test)

Example 4 with SimpleCode

use of io.github.linuxforhealth.core.terminology.SimpleCode in project hl7v2-fhir-converter by LinuxForHealth.

the class ResourceExpressionTest method testSegmentIdentifierObxCc.

@Test
void testSegmentIdentifierObxCc() throws IOException {
    String message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|12345678^^^MR|407623|TestPatient^John^^MR||19700101|male||||||||||\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||\r" + "OBX|1|TX|1234^some text^SCT||First line: ECHOCARDIOGRAPHIC REPORT||||||F||\r";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getStructure("OBX", 0).getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withSpecs("OBX.3").withValueOf("datatype/Identifier").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();
    Map<String, Object> type = (Map<String, Object>) result.get(0).get("type");
    assertThat(type).containsEntry("text", "some text");
    assertThat(type.get("coding")).isNotNull();
    List<Object> list = (List) type.get("coding");
    SimpleCode scs = (SimpleCode) list.get(0);
    assertThat(scs.getCode()).isEqualTo("1234");
    assertThat(scs.getSystem()).isEqualTo("http://snomed.info/sct");
    assertThat(scs.getDisplay()).isEqualTo("some text");
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) SimpleCode(io.github.linuxforhealth.core.terminology.SimpleCode) 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 SimpleCode

use of io.github.linuxforhealth.core.terminology.SimpleCode in project hl7v2-fhir-converter by LinuxForHealth.

the class ResourceExpressionTest method testSegmentIdentifierObxCcKnownSystem.

@Test
void testSegmentIdentifierObxCcKnownSystem() throws IOException {
    String message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|123456^^^MR|407623|TestPatient^John^^^MR||19700101|male||||||||||\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||\r" + "OBX|1|TX|1234^some text^SCT||First line: ECHOCARDIOGRAPHIC REPORT||||||F||\r";
    Message hl7message = getMessage(message);
    HL7DataExtractor hl7DTE = new HL7DataExtractor(hl7message);
    Structure s = hl7DTE.getStructure("OBX", 0).getValue();
    ExpressionAttributes attr = new ExpressionAttributes.Builder().withSpecs("OBX.3").withValueOf("datatype/CodeableConcept").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("text", "some text");
    assertThat(result.get(0).get("coding")).isNotNull();
    List<Object> list = (List) result.get(0).get("coding");
    SimpleCode scs = (SimpleCode) list.get(0);
    assertThat(scs.getCode()).isEqualTo("1234");
    assertThat(scs.getSystem()).isEqualTo("http://snomed.info/sct");
    assertThat(scs.getDisplay()).isEqualTo("some text");
}
Also used : Message(ca.uhn.hl7v2.model.Message) HL7DataExtractor(io.github.linuxforhealth.hl7.parsing.HL7DataExtractor) HashMap(java.util.HashMap) SimpleCode(io.github.linuxforhealth.core.terminology.SimpleCode) 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)

Aggregations

SimpleCode (io.github.linuxforhealth.core.terminology.SimpleCode)13 Test (org.junit.jupiter.api.Test)13 Message (ca.uhn.hl7v2.model.Message)4 Structure (ca.uhn.hl7v2.model.Structure)4 EvaluationResult (io.github.linuxforhealth.api.EvaluationResult)4 SimpleEvaluationResult (io.github.linuxforhealth.core.expression.SimpleEvaluationResult)4 HL7MessageData (io.github.linuxforhealth.hl7.message.HL7MessageData)4 HL7DataExtractor (io.github.linuxforhealth.hl7.parsing.HL7DataExtractor)4 HashMap (java.util.HashMap)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 List (java.util.List)3 Map (java.util.Map)3 CWE (ca.uhn.hl7v2.model.v26.datatype.CWE)1