Search in sources :

Example 1 with UsageContext

use of org.hl7.fhir.r4.model.UsageContext in project kindling by HL7.

the class PageProcessor method ucHeader.

private String ucHeader(String mode) {
    StringBuilder b = new StringBuilder();
    b.append("<ul class=\"nav nav-tabs\">");
    b.append(makeHeaderTab("UsageContext", "usagecontext.html", mode == null || "base".equals(mode)));
    b.append(makeHeaderTab("Examples", "usagecontext-examples.html", mode == null || "examples".equals(mode)));
    b.append(makeHeaderTab("Detailed Descriptions", "usagecontext-definitions.html", mode == null || "definitions".equals(mode)));
    b.append(makeHeaderTab("Mappings", "usagecontext-mappings.html", mode == null || "mappings".equals(mode)));
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 2 with UsageContext

use of org.hl7.fhir.r4.model.UsageContext in project kindling by HL7.

the class OldSpreadsheetParser method readBindings.

// Adds bindings to global definition.bindings. Returns list of
// newly found bindings in the sheet.
private void readBindings(Sheet sheet) throws Exception {
    for (int row = 0; row < sheet.rows.size(); row++) {
        String bindingName = sheet.getColumn(row, "Binding Name");
    }
    ValueSetGenerator vsGen = new ValueSetGenerator(definitions, version.toCode(), genDate, context.translator(), packageInfo);
    for (int row = 0; row < sheet.rows.size(); row++) {
        String bindingName = sheet.getColumn(row, "Binding Name");
        // Ignore bindings whose name start with "!"
        if (Utilities.noString(bindingName) || bindingName.startsWith("!"))
            continue;
        // if (Character.isLowerCase(bindingName.charAt(0)))
        // throw new Exception("binding name "+bindingName+" is illegal - must start with a capital letter");
        BindingSpecification cd = new BindingSpecification(usageContext, bindingName, false);
        if (definitions != null)
            definitions.getAllBindings().add(cd);
        cd.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Definition")));
        cd.setBindingMethod(BindingsParser.readBinding(sheet.getColumn(row, "Binding"), cd.getName() + " in " + folder));
        String ref = sheet.getColumn(row, "Reference");
        if (!cd.getBinding().equals(BindingMethod.Unbound) && Utilities.noString(ref))
            throw new Exception("binding " + cd.getName() + " is missing a reference");
        if (cd.getBinding() == BindingMethod.CodeList) {
            if (ref.startsWith("#valueset-"))
                throw new Exception("don't start code list references with #valueset-");
            cd.setValueSet(ValueSetUtilities.makeShareable(new ValueSet()));
            valuesets.add(cd.getValueSet());
            cd.getValueSet().setVersion(version.toCode());
            cd.getValueSet().setId(igSuffix(ig) + ref.substring(1));
            cd.getValueSet().setUrl("http://hl7.org/fhir/ValueSet/" + igSuffix(ig) + ref.substring(1));
            cd.getValueSet().setUserData("filename", "valueset-" + cd.getValueSet().getId());
            if (!cd.getValueSet().hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
                cd.getValueSet().addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType(committee.getCode()));
            } else {
                String ec = ToolingExtensions.readStringExtension(cd.getValueSet(), ToolingExtensions.EXT_WORKGROUP);
                if (!ec.equals(committee))
                    System.out.println("ValueSet " + cd.getValueSet().getUrl() + " WG mismatch 3: is " + ec + ", want to set to " + committee.getCode());
            }
            if (ig != null) {
                cd.getValueSet().setUserDataINN(ToolResourceUtilities.NAME_RES_IG, ig);
                cd.getValueSet().setUserData("path", "valueset-" + cd.getValueSet().getId() + ".html");
            } else
                cd.getValueSet().setUserData("path", "valueset-" + cd.getValueSet().getId() + ".html");
            if (!cd.getValueSet().getUserData("path").equals(cd.getValueSet().getUserData("filename") + ".html"))
                throw new Exception("Mis-identified value set");
            if (!ref.startsWith("#"))
                throw new Exception("Error parsing binding " + cd.getName() + ": code list reference '" + ref + "' must started with '#'");
            Sheet cs = xls.getSheets().get(ref.substring(1));
            if (cs == null)
                throw new Exception("Error parsing binding " + cd.getName() + ": code list reference '" + ref + "' not resolved");
            vsGen.updateHeader(cd, cd.getValueSet());
            new CodeListToValueSetParser(cs, ref.substring(1), cd.getValueSet(), version.toCode(), codeSystems, maps, packageInfo).execute(sheet.getColumn(row, "v2"), checkV3Mapping(sheet.getColumn(row, "v3")), getIsUtg(bindingName));
        } else if (cd.getBinding() == BindingMethod.ValueSet) {
            if (ref.startsWith("http:"))
                // will sort this out later
                cd.setReference(sheet.getColumn(row, "Reference"));
            else
                cd.setValueSet(loadValueSet(ref));
        } else if (cd.getBinding() == BindingMethod.Special) {
            if ("#operation-outcome".equals(sheet.getColumn(row, "Reference")))
                new ValueSetGenerator(definitions, version.toCode(), genDate, context.translator(), packageInfo).loadOperationOutcomeValueSet(cd);
            else
                throw new Exception("Special bindings are only allowed in bindings.xml");
        }
        // do this anyway in the short term
        cd.setReference(sheet.getColumn(row, "Reference"));
        if (cd.getValueSet() != null) {
            ValueSet vs = cd.getValueSet();
            ValueSetUtilities.makeShareable(vs);
            vs.setUserData("filename", "valueset-" + vs.getId());
            if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
                vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType(committee.getCode()));
            } else {
                String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
                if (!ec.equals(committee.getCode()))
                    System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 4: is " + ec + ", want to set to " + committee.getCode());
            }
            if (ig != null) {
                vs.setUserDataINN(ToolResourceUtilities.NAME_RES_IG, ig);
                vs.setUserData("path", ig.getCode() + "/valueset-" + vs.getId() + ".html");
            } else
                vs.setUserData("path", "valueset-" + vs.getId() + ".html");
            if (!ValueSetUtilities.hasOID(vs))
                ValueSetUtilities.setOID(vs, "urn:oid:" + BindingSpecification.DEFAULT_OID_VS + registry.idForUri(vs.getUrl()));
            if (vs.getUserData("cs") != null) {
                if (!CodeSystemUtilities.hasOID((CodeSystem) vs.getUserData("cs")))
                    CodeSystemUtilities.setOID((CodeSystem) vs.getUserData("cs"), "urn:oid:" + BindingSpecification.DEFAULT_OID_CS + registry.idForUri(((CodeSystem) vs.getUserData("cs")).getUrl()));
            }
            if (definitions != null)
                definitions.getBoundValueSets().put(vs.getUrl(), vs);
            else
                ig.getValueSets().add(vs);
        } else if (cd.getReference() != null && cd.getReference().startsWith("http:")) {
            if (definitions != null)
                definitions.getUnresolvedBindings().add(cd);
            else
                ig.getUnresolvedBindings().add(cd);
        }
        cd.setDescription(sheet.getColumn(row, "Description"));
        if (!Utilities.noString(sheet.getColumn(row, "Example")))
            throw new Exception("The 'Example' column is no longer supported");
        if (!Utilities.noString(sheet.getColumn(row, "Extensible")))
            throw new Exception("The 'Extensible' column is no longer supported");
        cd.setStrength(BindingsParser.readBindingStrength(sheet.getColumn(row, "Conformance")));
        if (cd.getBinding() == BindingMethod.Unbound) {
            cd.setStrength(BindingStrength.EXAMPLE);
        }
        cd.setSource(name);
        cd.setUri(sheet.getColumn(row, "Uri"));
        String oid = sheet.getColumn(row, "Oid");
        if (!Utilities.noString(oid))
            // no cs oid in this case
            cd.setVsOid(oid);
        cd.setStatus(PublicationStatus.fromCode(sheet.getColumn(row, "Status")));
        cd.setWebSite(sheet.getColumn(row, "Website"));
        cd.setEmail(sheet.getColumn(row, "Email"));
        cd.setCopyright(sheet.getColumn(row, "Copyright"));
        cd.setV2Map(sheet.getColumn(row, "v2"));
        cd.setV3Map(checkV3Mapping(sheet.getColumn(row, "v3")));
        String max = sheet.getColumn(row, "Max");
        if (!Utilities.noString(max))
            if (max.startsWith("http:")) {
                // will sort this out later
                cd.setMaxReference(max);
            } else
                cd.setMaxValueSet(loadValueSet(max));
        bindings.put(cd.getName(), cd);
        if (cd.getValueSet() != null) {
            ValueSet vs = cd.getValueSet();
            vsGen.updateHeader(cd, cd.getValueSet());
        }
    }
}
Also used : CodeListToValueSetParser(org.hl7.fhir.definitions.parsers.CodeListToValueSetParser) BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) CodeType(org.hl7.fhir.r5.model.CodeType) ValueSet(org.hl7.fhir.r5.model.ValueSet) Sheet(org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ValueSetGenerator(org.hl7.fhir.definitions.parsers.ValueSetGenerator) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 3 with UsageContext

use of org.hl7.fhir.r4.model.UsageContext in project kindling by HL7.

the class CodeSystemConvertor method populate.

public static void populate(CodeSystem cs, ValueSet vs) {
    if (!vs.hasName())
        throw new Error("No name vs " + vs.getUrl());
    if (!vs.hasDescription())
        throw new Error("No description vs " + vs.getUrl());
    if (cs.getUserData("conv-vs") != null)
        throw new Error("This code system has already been converted");
    cs.setUserData("conv-vs", "done");
    vs.setUserData("cs", cs);
    if (vs.hasUserData("filename"))
        cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
    if (vs.hasUserData("path"))
        cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
    if (vs.hasUserData("committee"))
        cs.setUserData("committee", vs.getUserData("committee"));
    cs.setId(vs.getId());
    cs.setVersion(vs.getVersion());
    cs.setName(vs.getName());
    cs.setTitle(vs.getTitle());
    cs.setStatus(vs.getStatus());
    cs.setExperimentalElement(vs.getExperimentalElement());
    cs.setPublisher(vs.getPublisher());
    for (ContactDetail csrc : vs.getContact()) {
        ContactDetail ctgt = cs.addContact();
        ctgt.setName(csrc.getName());
        for (ContactPoint cc : csrc.getTelecom()) ctgt.addTelecom(cc);
    }
    cs.setDate(vs.getDate());
    cs.setDescription(vs.getDescription());
    cs.getDescriptionElement().getExtension().addAll(vs.getDescriptionElement().getExtension());
    for (UsageContext cc : vs.getUseContext()) cs.addUseContext(cc);
    cs.setPurpose(vs.getPurpose());
    cs.setCopyright(vs.getCopyright());
    if (vs.hasCompose() && vs.getCompose().getInclude().size() == 1 && vs.getCompose().getExclude().size() == 0 && vs.getCompose().getInclude().get(0).getSystem().equals(cs.getUrl()) && !vs.getCompose().getInclude().get(0).hasValueSet() && !vs.getCompose().getInclude().get(0).hasConcept() && !vs.getCompose().getInclude().get(0).hasFilter())
        cs.setValueSet(vs.getUrl());
    vs.setImmutable(true);
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) UsageContext(org.hl7.fhir.r5.model.UsageContext)

Example 4 with UsageContext

use of org.hl7.fhir.r4.model.UsageContext in project org.hl7.fhir.core by hapifhir.

the class Questionnaire14_40 method convertQuestionnaire.

public static org.hl7.fhir.dstu2016may.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.Questionnaire tgt = new org.hl7.fhir.dstu2016may.model.Questionnaire();
    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt);
    if (src.hasUrl())
        tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement()));
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier14_40.convertIdentifier(t));
    if (src.hasVersion())
        tgt.setVersionElement(String14_40.convertString(src.getVersionElement()));
    if (src.hasStatus())
        tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
    if (src.hasDate())
        tgt.setDateElement(DateTime14_40.convertDateTime(src.getDateElement()));
    if (src.hasPublisher())
        tgt.setPublisherElement(String14_40.convertString(src.getPublisherElement()));
    for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(ContactPoint14_40.convertContactPoint(t1));
    for (UsageContext t : src.getUseContext()) tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t.getValueCodeableConcept()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t));
    if (src.hasTitle())
        tgt.setTitleElement(String14_40.convertString(src.getTitleElement()));
    for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(Coding14_40.convertCoding(t));
    for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
}
Also used : ContactDetail(org.hl7.fhir.r4.model.ContactDetail) UsageContext(org.hl7.fhir.r4.model.UsageContext)

Example 5 with UsageContext

use of org.hl7.fhir.r4.model.UsageContext in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeUsageContext.

protected void composeUsageContext(Complex parent, String parentType, String name, UsageContext element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "UsageContext", name, element, index);
    if (element.hasCode())
        composeCoding(t, "UsageContext", "code", element.getCode(), -1);
    if (element.hasValue())
        composeType(t, "UsageContext", "value", element.getValue(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)3 UsageContext (org.hl7.fhir.r4.model.UsageContext)3 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)3 UsageContext (org.hl7.fhir.r5.model.UsageContext)3 ContactDetail (org.hl7.fhir.dstu3.model.ContactDetail)2 UsageContext (org.hl7.fhir.dstu3.model.UsageContext)2 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)2 CodeType (org.hl7.fhir.r5.model.CodeType)2 CodeableConcept (org.hl7.fhir.r5.model.CodeableConcept)2 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)2 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)1 CodeListToValueSetParser (org.hl7.fhir.definitions.parsers.CodeListToValueSetParser)1 ValueSetGenerator (org.hl7.fhir.definitions.parsers.ValueSetGenerator)1 Address (org.hl7.fhir.dstu3.model.Address)1 Annotation (org.hl7.fhir.dstu3.model.Annotation)1 Attachment (org.hl7.fhir.dstu3.model.Attachment)1 Base (org.hl7.fhir.dstu3.model.Base)1 BooleanType (org.hl7.fhir.dstu3.model.BooleanType)1 CodeType (org.hl7.fhir.dstu3.model.CodeType)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1