Search in sources :

Example 1 with CanonicalPair

use of org.hl7.fhir.utilities.CanonicalPair in project org.hl7.fhir.core by hapifhir.

the class ConceptMapEngine method translateByJustCode.

private Coding translateByJustCode(ConceptMap cm, String code) throws FHIRException {
    SourceElementComponent ct = null;
    ConceptMapGroupComponent cg = null;
    for (ConceptMapGroupComponent g : cm.getGroup()) {
        for (SourceElementComponent e : g.getElement()) {
            if (code.equals(e.getCode())) {
                if (e != null)
                    throw new FHIRException("Unable to process translate " + code + " because multiple candidate matches were found in concept map " + cm.getUrl());
                ct = e;
                cg = g;
            }
        }
    }
    if (ct == null)
        return null;
    TargetElementComponent tt = null;
    for (TargetElementComponent t : ct.getTarget()) {
        if (!t.hasDependsOn() && !t.hasProduct() && isOkRelationship(t.getRelationship())) {
            if (tt != null)
                throw new FHIRException("Unable to process translate " + code + " because multiple targets were found in concept map " + cm.getUrl());
            tt = t;
        }
    }
    if (tt == null)
        return null;
    CanonicalPair cp = new CanonicalPair(cg.getTarget());
    return new Coding().setSystem(cp.getUrl()).setVersion(cp.getVersion()).setCode(tt.getCode()).setDisplay(tt.getDisplay());
}
Also used : Coding(org.hl7.fhir.r5.model.Coding) TargetElementComponent(org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent) FHIRException(org.hl7.fhir.exceptions.FHIRException) SourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent) ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent) CanonicalPair(org.hl7.fhir.utilities.CanonicalPair)

Example 2 with CanonicalPair

use of org.hl7.fhir.utilities.CanonicalPair in project org.hl7.fhir.core by hapifhir.

the class ConceptMap30_50 method convertConceptMapGroupComponent.

public static org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent convertConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent src) throws FHIRException {
    if (src == null)
        return null;
    org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent tgt = new org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent();
    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
    if (src.hasSource()) {
        CanonicalPair cp = new CanonicalPair(src.getSource());
        tgt.setSource(cp.getUrl());
        tgt.setSourceVersion(cp.getVersion());
    }
    if (src.hasTarget()) {
        CanonicalPair cp = new CanonicalPair(src.getTarget());
        tgt.setTarget(cp.getUrl());
        tgt.setTargetVersion(cp.getVersion());
    }
    for (org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent t : src.getElement()) tgt.addElement(convertSourceElementComponent(t));
    if (src.hasUnmapped())
        tgt.setUnmapped(convertConceptMapGroupUnmappedComponent(src.getUnmapped()));
    return tgt;
}
Also used : CanonicalPair(org.hl7.fhir.utilities.CanonicalPair)

Example 3 with CanonicalPair

use of org.hl7.fhir.utilities.CanonicalPair in project org.hl7.fhir.core by hapifhir.

the class ConceptMapEngine method translateByJustCode.

private Coding translateByJustCode(ConceptMap cm, String code) throws FHIRException {
    SourceElementComponent ct = null;
    ConceptMapGroupComponent cg = null;
    for (ConceptMapGroupComponent g : cm.getGroup()) {
        for (SourceElementComponent e : g.getElement()) {
            if (code.equals(e.getCode())) {
                if (e != null)
                    throw new FHIRException("Unable to process translate " + code + " because multiple candidate matches were found in concept map " + cm.getUrl());
                ct = e;
                cg = g;
            }
        }
    }
    if (ct == null)
        return null;
    TargetElementComponent tt = null;
    for (TargetElementComponent t : ct.getTarget()) {
        if (!t.hasDependsOn() && !t.hasProduct() && isOkEquivalence(t.getEquivalence())) {
            if (tt != null)
                throw new FHIRException("Unable to process translate " + code + " because multiple targets were found in concept map " + cm.getUrl());
            tt = t;
        }
    }
    if (tt == null)
        return null;
    CanonicalPair cp = new CanonicalPair(cg.getTarget());
    return new Coding().setSystem(cp.getUrl()).setVersion(cp.getVersion()).setCode(tt.getCode()).setDisplay(tt.getDisplay());
}
Also used : Coding(org.hl7.fhir.r4b.model.Coding) TargetElementComponent(org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent) FHIRException(org.hl7.fhir.exceptions.FHIRException) SourceElementComponent(org.hl7.fhir.r4b.model.ConceptMap.SourceElementComponent) ConceptMapGroupComponent(org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent) CanonicalPair(org.hl7.fhir.utilities.CanonicalPair)

Example 4 with CanonicalPair

use of org.hl7.fhir.utilities.CanonicalPair in project org.hl7.fhir.core by hapifhir.

the class ConceptMap40_50 method convertConceptMapGroupComponent.

public static org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent convertConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent src) throws FHIRException {
    if (src == null)
        return null;
    org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent tgt = new org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent();
    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
    if (src.hasSource()) {
        CanonicalPair cp = new CanonicalPair(src.getSource());
        tgt.setSource(cp.getUrl());
        tgt.setSourceVersion(cp.getVersion());
    }
    if (src.hasTarget()) {
        CanonicalPair cp = new CanonicalPair(src.getTarget());
        tgt.setTarget(cp.getUrl());
        tgt.setTargetVersion(cp.getVersion());
    }
    for (org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent t : src.getElement()) tgt.addElement(convertSourceElementComponent(t));
    if (src.hasUnmapped())
        tgt.setUnmapped(convertConceptMapGroupUnmappedComponent(src.getUnmapped()));
    return tgt;
}
Also used : CanonicalPair(org.hl7.fhir.utilities.CanonicalPair)

Aggregations

CanonicalPair (org.hl7.fhir.utilities.CanonicalPair)4 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 Coding (org.hl7.fhir.r4b.model.Coding)1 ConceptMapGroupComponent (org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent)1 SourceElementComponent (org.hl7.fhir.r4b.model.ConceptMap.SourceElementComponent)1 TargetElementComponent (org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent)1 Coding (org.hl7.fhir.r5.model.Coding)1 ConceptMapGroupComponent (org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent)1 SourceElementComponent (org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent)1 TargetElementComponent (org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent)1