Search in sources :

Example 31 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvStateValidatorTest method testValidate.

@Test
void testValidate() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_state.json");
    var dvState = new DvState();
    dvState.setValue(new DvCodedText("Test", new CodePhrase(new TerminologyId("local"), "at0010")));
    var result = validator.validate(dvState, node);
    assertTrue(result.isEmpty());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvState(com.nedap.archie.rm.datavalues.DvState) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Test(org.junit.jupiter.api.Test)

Example 32 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvStateValidatorTest method testValidate_List.

@Test
void testValidate_List() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_state_codedtext.json");
    var dvState = new DvState();
    dvState.setValue(new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0028")));
    var result = validator.validate(dvState, node);
    assertTrue(result.isEmpty());
    dvState.setValue(new DvCodedText("Test", new CodePhrase(new TerminologyId("local"), "at0010")));
    result = validator.validate(dvState, node);
    assertEquals(1, result.size());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvState(com.nedap.archie.rm.datavalues.DvState) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Test(org.junit.jupiter.api.Test)

Example 33 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project fhir-bridge by ehrbase.

the class KontaktActionConverter method mapContactWithInfected.

private void mapContactWithInfected(Boolean hadContact) {
    DvCodedText dvCodedText = new DvCodedText("Done", new CodePhrase(new TerminologyId("local"), "at0016"));
    kontaktAction.setCurrentState(dvCodedText);
    if (hadContact) {
        kontaktAction.setKontaktZuEinemBestaetigtenFallDefiningCode(AelterOderGleich65JahreAltDefiningCode.JA);
    } else {
        kontaktAction.setKontaktZuEinemBestaetigtenFallDefiningCode(AelterOderGleich65JahreAltDefiningCode.NEIN);
    }
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase)

Example 34 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project fhir-bridge by ehrbase.

the class DocumentReferenceToHipDocumentConverter method getMultimedia.

private MediendateiCluster getMultimedia(DocumentReference documentReference) {
    Attachment attachment = documentReference.getContentFirstRep().getAttachment();
    DvMultimedia multimedia = new DvMultimedia();
    multimedia.setUri(new DvURI(attachment.getUrl()));
    multimedia.setMediaType(new CodePhrase(new TerminologyId("IANA_media-types"), attachment.getContentType()));
    multimedia.setSize(attachment.getSize());
    MediendateiCluster result = new MediendateiCluster();
    result.setMediendateiInhalt(multimedia);
    result.setMediendateiInhaltValue(attachment.getTitle());
    result.setBeschreibungValue(documentReference.getDescription());
    getCreation(attachment).ifPresent(result::setErstelltValue);
    return result;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Attachment(org.hl7.fhir.r4.model.Attachment) DvMultimedia(com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia) MediendateiCluster(org.ehrbase.fhirbridge.ehr.opt.hipdocumentcomposition.definition.MediendateiCluster) DvURI(com.nedap.archie.rm.datavalues.DvURI)

Example 35 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class StdToCompositionWalker method postHandle.

@Override
protected void postHandle(Context<Map<FlatPathDto, String>> context) {
    super.postHandle(context);
    if (isRaw(context)) {
        handleRaw(context);
    }
    WebTemplateNode currentNode = context.getNodeDeque().peek();
    currentNode.getChildren().forEach(childNode -> {
        // Check for Raw in optional (skipped Nodes)
        if (context.getFlatHelper().skip(childNode, currentNode)) {
            context.getNodeDeque().push(childNode);
            context.getRmObjectDeque().push(new RMObject() {
            });
            String path = context.getFlatHelper().buildNamePath(context, true);
            Map<FlatPathDto, String> subValues = context.getObjectDeque().peek().entrySet().stream().filter(e -> e.getKey().startsWith(path + "/_" + childNode.getId())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
            context.getObjectDeque().push(subValues);
            if (isRaw(context)) {
                handleRaw(context);
            }
            context.getNodeDeque().poll();
            context.getRmObjectDeque().poll();
            context.getObjectDeque().poll();
        }
    });
    List<? extends UnmarshalPostprocessor<? extends RMObject>> postprocessor = findUnmarshalPostprocessors(context.getRmObjectDeque().peek().getClass());
    String namePath = buildNamePathWithElementHandling(context);
    if (Entry.class.isAssignableFrom(context.getRmObjectDeque().peek().getClass())) {
        if (((Entry) context.getRmObjectDeque().peek()).getSubject() instanceof PartyRelated) {
            Optional.ofNullable(context.getNodeDeque().peek()).flatMap(c -> c.findChildById("subject")).flatMap(c -> c.findChildById("relationship")).stream().map(WebTemplateNode::getInputs).flatMap(List::stream).filter(i -> "code".equals(i.getSuffix())).map(WebTemplateInput::getList).map(l -> l.size() == 1 ? l.get(0) : null).filter(Objects::nonNull).findAny().ifPresent(v -> ((PartyRelated) ((Entry) context.getRmObjectDeque().peek()).getSubject()).setRelationship(new DvCodedText(v.getLabel(), new CodePhrase(new TerminologyId("openehr"), v.getValue()))));
        }
    }
    postprocessor.forEach(p -> ((UnmarshalPostprocessor) p).process(namePath, context.getRmObjectDeque().peek(), context.getObjectDeque().peek(), consumedPaths, context));
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) ToCompositionWalker(org.ehrbase.serialisation.walker.ToCompositionWalker) DefaultRMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.DefaultRMUnmarshaller) Element(com.nedap.archie.rm.datastructures.Element) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) WebTemplateSkeletonBuilder(org.ehrbase.building.webtemplateskeletnbuilder.WebTemplateSkeletonBuilder) HashSet(java.util.HashSet) Map(java.util.Map) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Entry(com.nedap.archie.rm.composition.Entry) UnmarshalPostprocessor(org.ehrbase.serialisation.flatencoding.std.umarshal.postprocessor.UnmarshalPostprocessor) DV_TEXT(org.ehrbase.util.rmconstants.RmConstants.DV_TEXT) Context(org.ehrbase.serialisation.walker.Context) ReflectionHelper(org.ehrbase.util.reflection.ReflectionHelper) ELEMENT(org.ehrbase.util.rmconstants.RmConstants.ELEMENT) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) DvText(com.nedap.archie.rm.datavalues.DvText) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebTemplateInput(org.ehrbase.webtemplate.model.WebTemplateInput) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) DV_CODED_TEXT(org.ehrbase.util.rmconstants.RmConstants.DV_CODED_TEXT) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) UnmarshalException(org.ehrbase.serialisation.exception.UnmarshalException) JacksonUtil(org.ehrbase.serialisation.jsonencoding.JacksonUtil) Objects(java.util.Objects) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) List(java.util.List) WebTemplateUtils(org.ehrbase.webtemplate.util.WebTemplateUtils) RMObject(com.nedap.archie.rm.RMObject) Optional(java.util.Optional) RMUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.rmunmarshaller.RMUnmarshaller) NodeId(org.ehrbase.serialisation.walker.NodeId) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) PartyRelated(com.nedap.archie.rm.generic.PartyRelated) Collections(java.util.Collections) Filter(org.ehrbase.webtemplate.filter.Filter) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) WebTemplateInput(org.ehrbase.webtemplate.model.WebTemplateInput) PartyRelated(com.nedap.archie.rm.generic.PartyRelated) Entry(com.nedap.archie.rm.composition.Entry) Objects(java.util.Objects) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) RMObject(com.nedap.archie.rm.RMObject)

Aggregations

CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)71 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)60 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)56 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)16 Composition (com.nedap.archie.rm.composition.Composition)12 DvText (com.nedap.archie.rm.datavalues.DvText)12 ArrayList (java.util.ArrayList)8 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 RMObject (com.nedap.archie.rm.RMObject)5 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)5 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)5 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)4 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)4 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)4 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)4 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)4 Entry (com.nedap.archie.rm.composition.Entry)3