use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TermMappingRMUnmarshaller method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(String currentTerm, TermMapping rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
setValue(currentTerm, "match", currentValues, s -> Optional.ofNullable(s).map(c -> c.charAt(0)).ifPresent(rmObject::setMatch), String.class, consumedPaths);
Map<FlatPathDto, String> targetValues = FlatHelper.filter(currentValues, currentTerm + "/target", false);
if (!targetValues.isEmpty()) {
rmObject.setTarget(new CodePhrase());
context.getNodeDeque().push(buildDummyChild("target", context.getNodeDeque().peek()));
CODE_PHRASE_RM_UNMARSHALLER.handle(currentTerm + "/target", rmObject.getTarget(), targetValues, context, consumedPaths);
context.getNodeDeque().poll();
}
Map<FlatPathDto, String> purposeValues = FlatHelper.filter(currentValues, currentTerm + "/purpose", false);
if (!purposeValues.isEmpty()) {
rmObject.setPurpose(new DvCodedText());
context.getNodeDeque().push(buildDummyChild("purpose", context.getNodeDeque().peek()));
DV_CODED_TEXT_RM_UNMARSHALLER.handle(currentTerm + "/purpose", rmObject.getPurpose(), purposeValues, context, consumedPaths);
context.getNodeDeque().poll();
}
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvMultimediaRMUnmarshaller method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(String currentTerm, DvMultimedia rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
rmObject.setUri(new DvURI());
setValue(currentTerm, "url", currentValues, rmObject.getUri()::setValue, URI.class, consumedPaths);
if (rmObject.getUri().getValue() == null) {
setValue(currentTerm, null, currentValues, rmObject.getUri()::setValue, URI.class, consumedPaths);
}
if (RMHelper.isEmpty(rmObject.getUri())) {
rmObject.setUri(null);
}
rmObject.setMediaType(new CodePhrase());
rmObject.getMediaType().setTerminologyId(new TerminologyId("IANA_media-types"));
setValue(currentTerm, "mediatype", currentValues, rmObject.getMediaType()::setCodeString, String.class, consumedPaths);
setValue(currentTerm, "compression_algorithm", currentValues, codeString -> {
if (codeString != null) {
rmObject.setCompressionAlgorithm(new CodePhrase());
rmObject.getCompressionAlgorithm().setTerminologyId(new TerminologyId("openehr_compression_algorithms"));
rmObject.getCompressionAlgorithm().setCodeString(codeString);
}
}, String.class, consumedPaths);
setValue(currentTerm, "integrity_check_algorithm", currentValues, codeString -> {
if (codeString != null) {
rmObject.setIntegrityCheckAlgorithm(new CodePhrase());
rmObject.getIntegrityCheckAlgorithm().setTerminologyId(new TerminologyId("openehr_integrity_check_algorithms"));
rmObject.getIntegrityCheckAlgorithm().setCodeString(codeString);
}
}, String.class, consumedPaths);
setValue(currentTerm, "integrity_check", currentValues, codeString -> {
if (codeString != null) {
rmObject.setIntegrityCheck(codeString.getBytes(StandardCharsets.UTF_8));
}
}, String.class, consumedPaths);
setValue(currentTerm, "data", currentValues, codeString -> {
if (codeString != null) {
rmObject.setData(codeString.getBytes(StandardCharsets.UTF_8));
}
}, String.class, consumedPaths);
setValue(currentTerm, "size", currentValues, rmObject::setSize, Integer.class, consumedPaths);
setValue(currentTerm, "alternatetext", currentValues, rmObject::setAlternateText, String.class, consumedPaths);
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TermMappingTestOverwritten method testTermMappingFromMap.
@Override
@Test
public void testTermMappingFromMap() 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 flatJson = getFlatJson(template, FlatFormat.SIM_SDT).marshal(unmarshal);
Composition actualComposition = getFlatJson(template, FlatFormat.SIM_SDT).unmarshal(flatJson);
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 SimpleValidationTest method testSimpleValidation.
@Test
public void testSimpleValidation() throws Exception {
TerminologyInterface simpleTerminologyInterface = new SimpleTerminologyInterface("en");
AttributeCodesetMapping codesetMapping = AttributeCodesetMapping.getInstance();
CodePhrase codePhrase = new CodePhrase(new TerminologyId("openehr"), "433");
DvCodedText category = new DvCodedText("event", codePhrase);
// get the actual attribute
String attribute = codesetMapping.actualAttributeId("openehr", "category", "en");
ContainerType containerType = codesetMapping.containerType("openehr", "category");
switch(containerType) {
case // a code string defined within a group of a codeset
GROUP:
boolean valid = simpleTerminologyInterface.terminology("openehr").hasCodeForGroupId(attribute, codePhrase);
// check if the supplied value matches codephrase
String rubric = simpleTerminologyInterface.terminology("openehr").rubricForCode(codePhrase.getCodeString(), "en");
valid = rubric.equals("event");
break;
case // a codestring defined in a codeset
CODESET:
valid = simpleTerminologyInterface.codeSet(attribute).hasCode(codePhrase);
break;
default:
throw new IllegalArgumentException("undefined container type");
}
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TerminologyAccessTest method testTerminologyAccess.
@Test
public void testTerminologyAccess() throws Exception {
assertEquals("openehr", terminologyAccess.id());
Set<CodePhrase> codePhrases = terminologyAccess.allCodes();
assertEquals(216, codePhrases.size());
codePhrases = terminologyAccess.codesForGroupId("setting");
assertEquals(13, codePhrases.size());
// nursing home care
assertTrue(terminologyAccess.hasCodeForGroupId("setting", new CodePhrase(new TerminologyId("openehr"), "237")));
// bad code string
assertFalse(terminologyAccess.hasCodeForGroupId("setting", new CodePhrase(new TerminologyId("openehr"), "240")));
}
Aggregations