Search in sources :

Example 1 with PropertyComponent

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

the class CodeSystemUtilities method defineCodeSystemProperty.

public static PropertyComponent defineCodeSystemProperty(CodeSystem cs, String code, String description, PropertyType type) {
    for (PropertyComponent p : cs.getProperty()) {
        if (p.getCode().equals(code))
            return p;
    }
    PropertyComponent p = cs.addProperty();
    p.setCode(code).setDescription(description).setType(type).setUri("http://hl7.org/fhir/concept-properties#" + code);
    return p;
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent) PropertyComponent(org.hl7.fhir.r4.model.CodeSystem.PropertyComponent)

Example 2 with PropertyComponent

use of org.hl7.fhir.r5.model.CodeSystem.PropertyComponent 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 3 with PropertyComponent

use of org.hl7.fhir.r5.model.CodeSystem.PropertyComponent 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)

Example 4 with PropertyComponent

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

the class CodeSystemComparer method merge.

private ConceptDefinitionComponent merge(ConceptDefinitionComponent l, ConceptDefinitionComponent r, List<PropertyComponent> destProps, CodeSystemComparison res) {
    ConceptDefinitionComponent cd = l.copy();
    if (!l.hasDisplay() && r.hasDisplay()) {
        cd.setDisplay(r.getDisplay());
    }
    if (!l.hasDefinition() && r.hasDefinition()) {
        cd.setDefinition(r.getDefinition());
    }
    mergeProps(cd, l, r, destProps, res);
    mergeDesignations(cd, l, r);
    return cd;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)

Example 5 with PropertyComponent

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

the class CodeSystemComparer method getUniqued.

private String getUniqued(String code, List<PropertyComponent> list) {
    int i = 0;
    while (true) {
        boolean ok = true;
        String res = code + (i == 0 ? "" : i);
        for (PropertyComponent t : list) {
            if (res.equals(t.getCode())) {
                ok = false;
            }
        }
        if (ok) {
            return res;
        }
    }
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent) PropertyComponent(org.hl7.fhir.r4b.model.CodeSystem.PropertyComponent)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)10 ConceptPropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent)9 PropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.PropertyComponent)9 ConceptPropertyComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent)9 PropertyComponent (org.hl7.fhir.r5.model.CodeSystem.PropertyComponent)9 ArrayList (java.util.ArrayList)4 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)4 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)4 Date (java.util.Date)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)2 CodeSystem (org.hl7.fhir.r4b.model.CodeSystem)2 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)2 HierarchicalTableGenerator (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator)2 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)2 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)2 TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)2 PropertyComponent (org.hl7.fhir.dstu3.model.CodeSystem.PropertyComponent)1 PublicationStatusEnumFactory (org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)1 ConceptPropertyComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptPropertyComponent)1