Search in sources :

Example 36 with ConceptMapGroupComponent

use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project kindling by HL7.

the class CodeListToValueSetParser method getGroup.

private ConceptMapGroupComponent getGroup(ConceptMap map, String srcs, String tgts) {
    for (ConceptMapGroupComponent grp : map.getGroup()) {
        if (grp.getSource().equals(srcs) && grp.getTarget().equals(tgts))
            return grp;
    }
    ConceptMapGroupComponent grp = map.addGroup();
    grp.setSource(srcs);
    grp.setTarget(tgts);
    return grp;
}
Also used : ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent)

Example 37 with ConceptMapGroupComponent

use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project kindling by HL7.

the class Publisher method buildConceptMap.

private ConceptMap buildConceptMap(String path, ValueSet vs, ResourceDefn rd) throws EOperationOutcome, FHIRException, IOException {
    ConceptMap cm = new ConceptMap();
    cm.setUserData("path", "sc-" + vs.getUserString("path"));
    cm.setUserData("resource-definition", rd);
    cm.setId("sc-" + vs.getId());
    cm.setUrl("http://hl7.org/fhir/ConceptMap/" + cm.getId());
    cm.setVersion(page.getVersion().toCode());
    cm.setName(vs.getName() + "CanonicalMap");
    cm.setTitle("Canonical Mapping for \"" + vs.present() + "\"");
    cm.setStatus(PublicationStatus.DRAFT);
    cm.setDate(vs.getDate());
    cm.setPublisher(vs.getPublisher());
    cm.addContact(vs.getContactFirstRep());
    cm.setDescription("Canonical Mapping for \"" + vs.getDescription() + "\"");
    cm.setSource(new CanonicalType(vs.getUrl()));
    cm.setTarget(new CanonicalType("http://hl7.org/fhir/ValueSet/resource-status"));
    List<String> canonical = page.getDefinitions().getStatusCodes().get("@code");
    List<String> self = page.getDefinitions().getStatusCodes().get(path);
    ConceptMapGroupComponent grp = cm.addGroup();
    grp.setTarget("http://hl7.org/fhir/resource-status");
    grp.setSource(vs.getCompose().getIncludeFirstRep().getSystem());
    for (int i = 0; i < self.size(); i++) {
        if (!Utilities.noString(self.get(i))) {
            String cc = canonical.get(i);
            String sc = self.get(i);
            SourceElementComponent e = grp.addElement();
            e.setCode(sc);
            TargetElementComponent t = e.addTarget();
            t.setCode(cc);
            t.setRelationship(ConceptMapRelationship.EQUIVALENT);
        }
    }
    if (!grp.hasElement())
        return null;
    page.getConceptMaps().see(cm, page.packageInfo());
    statusCodeConceptMaps.add(cm);
    return cm;
}
Also used : TargetElementComponent(org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) SourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent)

Example 38 with ConceptMapGroupComponent

use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project org.hl7.fhir.core by hapifhir.

the class ConceptMap10_30 method getGroup.

public static ConceptMapGroupComponent getGroup(ConceptMap map, String srcs, String tgts) {
    for (ConceptMapGroupComponent grp : map.getGroup()) {
        if (grp.getSource().equals(srcs) && grp.getTarget().equals(tgts))
            return grp;
    }
    ConceptMapGroupComponent grp = map.addGroup();
    grp.setSource(srcs);
    grp.setTarget(tgts);
    return grp;
}
Also used : ConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent)

Example 39 with ConceptMapGroupComponent

use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project org.hl7.fhir.core by hapifhir.

the class SearchParameterProcessor method generate.

private void generate(String src, String dst, String srcURL, String tgtURL) throws IOException {
    ConceptMap map = new ConceptMap();
    map.setId("search-parameters-" + src + "-to-" + dst);
    map.setUrl("http://hl7.org/fhir/interversion/ConceptMap/" + map.getId());
    map.setName("SearchParameterMap" + src + dst);
    map.setTitle("Search Parameter Map - " + src + " to " + dst);
    map.setStatus(PublicationStatus.DRAFT);
    map.setDate(new Date());
    map.setExperimental(false);
    map.setPublisher("HL7");
    ConceptMapGroupComponent group = map.addGroup();
    group.setSource("http://hl7.org/fhir/" + srcURL);
    group.setTarget("http://hl7.org/fhir/" + tgtURL);
    for (SPRelationship sp : list) {
        String s = sp.getByCode(src);
        String d = sp.getByCode(dst);
        if (!Utilities.noString(s) && !Utilities.noString(d)) {
            SourceElementComponent e = makeElement(s, group);
            e.addTarget().setCode(d).setRelationship(ConceptMapRelationship.RELATEDTO);
        }
    }
    new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(ROOT, "ConceptMap-" + map.getId() + ".json")), map);
}
Also used : FileOutputStream(java.io.FileOutputStream) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) Date(java.util.Date) ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent) SourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent) JsonParser(org.hl7.fhir.r5.formats.JsonParser)

Example 40 with ConceptMapGroupComponent

use of org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent in project org.hl7.fhir.core by hapifhir.

the class ConceptMapSpreadsheetGenerator method renderGroup.

private void renderGroup(ConceptMapGroupComponent grp, int i) {
    Sheet sheet = makeSheet("Mapping Table " + Integer.toString(i));
    addHeaders(sheet, "Source", "Display", "Relationship", "Target", "Display");
    addRow(sheet, grp.getSource(), "", "", grp.getTarget(), "");
    for (SourceElementComponent s : grp.getElement()) {
        for (TargetElementComponent t : s.getTarget()) {
            addRow(sheet, s.getCode(), s.getDisplay(), t.getRelationshipElement().asStringValue(), t.getCode(), t.getDisplay());
        }
    }
}
Also used : TargetElementComponent(org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent) Sheet(org.apache.poi.ss.usermodel.Sheet) SourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent)

Aggregations

ConceptMapGroupComponent (org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent)17 ConceptMapGroupComponent (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent)14 SourceElementComponent (org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent)13 ConceptMapGroupComponent (org.hl7.fhir.r4.model.ConceptMap.ConceptMapGroupComponent)12 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 SourceElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)9 TargetElementComponent (org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent)9 SourceElementComponent (org.hl7.fhir.r4.model.ConceptMap.SourceElementComponent)8 ConceptMapGroupComponent (org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent)8 HashMap (java.util.HashMap)7 SourceElementComponent (org.hl7.fhir.r4b.model.ConceptMap.SourceElementComponent)7 ArrayList (java.util.ArrayList)6 TargetElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent)6 TargetElementComponent (org.hl7.fhir.r4.model.ConceptMap.TargetElementComponent)6 TargetElementComponent (org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent)6 UriType (org.hl7.fhir.dstu3.model.UriType)5 ConceptMap (org.hl7.fhir.dstu3.model.ConceptMap)4 ConceptMap (org.hl7.fhir.r4.model.ConceptMap)4 FileOutputStream (java.io.FileOutputStream)3 HashSet (java.util.HashSet)3