use of io.github.linuxforhealth.api.EvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.
the class ResourceExpressionTest method test1_segment.
@Test
void test1_segment() throws IOException {
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));
Map<String, Object> result = (Map<String, Object>) value.getValue();
assertThat(result.get("use")).isNull();
assertThat(result).containsEntry("value", "000010016");
}
use of io.github.linuxforhealth.api.EvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.
the class ResourceExpressionTest method test1_segment_rep.
@Test
void test1_segment_rep() throws IOException {
String message = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.3|\r" + "EVN|A01|20130617154644\r" + "PID|1|465 306 5961|000010016^^^SY1^MR~000010017^^^SY2^SS~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").withGenerateList(true).build();
ResourceExpression exp = new ResourceExpression(attr);
assertThat(exp.getData()).isNotNull();
Map<String, EvaluationResult> context = new HashMap<>();
context.put("code", new SimpleEvaluationResult(hl7DTE.getTypes((Segment) s, 3)));
EvaluationResult value = exp.evaluate(new HL7MessageData(hl7DTE), ImmutableMap.copyOf(context), new SimpleEvaluationResult(s));
List<Object> results = (List<Object>) value.getValue();
assertThat(results).hasSize(3);
Map<String, Object> result = (Map<String, Object>) results.get(0);
assertThat(result.get("use")).isNull();
assertThat(result).containsEntry("value", "000010016");
assertThat(result.get("system")).isNull();
assertThat(result.get("type")).isNotNull();
}
use of io.github.linuxforhealth.api.EvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.
the class ResourceExpressionTest method testCodeableConceptFromISTtype.
@Test
void testCodeableConceptFromISTtype() 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|TestPatient^Jane|19700101|female||||||||||\r" + "PV1|1||Location||||||||||||||||261938_6_201306171546|||||||||||||||||||||||||20130617134644|||||||||\r" + "OBX|1|TX|1234^^SCT||First line: ECHOCARDIOGRAPHIC REPORT|||AA|||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.8").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).get("text")).isNull();
assertThat(result.get(0).get("coding")).isNotNull();
List<SimpleCode> scs = (List<SimpleCode>) result.get(0).get("coding");
SimpleCode sc = scs.get(0);
assertThat(sc.getCode()).isEqualTo("AA");
assertThat(sc.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0078");
assertThat(sc.getDisplay()).isEqualTo("Critically abnormal");
}
use of io.github.linuxforhealth.api.EvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.
the class ExpressionUtility method processExpression.
private static void processExpression(InputDataExtractor dataSource, EvaluationResult baseValue, Map<String, EvaluationResult> localContext, List<ResourceValue> additionalResolveValues, Map<String, Object> resolveValues, Entry<String, Expression> entry) {
EvaluationResult obj = entry.getValue().evaluate(dataSource, localContext, baseValue);
LOGGER.debug("Evaluated {} {} value returned {} ", entry.getKey(), entry.getValue(), obj);
if (obj != null && !obj.isEmpty()) {
String keyNameSuffix = getKeyNameSuffix(localContext);
// Check if the key already exist in the HashMap, if found append, do not replace
if (!resolveValues.containsKey(getKeyName(entry.getKey(), keyNameSuffix))) {
resolveValues.put(getKeyName(entry.getKey(), keyNameSuffix), obj.getValue());
} else {
Object existing = resolveValues.get(getKeyName(entry.getKey(), keyNameSuffix));
if (existing instanceof List) {
if (obj.getValue() instanceof List) {
((List<Object>) existing).addAll(obj.getValue());
} else {
((List<Object>) existing).add(obj.getValue());
}
}
}
if (obj.getAdditionalResources() != null && !obj.getAdditionalResources().isEmpty() && additionalResolveValues != null) {
additionalResolveValues.addAll(obj.getAdditionalResources());
}
}
}
use of io.github.linuxforhealth.api.EvaluationResult in project hl7v2-fhir-converter by LinuxForHealth.
the class SimpleExpressionTest method test_variable.
@Test
void test_variable() {
ExpressionAttributes attr = new ExpressionAttributes.Builder().withValue(SOME_VALUE).build();
SimpleExpression exp = new SimpleExpression(attr);
Map<String, EvaluationResult> context = new HashMap<>();
context.put("var1", new SimpleEvaluationResult(SOME_VALUE));
EvaluationResult value = exp.evaluate(data, ImmutableMap.copyOf(context), new EmptyEvaluationResult());
assertThat((String) value.getValue()).isEqualTo(SOME_VALUE);
}
Aggregations