Search in sources :

Example 71 with Enumeration

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

the class ProfileUtilities method genTypes.

private Cell genTypes(HierarchicalTableGenerator gen, Row r, ElementDefinition e, String profileBaseFileName, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean mustSupportMode) {
    Cell c = gen.new Cell();
    r.getCells().add(c);
    if (e.hasContentReference()) {
        ElementInStructure ed = getElementByName(profile.getSnapshot().getElement(), e.getContentReference(), profile);
        if (ed == null)
            c.getPieces().add(gen.new Piece(null, translate("sd.table", "Unknown reference to %s", e.getContentReference()), null));
        else {
            if (ed.getSource() == profile) {
                c.getPieces().add(gen.new Piece(null, translate("sd.table", "See ", ed.getElement().getPath()), null));
                c.getPieces().add(gen.new Piece("#" + ed.getElement().getPath(), tail(ed.getElement().getPath()), ed.getElement().getPath()));
            } else {
                c.getPieces().add(gen.new Piece(null, translate("sd.table", "See ", ed.getElement().getPath()), null));
                c.getPieces().add(gen.new Piece(pfx(corePath, ed.getSource().getUserString("path")) + "#" + ed.getElement().getPath(), tail(ed.getElement().getPath()) + " (" + ed.getSource().getType() + ")", ed.getElement().getPath()));
            }
        }
        return c;
    }
    List<TypeRefComponent> types = e.getType();
    if (!e.hasType()) {
        if (root) {
            // we'll use base instead of types then
            StructureDefinition bsd = profile == null ? null : context.fetchResource(StructureDefinition.class, profile.getBaseDefinition());
            if (bsd != null) {
                if (bsd.hasUserData("path")) {
                    c.getPieces().add(gen.new Piece(Utilities.isAbsoluteUrl(bsd.getUserString("path")) ? bsd.getUserString("path") : imagePath + bsd.getUserString("path"), bsd.getName(), null));
                } else {
                    c.getPieces().add(gen.new Piece(null, bsd.getName(), null));
                }
            }
            return c;
        } else if (e.hasContentReference()) {
            return c;
        } else {
            ElementDefinition d = (ElementDefinition) e.getUserData(DERIVATION_POINTER);
            if (d != null && d.hasType()) {
                types = new ArrayList<ElementDefinition.TypeRefComponent>();
                for (TypeRefComponent tr : d.getType()) {
                    TypeRefComponent tt = tr.copy();
                    tt.setUserData(DERIVATION_EQUALS, true);
                    types.add(tt);
                }
            } else {
                return c;
            }
        }
    }
    boolean first = true;
    TypeRefComponent tl = null;
    for (TypeRefComponent t : types) {
        if (!mustSupportMode || allTypesMustSupport(e) || isMustSupport(t)) {
            if (first) {
                first = false;
            } else {
                c.addPiece(checkForNoChange(tl, gen.new Piece(null, ", ", null)));
            }
            tl = t;
            if (t.hasTarget()) {
                c.getPieces().add(gen.new Piece(corePath + "references.html", t.getWorkingCode(), null));
                if (!mustSupportMode && isMustSupportDirect(t) && e.getMustSupport()) {
                    c.addPiece(gen.new Piece(null, " ", null));
                    c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
                }
                c.getPieces().add(gen.new Piece(null, "(", null));
                boolean tfirst = true;
                for (CanonicalType u : t.getTargetProfile()) {
                    if (!mustSupportMode || allProfilesMustSupport(t.getTargetProfile()) || isMustSupport(u)) {
                        if (tfirst)
                            tfirst = false;
                        else
                            c.addPiece(gen.new Piece(null, " | ", null));
                        genTargetLink(gen, profileBaseFileName, corePath, c, t, u.getValue());
                        if (!mustSupportMode && isMustSupport(u) && e.getMustSupport()) {
                            c.addPiece(gen.new Piece(null, " ", null));
                            c.addStyledText(translate("sd.table", "This target must be supported"), "S", "white", "red", null, false);
                        }
                    }
                }
                c.getPieces().add(gen.new Piece(null, ")", null));
                if (t.getAggregation().size() > 0) {
                    c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", " {", null));
                    boolean firstA = true;
                    for (Enumeration<AggregationMode> a : t.getAggregation()) {
                        if (firstA = true)
                            firstA = false;
                        else
                            c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", ", ", null));
                        c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", codeForAggregation(a.getValue()), hintForAggregation(a.getValue())));
                    }
                    c.getPieces().add(gen.new Piece(corePath + "valueset-resource-aggregation-mode.html", "}", null));
                }
            } else if (t.hasProfile() && (!t.getWorkingCode().equals("Extension") || isProfiledType(t.getProfile()))) {
                // a profiled type
                String ref;
                boolean pfirst = true;
                for (CanonicalType p : t.getProfile()) {
                    if (!mustSupportMode || allProfilesMustSupport(t.getProfile()) || isMustSupport(p)) {
                        if (pfirst) {
                            pfirst = false;
                        } else {
                            c.addPiece(checkForNoChange(tl, gen.new Piece(null, ", ", null)));
                        }
                        ref = pkp == null ? null : pkp.getLinkForProfile(profile, p.getValue());
                        if (ref != null) {
                            String[] parts = ref.split("\\|");
                            if (parts[0].startsWith("http:") || parts[0].startsWith("https:")) {
                                // c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], "<" + parts[1] + ">", t.getCode()))); Lloyd
                                c.addPiece(checkForNoChange(t, gen.new Piece(parts[0], parts[1], t.getWorkingCode())));
                            } else {
                                // c.addPiece(checkForNoChange(t, gen.new Piece((t.getProfile().startsWith(corePath)? corePath: "")+parts[0], "<" + parts[1] + ">", t.getCode())));
                                c.addPiece(checkForNoChange(t, gen.new Piece((p.getValue().startsWith(corePath + "StructureDefinition") ? corePath : "") + parts[0], parts[1], t.getWorkingCode())));
                            }
                        } else
                            c.addPiece(checkForNoChange(t, gen.new Piece((p.getValue().startsWith(corePath) ? corePath : "") + ref, t.getWorkingCode(), null)));
                        if (!mustSupportMode && isMustSupport(p) && e.getMustSupport()) {
                            c.addPiece(gen.new Piece(null, " ", null));
                            c.addStyledText(translate("sd.table", "This profile must be supported"), "S", "white", "red", null, false);
                        }
                    }
                }
            } else {
                String tc = t.getWorkingCode();
                if (Utilities.isAbsoluteUrl(tc)) {
                    StructureDefinition sd = context.fetchTypeDefinition(tc);
                    if (sd == null) {
                        c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null)));
                    } else {
                        c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), sd.getType(), null)));
                    }
                } else if (pkp != null && pkp.hasLinkFor(tc)) {
                    c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null)));
                } else {
                    c.addPiece(checkForNoChange(t, gen.new Piece(null, tc, null)));
                }
                if (!mustSupportMode && isMustSupportDirect(t) && e.getMustSupport()) {
                    c.addPiece(gen.new Piece(null, " ", null));
                    c.addStyledText(translate("sd.table", "This type must be supported"), "S", "white", "red", null, false);
                }
            }
        }
    }
    return c;
}
Also used : ArrayList(java.util.ArrayList) AggregationMode(org.hl7.fhir.r4b.model.ElementDefinition.AggregationMode) CanonicalType(org.hl7.fhir.r4b.model.CanonicalType) StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.r4b.model.ElementDefinition.TypeRefComponent) Piece(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece) ElementDefinition(org.hl7.fhir.r4b.model.ElementDefinition) Cell(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)

Example 72 with Enumeration

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

the class ImplementationGuide14_50 method convertImplementationGuide.

public static org.hl7.fhir.dstu2016may.model.ImplementationGuide convertImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.ImplementationGuide tgt = new org.hl7.fhir.dstu2016may.model.ImplementationGuide();
    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt);
    if (src.hasUrlElement())
        tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement()));
    if (src.hasVersion())
        tgt.setVersionElement(String14_50.convertString(src.getVersionElement()));
    if (src.hasNameElement())
        tgt.setNameElement(String14_50.convertString(src.getNameElement()));
    if (src.hasStatus())
        tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement()));
    if (src.hasExperimental())
        tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement()));
    if (src.hasPublisher())
        tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement()));
    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) tgt.addContact(convertImplementationGuideContactComponent(t));
    if (src.hasDate())
        tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement()));
    if (src.hasDescription())
        tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) if (t.hasValueCodeableConcept())
        tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept()));
    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t));
    if (src.hasCopyright())
        tgt.setCopyright(src.getCopyright());
    if (src.hasFhirVersion())
        for (Enumeration<org.hl7.fhir.r5.model.Enumerations.FHIRVersion> v : src.getFhirVersion()) {
            tgt.setFhirVersion(v.asStringValue());
        }
    for (org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDependsOnComponent t : src.getDependsOn()) tgt.addDependency(convertImplementationGuideDependencyComponent(t));
    for (org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionGroupingComponent t : src.getDefinition().getGrouping()) tgt.addPackage(convertImplementationGuidePackageComponent(t));
    for (org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent t : src.getDefinition().getResource()) findPackage(tgt.getPackage(), t.getGroupingId()).addResource(convertImplementationGuidePackageResourceComponent(t));
    for (org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideGlobalComponent t : src.getGlobal()) tgt.addGlobal(convertImplementationGuideGlobalComponent(t));
    tgt.setPage(convertImplementationGuidePageComponent(src.getDefinition().getPage()));
    return tgt;
}
Also used : Enumeration(org.hl7.fhir.r5.model.Enumeration) ImplementationGuide(org.hl7.fhir.dstu2016may.model.ImplementationGuide) ImplementationGuide(org.hl7.fhir.dstu2016may.model.ImplementationGuide)

Example 73 with Enumeration

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

the class ExpansionProfile method setProperty.

@Override
public void setProperty(String name, Base value) throws FHIRException {
    if (name.equals("url"))
        // UriType
        this.url = castToUri(value);
    else if (name.equals("identifier"))
        // Identifier
        this.identifier = castToIdentifier(value);
    else if (name.equals("version"))
        // StringType
        this.version = castToString(value);
    else if (name.equals("name"))
        // StringType
        this.name = castToString(value);
    else if (name.equals("status"))
        // Enumeration<ConformanceResourceStatus>
        this.status = new ConformanceResourceStatusEnumFactory().fromType(value);
    else if (name.equals("experimental"))
        // BooleanType
        this.experimental = castToBoolean(value);
    else if (name.equals("publisher"))
        // StringType
        this.publisher = castToString(value);
    else if (name.equals("contact"))
        this.getContact().add((ExpansionProfileContactComponent) value);
    else if (name.equals("date"))
        // DateTimeType
        this.date = castToDateTime(value);
    else if (name.equals("description"))
        // StringType
        this.description = castToString(value);
    else if (name.equals("codeSystem"))
        // ExpansionProfileCodeSystemComponent
        this.codeSystem = (ExpansionProfileCodeSystemComponent) value;
    else if (name.equals("includeDesignations"))
        // BooleanType
        this.includeDesignations = castToBoolean(value);
    else if (name.equals("designation"))
        // ExpansionProfileDesignationComponent
        this.designation = (ExpansionProfileDesignationComponent) value;
    else if (name.equals("includeDefinition"))
        // BooleanType
        this.includeDefinition = castToBoolean(value);
    else if (name.equals("includeInactive"))
        // BooleanType
        this.includeInactive = castToBoolean(value);
    else if (name.equals("excludeNested"))
        // BooleanType
        this.excludeNested = castToBoolean(value);
    else if (name.equals("excludeNotForUI"))
        // BooleanType
        this.excludeNotForUI = castToBoolean(value);
    else if (name.equals("excludePostCoordinated"))
        // BooleanType
        this.excludePostCoordinated = castToBoolean(value);
    else if (name.equals("displayLanguage"))
        // CodeType
        this.displayLanguage = castToCode(value);
    else if (name.equals("limitedExpansion"))
        // BooleanType
        this.limitedExpansion = castToBoolean(value);
    else
        super.setProperty(name, value);
}
Also used : ConformanceResourceStatusEnumFactory(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory)

Example 74 with Enumeration

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

the class DocumentManifest method setProperty.

@Override
public void setProperty(String name, Base value) throws FHIRException {
    if (name.equals("masterIdentifier"))
        // Identifier
        this.masterIdentifier = castToIdentifier(value);
    else if (name.equals("identifier"))
        this.getIdentifier().add(castToIdentifier(value));
    else if (name.equals("subject"))
        // Reference
        this.subject = castToReference(value);
    else if (name.equals("recipient"))
        this.getRecipient().add(castToReference(value));
    else if (name.equals("type"))
        // CodeableConcept
        this.type = castToCodeableConcept(value);
    else if (name.equals("author"))
        this.getAuthor().add(castToReference(value));
    else if (name.equals("created"))
        // DateTimeType
        this.created = castToDateTime(value);
    else if (name.equals("source"))
        // UriType
        this.source = castToUri(value);
    else if (name.equals("status"))
        // Enumeration<DocumentReferenceStatus>
        this.status = new DocumentReferenceStatusEnumFactory().fromType(value);
    else if (name.equals("description"))
        // StringType
        this.description = castToString(value);
    else if (name.equals("content"))
        this.getContent().add((DocumentManifestContentComponent) value);
    else if (name.equals("related"))
        this.getRelated().add((DocumentManifestRelatedComponent) value);
    else
        super.setProperty(name, value);
}
Also used : DocumentReferenceStatusEnumFactory(org.hl7.fhir.dstu2016may.model.Enumerations.DocumentReferenceStatusEnumFactory)

Example 75 with Enumeration

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

the class EnrollmentResponse method setProperty.

@Override
public void setProperty(String name, Base value) throws FHIRException {
    if (name.equals("identifier"))
        this.getIdentifier().add(castToIdentifier(value));
    else if (name.equals("request"))
        // Reference
        this.request = castToReference(value);
    else if (name.equals("outcome"))
        // Enumeration<RemittanceOutcome>
        this.outcome = new RemittanceOutcomeEnumFactory().fromType(value);
    else if (name.equals("disposition"))
        // StringType
        this.disposition = castToString(value);
    else if (name.equals("ruleset"))
        // Coding
        this.ruleset = castToCoding(value);
    else if (name.equals("originalRuleset"))
        // Coding
        this.originalRuleset = castToCoding(value);
    else if (name.equals("created"))
        // DateTimeType
        this.created = castToDateTime(value);
    else if (name.equals("organization"))
        // Reference
        this.organization = castToReference(value);
    else if (name.equals("requestProvider"))
        // Reference
        this.requestProvider = castToReference(value);
    else if (name.equals("requestOrganization"))
        // Reference
        this.requestOrganization = castToReference(value);
    else
        super.setProperty(name, value);
}
Also used : RemittanceOutcomeEnumFactory(org.hl7.fhir.dstu2016may.model.Enumerations.RemittanceOutcomeEnumFactory)

Aggregations

CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)14 ArrayList (java.util.ArrayList)11 NotImplementedException (org.apache.commons.lang3.NotImplementedException)11 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)10 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 StringType (org.hl7.fhir.r5.model.StringType)7 ConformanceResourceStatusEnumFactory (org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory)6 Enumeration (org.hl7.fhir.dstu3.model.Enumeration)6 Enumeration (org.hl7.fhir.r4.model.Enumeration)6 StringType (org.hl7.fhir.r4b.model.StringType)6 Enumeration (org.hl7.fhir.r5.model.Enumeration)6 UriType (org.hl7.fhir.r5.model.UriType)6 Base64 (org.apache.commons.codec.binary.Base64)5 PublicationStatusEnumFactory (org.hl7.fhir.dstu3.model.Enumerations.PublicationStatusEnumFactory)5 StringType (org.hl7.fhir.dstu3.model.StringType)5 Enumeration (org.hl7.fhir.dstu2.model.Enumeration)4 Reference (org.hl7.fhir.dstu2.model.Reference)4 StringType (org.hl7.fhir.dstu2.model.StringType)4 Patient (org.hl7.fhir.r4.model.Patient)4