Search in sources :

Example 16 with ConceptPropertyComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method oid2Uri.

@Override
public String oid2Uri(String oid) {
    synchronized (lock) {
        if (oid != null && oid.startsWith("urn:oid:")) {
            oid = oid.substring(8);
        }
        if (oidCache.containsKey(oid)) {
            return oidCache.get(oid);
        }
        String uri = OIDUtils.getUriForOid(oid);
        if (uri != null) {
            oidCache.put(oid, uri);
            return uri;
        }
        CodeSystem cs = fetchCodeSystem("http://terminology.hl7.org/CodeSystem/v2-tables");
        if (cs != null) {
            for (ConceptDefinitionComponent cc : cs.getConcept()) {
                for (ConceptPropertyComponent cp : cc.getProperty()) {
                    if (Utilities.existsInList(cp.getCode(), "v2-table-oid", "v2-cs-oid") && oid.equals(cp.getValue().primitiveValue())) {
                        for (ConceptPropertyComponent cp2 : cc.getProperty()) {
                            if ("v2-cs-uri".equals(cp2.getCode())) {
                                oidCache.put(oid, cp2.getValue().primitiveValue());
                                return cp2.getValue().primitiveValue();
                            }
                        }
                    }
                }
            }
        }
        for (CodeSystem css : codeSystems.getList()) {
            if (("urn:oid:" + oid).equals(css.getUrl())) {
                oidCache.put(oid, css.getUrl());
                return css.getUrl();
            }
            for (Identifier id : css.getIdentifier()) {
                if ("urn:ietf:rfc:3986".equals(id.getSystem()) && ("urn:oid:" + oid).equals(id.getValue())) {
                    oidCache.put(oid, css.getUrl());
                    return css.getUrl();
                }
            }
        }
        for (NamingSystem ns : systems.getList()) {
            if (hasOid(ns, oid)) {
                uri = getUri(ns);
                if (uri != null) {
                    oidCache.put(oid, null);
                    return null;
                }
            }
        }
    }
    oidCache.put(oid, null);
    return null;
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) Identifier(org.hl7.fhir.r5.model.Identifier) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 17 with ConceptPropertyComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.

the class CodeSystemComparer method getProp.

public ConceptPropertyComponent getProp(ConceptDefinitionComponent cd, PropertyComponent p, boolean right, CodeSystemComparison comp) {
    String c = p.getCode();
    if (right) {
        c = comp.getPropMap().get(c);
    }
    ConceptPropertyComponent cp = null;
    if (cd != null) {
        for (ConceptPropertyComponent t : cd.getProperty()) {
            if (t.hasCode() && t.getCode().equals(c)) {
                cp = t;
            }
        }
    }
    return cp;
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent)

Example 18 with ConceptPropertyComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.

the class CodeSystemComparer method mergeProps.

private void mergeProps(ConceptDefinitionComponent cd, ConceptDefinitionComponent l, ConceptDefinitionComponent r, List<PropertyComponent> destProps, CodeSystemComparison res) {
    List<ConceptPropertyComponent> matchR = new ArrayList<>();
    for (ConceptPropertyComponent lp : l.getProperty()) {
        ConceptPropertyComponent rp = findRightProp(r.getProperty(), lp, res);
        if (rp == null) {
            cd.getProperty().add(lp);
        } else {
            matchR.add(rp);
            cd.getProperty().add(lp);
            if (lp.getValue().equalsDeep(rp.getValue())) {
                cd.getProperty().add(rp.setCode(res.getPropMap().get(rp.getCode())));
            }
        }
    }
    for (ConceptPropertyComponent rp : r.getProperty()) {
        if (!matchR.contains(rp)) {
            cd.getProperty().add(rp.setCode(res.getPropMap().get(rp.getCode())));
        }
    }
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) ArrayList(java.util.ArrayList)

Example 19 with ConceptPropertyComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.

the class CodeSystemComparer method addRow.

private void addRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<ConceptDefinitionComponent> t, CodeSystemComparison comparison) {
    Row r = gen.new Row();
    rows.add(r);
    r.getCells().add(gen.new Cell(null, null, t.either().getCode(), null, null));
    if (t.hasLeft() && t.hasRight()) {
        if (t.getLeft().hasDisplay() && t.getRight().hasDisplay()) {
            if (t.getLeft().getDisplay().equals(t.getRight().getDisplay())) {
                r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).span(2));
            } else {
                r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
                r.getCells().add(gen.new Cell(null, null, t.getRight().getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
            }
        } else if (t.getLeft().hasDisplay()) {
            r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null));
            r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
        } else if (t.getRight().hasDisplay()) {
            r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
            r.getCells().add(gen.new Cell(null, null, t.getRight().getDisplay(), null, null));
        } else {
            r.getCells().add(missingCell(gen).span(2));
        }
        for (PropertyComponent p : comparison.getUnion().getProperty()) {
            ConceptPropertyComponent lp = getProp(t.getLeft(), p, false, comparison);
            ConceptPropertyComponent rp = getProp(t.getRight(), p, true, comparison);
            if (lp != null && rp != null) {
                if (lp.getValue().equals(rp.getValue())) {
                    r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).span(2));
                } else {
                    r.getCells().add(gen.new Cell(null, null, lp.getValue().toString(), null, null));
                    r.getCells().add(gen.new Cell(null, null, rp.getValue().toString(), null, null));
                }
            } else if (lp != null) {
                r.getCells().add(gen.new Cell(null, null, lp.getValue().toString(), null, null));
                r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
            } else if (rp != null) {
                r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
                r.getCells().add(gen.new Cell(null, null, rp.getValue().toString(), null, null));
            } else {
                r.getCells().add(missingCell(gen).span(2));
            }
        }
    } else if (t.hasLeft()) {
        r.setColor(COLOR_NO_ROW_RIGHT);
        r.getCells().add(gen.new Cell(null, null, t.either().getDisplay(), null, null));
        r.getCells().add(missingCell(gen));
        for (PropertyComponent p : comparison.getUnion().getProperty()) {
            r.getCells().add(propertyCell(gen, t.getLeft(), p, false, comparison));
            r.getCells().add(missingCell(gen));
        }
    } else {
        r.setColor(COLOR_NO_ROW_LEFT);
        r.getCells().add(missingCell(gen));
        r.getCells().add(gen.new Cell(null, null, t.either().getDisplay(), null, null));
        for (PropertyComponent p : comparison.getUnion().getProperty()) {
            r.getCells().add(missingCell(gen));
            r.getCells().add(propertyCell(gen, t.getLeft(), p, true, comparison));
        }
    }
    r.getCells().add(cellForMessages(gen, t.getMessages()));
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) PropertyComponent(org.hl7.fhir.r5.model.CodeSystem.PropertyComponent) ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Aggregations

ConceptPropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent)8 ConceptPropertyComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent)8 ArrayList (java.util.ArrayList)4 ConceptPropertyComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent)3 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)3 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)3 List (java.util.List)2 PropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.PropertyComponent)2 PropertyComponent (org.hl7.fhir.r5.model.CodeSystem.PropertyComponent)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 BooleanType (org.hl7.fhir.r4.model.BooleanType)1 CodeType (org.hl7.fhir.r4.model.CodeType)1 BooleanType (org.hl7.fhir.r4b.model.BooleanType)1 CodeSystem (org.hl7.fhir.r4b.model.CodeSystem)1 ConceptDefinitionDesignationComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionDesignationComponent)1 CodeType (org.hl7.fhir.r4b.model.CodeType)1