Search in sources :

Example 66 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class SpreadSheetReloader method parseStatus.

private void parseStatus(DomainResource ed, String value) {
    ed.getExtension().removeIf(ext -> ext.getUrl().equals(BuildExtensions.EXT_FMM_LEVEL));
    ed.getExtension().removeIf(ext -> ext.getUrl().equals(BuildExtensions.EXT_STANDARDS_STATUS));
    ed.getExtension().removeIf(ext -> ext.getUrl().equals(BuildExtensions.EXT_NORMATIVE_VERSION));
    if (!Utilities.noString(value) && value.contains("/")) {
        String[] p = value.split("\\/");
        if (Utilities.noString(p[0].trim())) {
            ed.getExtension().removeIf(ext -> ext.getUrl().equals(BuildExtensions.EXT_FMM_LEVEL));
        } else {
            ed.addExtension(BuildExtensions.EXT_FMM_LEVEL, new IntegerType(p[0]));
        }
        if (p[1].contains(";")) {
            ed.addExtension(BuildExtensions.EXT_STANDARDS_STATUS, new CodeType(p[1].substring(0, p[1].indexOf(";"))));
            ed.addExtension(BuildExtensions.EXT_NORMATIVE_VERSION, new CodeType(p[1].substring(p[1].indexOf("from=") + 5)));
        } else {
            ed.addExtension(BuildExtensions.EXT_STANDARDS_STATUS, new CodeType(p[1]));
        }
    }
    sortExtensions(ed);
}
Also used : IntegerType(org.hl7.fhir.r5.model.IntegerType) CodeType(org.hl7.fhir.r5.model.CodeType)

Example 67 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class SpreadSheetReloader method parseUml.

private void parseUml(ElementDefinition ed, String value, XSSFSheet bindings) {
    ed.removeExtension(BuildExtensions.EXT_UML_BREAK);
    ed.removeExtension(BuildExtensions.EXT_UML_DIR);
    if (!Utilities.noString(value)) {
        if (value.contains("|")) {
            String[] p = value.split("\\|");
            if (Utilities.noString(p[0].trim())) {
                ed.addExtension(BuildExtensions.EXT_UML_BREAK, new CodeType(p[1].trim()));
            } else {
                ed.addExtension(BuildExtensions.EXT_UML_DIR, new CodeType(p[0].trim()));
                ed.addExtension(BuildExtensions.EXT_UML_BREAK, new CodeType(p[1].trim()));
            }
        } else {
            ed.addExtension(BuildExtensions.EXT_UML_DIR, new CodeType(value));
        }
    }
    sortExtensions(ed);
}
Also used : CodeType(org.hl7.fhir.r5.model.CodeType)

Example 68 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class SpreadSheetReloader method parseType.

private void parseType(ElementDefinition ed, String value, String hierarchy) throws Exception {
    ed.getType().clear();
    ed.setContentReferenceElement(null);
    if (ed.getPath().equals("Resource.id")) {
        ed.addType().setCode("http://hl7.org/fhirpath/System.String").addExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type", new UriType("id"));
    } else {
        if (Utilities.noString(value)) {
            if (ed.getPath().contains(".")) {
                ed.addType().setCode("BackboneElement");
            }
        } else if (value.startsWith("#")) {
            ed.setContentReference(value);
        } else {
            List<TypeRef> tl = new TypeParser(version).parse(value, false, null, context, false);
            for (TypeRef tr : tl) {
                TypeRefComponent t = ed.addType().setCode(tr.getName());
                if ("SimpleQuantity".equals(t.getCode())) {
                    t.setCode("Quantity");
                    t.addProfile("http://hl7.org/fhir/StructureDefinition/SimpleQuantity");
                }
                for (String p : tr.getParams()) {
                    if (p.equals("Definition")) {
                        t.addExtension(BuildExtensions.EXT_PATTERN, new CanonicalType("http://hl7.org/fhir/StructureDefinition/Definition"));
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/ActivityDefinition");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/EventDefinition");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/EvidenceVariable");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/Measure");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/OperationDefinition");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/PlanDefinition");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/Questionnaire");
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/SubscriptionTopic");
                    } else {
                        t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + p);
                    }
                }
                if (Utilities.existsInList(tr.getName(), "canonical", "Reference") && !Utilities.noString(hierarchy)) {
                    t.addExtension(BuildExtensions.EXT_HIERARCHY, new BooleanType(Utilities.existsInList(hierarchy, "true", "True", "TRUE", "1", "y", "Y")));
                }
            }
        }
    }
}
Also used : TypeParser(org.hl7.fhir.definitions.parsers.TypeParser) TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) TypeRef(org.hl7.fhir.definitions.model.TypeRef) BooleanType(org.hl7.fhir.r5.model.BooleanType) List(java.util.List) ArrayList(java.util.ArrayList) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) UriType(org.hl7.fhir.r5.model.UriType)

Example 69 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class SpreadSheetReloader method parseBinding.

private void parseBinding(ElementDefinition ed, String value, XSSFSheet bindings) {
    if (Utilities.noString(value)) {
        ed.setBinding(null);
    } else {
        XSSFRow cols = bindings.getRow(0);
        XSSFRow row = lookupRow(bindings, cols, CN_BINDING_NAME, value);
        if (row == null) {
            throw new FHIRException("Unable to find binding " + value + " in " + xlsx);
        }
        ElementDefinitionBindingComponent bs = ed.getBinding();
        bs.removeExtension(BuildExtensions.EXT_NAME);
        readExt(bs, row, cols, CN_BINDING_NAME, BuildExtensions.EXT_BINDING_NAME, ExtensionType.String);
        readExt(bs, row, cols, CN_DEFINITION, BuildExtensions.EXT_DEFINITION, ExtensionType.String);
        bs.setStrength(BindingStrength.fromCode(getValue(row, cols, CN_STRENGTH)));
        bs.setValueSet(getValue(row, cols, CN_VALUE_SET));
        readExt(bs, row, cols, CN_OID, BuildExtensions.EXT_VS_OID, ExtensionType.String);
        readExt(bs, row, cols, CN_URI, BuildExtensions.EXT_URI, ExtensionType.String);
        readExt(bs, row, cols, CN_WEBSITE_EMAIL, BuildExtensions.EXT_WEBSITE, ExtensionType.Uri);
        readExt(bs, row, cols, CN_V2, BuildExtensions.EXT_V2_MAP, ExtensionType.String);
        readExt(bs, row, cols, CN_V3, BuildExtensions.EXT_V3_MAP, ExtensionType.String);
        readExt(bs, row, cols, CN_COPYRIGHT, BuildExtensions.EXT_COPYRIGHT, ExtensionType.String);
        readExt(bs, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.Markdown);
    }
}
Also used : XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) FHIRException(org.hl7.fhir.exceptions.FHIRException) ElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent)

Example 70 with Value

use of org.hl7.fhir.utilities.graphql.Value in project kindling by HL7.

the class ExtensionDefinitionValidator method checkNoValueAndExtensions.

private void checkNoValueAndExtensions(StructureDefinition sd) throws FHIRException {
    boolean hasValue = false;
    for (ElementDefinition ed : sd.getSnapshot().getElement()) {
        if (ed.getPath().startsWith("Extension.value")) {
            if (!ed.getMax().equals("0")) {
                hasValue = true;
            }
        }
    }
    if (hasValue) {
        for (ElementDefinition ed : sd.getSnapshot().getElement()) {
            if (ed.getPath().equals("Extension.extension")) {
                ed.setMax("0");
            }
            if (ed.getPath().startsWith("Extension.extension.")) {
                throw new FHIRException("The extension " + sd.getUrl() + " has both value and extensions");
            }
        }
        boolean found = false;
        int ip = 0;
        for (ElementDefinition ed : sd.getDifferential().getElement()) {
            if (ed.getPath().equals("Extension.extension")) {
                ed.setMax("0");
                found = true;
            }
            if (ed.getPath().equals("Extension") || ed.getPath().equals("Extension.id"))
                ip++;
        }
        if (!found) {
            ElementDefinition ed = new ElementDefinition();
            ed.setPath("Extension.extension");
            ed.setMax("0");
            sd.getDifferential().getElement().add(ip, ed);
        }
    }
}
Also used : ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Aggregations

Test (org.junit.jupiter.api.Test)222 ArrayList (java.util.ArrayList)183 FHIRException (org.hl7.fhir.exceptions.FHIRException)107 List (java.util.List)97 DisplayName (org.junit.jupiter.api.DisplayName)96 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)89 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)85 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)70 Identifier (org.hl7.fhir.r4.model.Identifier)69 Test (org.junit.Test)66 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)64 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)54 IOException (java.io.IOException)52 Bundle (org.hl7.fhir.r4.model.Bundle)49 Coding (org.hl7.fhir.r4.model.Coding)49 ValueSet (org.hl7.fhir.r5.model.ValueSet)48 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)46 Resource (org.hl7.fhir.r4.model.Resource)46 BigDecimal (java.math.BigDecimal)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)44