Search in sources :

Example 1 with ConceptPropertyComponent

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

the class ICD11Generator method processMMSEntity.

private void processMMSEntity(CodeSystem cs, String base, String ref, org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cc, String dest) throws IOException {
    System.out.print(".");
    JsonObject entity = fetchJson(url(base, ref));
    cc.setId(tail(ref));
    if (entity.has("code") && !Utilities.noString(entity.get("code").getAsString())) {
        cc.setCode(entity.get("code").getAsString());
    } else if (entity.has("blockId") && !Utilities.noString(entity.get("blockId").getAsString())) {
        cc.setCode(entity.get("blockId").getAsString());
    } else {
        cc.setCode(cc.getId());
        cc.addProperty().setCode("abstract").setValue(new BooleanType(true));
    }
    if (entity.has("classKind") && !Utilities.noString(entity.get("classKind").getAsString()) && !"category".equals(entity.get("classKind").getAsString())) {
        cc.addProperty().setCode("kind").setValue(new CodeType(entity.get("classKind").getAsString()));
    }
    cc.setDisplay(readString(entity, "title"));
    StringBuilder defn = new StringBuilder();
    String d = readString(entity, "definition");
    if (d != null) {
        defn.append(d);
    }
    if (d == null && (entity.has("inclusion") || entity.has("exclusion"))) {
        defn.append(cc.getDisplay());
    }
    if (entity.has("inclusion")) {
        defn.append(". Includes: ");
        boolean first = true;
        for (JsonElement child : entity.getAsJsonArray("inclusion")) {
            if (first)
                first = false;
            else
                defn.append(", ");
            defn.append(readString((JsonObject) child, "label"));
        }
    }
    if (entity.has("exclusion")) {
        defn.append(". Excludes: ");
        boolean first = true;
        for (JsonElement child : entity.getAsJsonArray("exclusion")) {
            if (first)
                first = false;
            else
                defn.append(", ");
            JsonObject co = (JsonObject) child;
            String v = readString(co, "label");
            if (v != null) {
                defn.append(v);
                if (co.has("linearizationReference")) {
                    cc.addProperty().setValue(new Coding().setSystem("http://id.who.int/icd11/mms").setCode(tail(co.get("linearizationReference").getAsString())).setDisplay(v)).setCode("exclusion");
                }
            }
        }
    }
    cc.setDefinition(defn.toString());
    addDesignation(readString(entity, "longDefinition"), cc, "http://id.who.int/icd11/mms/designation", "longDefinition");
    addDesignation(readString(entity, "fullySpecifiedName"), cc, "http://snomed.info/sct", "900000000000003001");
    addProperty(readString(entity, "codingNote"), cc, "codingNote");
    if (entity.has("indexTerm")) {
        // }
        for (JsonElement child : entity.getAsJsonArray("indexTerm")) {
            processIndexTerm(cc, (JsonObject) child);
        }
    }
    if (entity.has("postcoordinationScale")) {
        for (JsonElement child : entity.getAsJsonArray("postcoordinationScale")) {
            JsonObject o = (JsonObject) child;
            String name = tail(o.get("axisName").getAsString());
            ConceptPropertyComponent prop = cc.addProperty();
            prop.setCode("postcoordinationScale");
            prop.setValue(new CodeType(name));
            ToolingExtensions.addBooleanExtension(prop, "http://id.who.int/icd11/extensions/required", o.get("requiredPostcoordination").getAsBoolean());
            ToolingExtensions.addBooleanExtension(prop, "http://id.who.int/icd11/extensions/repeats", o.get("allowMultipleValues").getAsBoolean());
            if (o.has("scaleEntity")) {
                ToolingExtensions.addUriExtension(prop, "http://id.who.int/icd11/extensions/valueSet", buildValueSet(cs, cc.getCode(), name, o, dest));
            }
        }
    }
    if (entity.has("child")) {
        for (JsonElement child : entity.getAsJsonArray("child")) {
            processMMSEntity(cs, base, child.getAsString(), cc.addConcept(), dest);
        }
    }
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject)

Example 2 with ConceptPropertyComponent

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

the class CodeSystemUtilities method setStatus.

public static void setStatus(CodeSystem cs, ConceptDefinitionComponent concept, ConceptStatus status) throws FHIRFormatError {
    defineStatusProperty(cs);
    ConceptPropertyComponent p = getProperty(concept, "status");
    if (p != null)
        p.setValue(new CodeType(status.toCode()));
    else
        concept.addProperty().setCode("status").setValue(new CodeType(status.toCode()));
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) CodeType(org.hl7.fhir.r5.model.CodeType)

Example 3 with ConceptPropertyComponent

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

the class CodeSystemUtilities method setNotSelectable.

public static void setNotSelectable(CodeSystem cs, ConceptDefinitionComponent concept) throws FHIRFormatError {
    defineNotSelectableProperty(cs);
    ConceptPropertyComponent p = getProperty(concept, "notSelectable");
    if (p != null)
        p.setValue(new BooleanType(true));
    else
        concept.addProperty().setCode("notSelectable").setValue(new BooleanType(true));
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) BooleanType(org.hl7.fhir.r5.model.BooleanType)

Example 4 with ConceptPropertyComponent

use of org.hl7.fhir.r4b.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.r4b.model.CodeSystem.ConceptPropertyComponent) ConceptPropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent) PropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.PropertyComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 5 with ConceptPropertyComponent

use of org.hl7.fhir.r4b.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.getCode().equals(c)) {
                cp = t;
            }
        }
    }
    return cp;
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent)

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