use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvOrderedPostprocessor method process.
/**
* {@inheritDoc} Adds the encoding information
*/
@Override
public void process(String term, DvOrdered rmObject, Map<String, Object> values, Context<Map<String, Object>> context) {
if (rmObject.getNormalRange() != null) {
handleRange(term + "/_normal_range", values, rmObject.getNormalRange(), context);
}
IntStream.range(0, rmObject.getOtherReferenceRanges().size()).forEach(i -> {
ReferenceRange referenceRange = (ReferenceRange) rmObject.getOtherReferenceRanges().get(i);
if (referenceRange.getMeaning() != null) {
callMarshal(term, "_other_reference_ranges:" + i + "/meaning", referenceRange.getMeaning(), values, context, context.getNodeDeque().peek().findChildById("meaning").orElse(null));
callPostprocess(term, "_other_reference_ranges:" + i + "/meaning", referenceRange.getMeaning(), values, context, context.getNodeDeque().peek().findChildById("meaning").orElse(null));
}
if (referenceRange.getRange() != null) {
handleRange(term + "/_other_reference_ranges:" + i, values, referenceRange.getRange(), context);
}
});
addValue(values, term, "normal_status", Optional.ofNullable(rmObject.getNormalStatus()).map(CodePhrase::getCodeString).orElse(null));
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TermMappingTestOverwritten method testTermMappingFromJson.
@Override
@Test
public void testTermMappingFromJson() throws Exception {
String template = this.getFileContent("/res/Demo Vitals.xml");
String rawJson = this.getFileContent("/res/TmComposition.json");
Composition unmarshal = new CanonicalJson().unmarshal(rawJson.replace("\"@class\"", "\"_type\""), Composition.class);
String structuredJson = getFlatJson(template, FlatFormat.STRUCTURED).marshal(unmarshal);
Composition actualComposition = getFlatJson(template, FlatFormat.STRUCTURED).unmarshal(structuredJson);
List<TermMapping> termMappings = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/data/items[at0.63]/value").get(0)).getMappings();
assertThat(termMappings).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "21794005", "SNOMED-CT", null), new Tuple('=', "W.11.7", "RTX", null));
List<TermMapping> termMappings2 = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/state/items[at0041]/value").get(0)).getMappings();
assertThat(termMappings2).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "99.1", "IAXA", new DvCodedText("Purpose 1", new CodePhrase(new TerminologyId("Purposes"), "p.0.63.1"))));
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class CodeSetAccessTest method testCodeSetAccess.
@Test
public void testCodeSetAccess() throws Exception {
TerminologyInterface simpleTerminologyInterface = new SimpleTerminologyInterface("en");
CodeSetAccess codeSetAccess = simpleTerminologyInterface.codeSetForId(OpenEHRCodeSetIdentifiers.INTEGRITY_CHECK_ALGORITHMS);
assertEquals("openehr_integrity_check_algorithms", codeSetAccess.id());
assertEquals(2, codeSetAccess.allCodes().size());
assertTrue(codeSetAccess.hasCode(new CodePhrase(new TerminologyId("openehr_integrity_check_algorithms"), "SHA-1")));
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvCodedTextTest method testValidate_FhirCodeSystem.
@Test
void testValidate_FhirCodeSystem() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/observation-status"), "final");
// Mockito initialization
Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status")).thenReturn(true);
Mockito.doNothing().when(fhirTerminologyValidationMock).validate("/test/dv_coded_text_fhir_code_system", "//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status", codePhrase);
var validator = new DvCodedTextValidator(fhirTerminologyValidationMock);
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_codesystem.json");
var result = validator.validate(new DvCodedText("Final", codePhrase), node);
assertTrue(result.isEmpty());
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvCodedTextTest method testValidate_UnsupportedExternalTerminology.
@Test
void testValidate_UnsupportedExternalTerminology() throws Exception {
Mockito.when(fhirTerminologyValidationMock.supports("ICD10")).thenReturn(false);
var node = parseNode("/webtemplate_nodes/dv_codedtext_unsupported.json");
var dvCodedText = new DvCodedText("Iodine-deficiency related thyroid disorders and allied conditions", new CodePhrase(new TerminologyId("ICD10"), "E01"));
var result = new DvCodedTextValidator(fhirTerminologyValidationMock).validate(dvCodedText, node);
assertTrue(result.isEmpty());
}
Aggregations