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());
}
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;
}
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());
}
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;
}
Aggregations