Search in sources :

Example 86 with CanonicalType

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

the class ImplementationGuide14_50 method convertImplementationGuidePackageResourceComponent.

public static org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent convertImplementationGuidePackageResourceComponent(org.hl7.fhir.dstu2016may.model.ImplementationGuide.ImplementationGuidePackageResourceComponent src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent tgt = new org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent();
    ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
    if (src.hasExampleFor()) {
        DataType t = ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getExampleFor());
        tgt.setExample(t instanceof org.hl7.fhir.r5.model.Reference ? new CanonicalType(((org.hl7.fhir.r5.model.Reference) t).getReference()) : t);
    } else if (src.hasExample())
        tgt.setExample(new org.hl7.fhir.r5.model.BooleanType(src.getExample()));
    if (src.hasName())
        tgt.setNameElement(String14_50.convertString(src.getNameElement()));
    if (src.hasDescription())
        tgt.setDescriptionElement(String14_50.convertString(src.getDescriptionElement()));
    if (src.hasSourceReference())
        tgt.setReference(Reference14_50.convertReference(src.getSourceReference()));
    else if (src.hasSourceUriType())
        tgt.setReference(new org.hl7.fhir.r5.model.Reference(src.getSourceUriType().getValue()));
    return tgt;
}
Also used : ImplementationGuide(org.hl7.fhir.dstu2016may.model.ImplementationGuide) CanonicalType(org.hl7.fhir.r5.model.CanonicalType) DataType(org.hl7.fhir.r5.model.DataType)

Example 87 with CanonicalType

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

the class JsonParser method composeType.

protected void composeType(String prefix, DataType type) throws IOException {
    if (type == null) {
        ;
    } else if (type instanceof Address) {
        composeAddress(prefix + "Address", (Address) type);
    } else if (type instanceof Age) {
        composeAge(prefix + "Age", (Age) type);
    } else if (type instanceof Annotation) {
        composeAnnotation(prefix + "Annotation", (Annotation) type);
    } else if (type instanceof Attachment) {
        composeAttachment(prefix + "Attachment", (Attachment) type);
    } else if (type instanceof CodeableConcept) {
        composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
    } else if (type instanceof CodeableReference) {
        composeCodeableReference(prefix + "CodeableReference", (CodeableReference) type);
    } else if (type instanceof Coding) {
        composeCoding(prefix + "Coding", (Coding) type);
    } else if (type instanceof ContactDetail) {
        composeContactDetail(prefix + "ContactDetail", (ContactDetail) type);
    } else if (type instanceof ContactPoint) {
        composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
    } else if (type instanceof Contributor) {
        composeContributor(prefix + "Contributor", (Contributor) type);
    } else if (type instanceof Count) {
        composeCount(prefix + "Count", (Count) type);
    } else if (type instanceof DataRequirement) {
        composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
    } else if (type instanceof Distance) {
        composeDistance(prefix + "Distance", (Distance) type);
    } else if (type instanceof Dosage) {
        composeDosage(prefix + "Dosage", (Dosage) type);
    } else if (type instanceof Duration) {
        composeDuration(prefix + "Duration", (Duration) type);
    } else if (type instanceof ElementDefinition) {
        composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
    } else if (type instanceof Expression) {
        composeExpression(prefix + "Expression", (Expression) type);
    } else if (type instanceof Extension) {
        composeExtension(prefix + "Extension", (Extension) type);
    } else if (type instanceof HumanName) {
        composeHumanName(prefix + "HumanName", (HumanName) type);
    } else if (type instanceof Identifier) {
        composeIdentifier(prefix + "Identifier", (Identifier) type);
    } else if (type instanceof MarketingStatus) {
        composeMarketingStatus(prefix + "MarketingStatus", (MarketingStatus) type);
    } else if (type instanceof Meta) {
        composeMeta(prefix + "Meta", (Meta) type);
    } else if (type instanceof Money) {
        composeMoney(prefix + "Money", (Money) type);
    } else if (type instanceof Narrative) {
        composeNarrative(prefix + "Narrative", (Narrative) type);
    } else if (type instanceof ParameterDefinition) {
        composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
    } else if (type instanceof Period) {
        composePeriod(prefix + "Period", (Period) type);
    } else if (type instanceof Population) {
        composePopulation(prefix + "Population", (Population) type);
    } else if (type instanceof ProdCharacteristic) {
        composeProdCharacteristic(prefix + "ProdCharacteristic", (ProdCharacteristic) type);
    } else if (type instanceof ProductShelfLife) {
        composeProductShelfLife(prefix + "ProductShelfLife", (ProductShelfLife) type);
    } else if (type instanceof Quantity) {
        composeQuantity(prefix + "Quantity", (Quantity) type);
    } else if (type instanceof Range) {
        composeRange(prefix + "Range", (Range) type);
    } else if (type instanceof Ratio) {
        composeRatio(prefix + "Ratio", (Ratio) type);
    } else if (type instanceof RatioRange) {
        composeRatioRange(prefix + "RatioRange", (RatioRange) type);
    } else if (type instanceof Reference) {
        composeReference(prefix + "Reference", (Reference) type);
    } else if (type instanceof RelatedArtifact) {
        composeRelatedArtifact(prefix + "RelatedArtifact", (RelatedArtifact) type);
    } else if (type instanceof SampledData) {
        composeSampledData(prefix + "SampledData", (SampledData) type);
    } else if (type instanceof Signature) {
        composeSignature(prefix + "Signature", (Signature) type);
    } else if (type instanceof Timing) {
        composeTiming(prefix + "Timing", (Timing) type);
    } else if (type instanceof TriggerDefinition) {
        composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
    } else if (type instanceof UsageContext) {
        composeUsageContext(prefix + "UsageContext", (UsageContext) type);
    } else if (type instanceof CodeType) {
        composeCodeCore(prefix + "Code", (CodeType) type, false);
        composeCodeExtras(prefix + "Code", (CodeType) type, false);
    } else if (type instanceof OidType) {
        composeOidCore(prefix + "Oid", (OidType) type, false);
        composeOidExtras(prefix + "Oid", (OidType) type, false);
    } else if (type instanceof CanonicalType) {
        composeCanonicalCore(prefix + "Canonical", (CanonicalType) type, false);
        composeCanonicalExtras(prefix + "Canonical", (CanonicalType) type, false);
    } else if (type instanceof UuidType) {
        composeUuidCore(prefix + "Uuid", (UuidType) type, false);
        composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
    } else if (type instanceof UrlType) {
        composeUrlCore(prefix + "Url", (UrlType) type, false);
        composeUrlExtras(prefix + "Url", (UrlType) type, false);
    } else if (type instanceof UnsignedIntType) {
        composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
        composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
    } else if (type instanceof MarkdownType) {
        composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
        composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
    } else if (type instanceof IdType) {
        composeIdCore(prefix + "Id", (IdType) type, false);
        composeIdExtras(prefix + "Id", (IdType) type, false);
    } else if (type instanceof PositiveIntType) {
        composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
        composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
    } else if (type instanceof DateType) {
        composeDateCore(prefix + "Date", (DateType) type, false);
        composeDateExtras(prefix + "Date", (DateType) type, false);
    } else if (type instanceof DateTimeType) {
        composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
        composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
    } else if (type instanceof StringType) {
        composeStringCore(prefix + "String", (StringType) type, false);
        composeStringExtras(prefix + "String", (StringType) type, false);
    } else if (type instanceof IntegerType) {
        composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
        composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
    } else if (type instanceof Integer64Type) {
        composeInteger64Core(prefix + "Integer64", (Integer64Type) type, false);
        composeInteger64Extras(prefix + "Integer64", (Integer64Type) type, false);
    } else if (type instanceof UriType) {
        composeUriCore(prefix + "Uri", (UriType) type, false);
        composeUriExtras(prefix + "Uri", (UriType) type, false);
    } else if (type instanceof InstantType) {
        composeInstantCore(prefix + "Instant", (InstantType) type, false);
        composeInstantExtras(prefix + "Instant", (InstantType) type, false);
    } else if (type instanceof BooleanType) {
        composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
        composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
    } else if (type instanceof Base64BinaryType) {
        composeBase64BinaryCore(prefix + "Base64Binary", (Base64BinaryType) type, false);
        composeBase64BinaryExtras(prefix + "Base64Binary", (Base64BinaryType) type, false);
    } else if (type instanceof TimeType) {
        composeTimeCore(prefix + "Time", (TimeType) type, false);
        composeTimeExtras(prefix + "Time", (TimeType) type, false);
    } else if (type instanceof DecimalType) {
        composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
        composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
    } else
        throw new Error("Unhandled type");
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 88 with CanonicalType

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

the class StructureDefinitionSpreadsheetGenerator method canonicalList.

private String canonicalList(List<CanonicalType> list) {
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder("|");
    for (CanonicalType c : list) {
        String v = c.getValue();
        if (v.startsWith("http://hl7.org/fhir/StructureDefinition/"))
            v = v.substring(40);
        b.append(v);
    }
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CanonicalType(org.hl7.fhir.r5.model.CanonicalType)

Example 89 with CanonicalType

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

the class ConceptMap10_50 method convertConceptMap.

public static org.hl7.fhir.r5.model.ConceptMap convertConceptMap(org.hl7.fhir.dstu2.model.ConceptMap src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r5.model.ConceptMap tgt = new org.hl7.fhir.r5.model.ConceptMap();
    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
    if (src.hasUrlElement())
        tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
    if (src.hasIdentifier())
        tgt.addIdentifier(Identifier10_50.convertIdentifier(src.getIdentifier()));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_50.convertString(src.getVersionElement()));
    if (src.hasNameElement())
        tgt.setNameElement(String10_50.convertString(src.getNameElement()));
    if (src.hasStatus())
        tgt.setStatusElement(Enumerations10_50.convertConformanceResourceStatus(src.getStatusElement()));
    if (src.hasExperimental())
        tgt.setExperimentalElement(Boolean10_50.convertBoolean(src.getExperimentalElement()));
    if (src.hasPublisherElement())
        tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement()));
    for (org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent t : src.getContact()) tgt.addContact(convertConceptMapContactComponent(t));
    if (src.hasDate())
        tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement()));
    if (src.hasDescription())
        tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) if (VersionConvertor_10_50.isJurisdiction(t))
        tgt.addJurisdiction(CodeableConcept10_50.convertCodeableConcept(t));
    else
        tgt.addUseContext(CodeableConcept10_50.convertCodeableConceptToUsageContext(t));
    if (src.hasRequirements())
        tgt.setPurpose(src.getRequirements());
    if (src.hasCopyright())
        tgt.setCopyright(src.getCopyright());
    org.hl7.fhir.r5.model.DataType r = ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getSource());
    tgt.setSource(r instanceof org.hl7.fhir.r5.model.Reference ? new CanonicalType(((org.hl7.fhir.r5.model.Reference) r).getReference()) : r);
    r = ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getTarget());
    tgt.setTarget(r instanceof org.hl7.fhir.r5.model.Reference ? new CanonicalType(((org.hl7.fhir.r5.model.Reference) r).getReference()) : r);
    for (org.hl7.fhir.dstu2.model.ConceptMap.SourceElementComponent t : src.getElement()) {
        List<SourceElementComponentWrapper<ConceptMap.SourceElementComponent>> ws = convertSourceElementComponent(t);
        for (SourceElementComponentWrapper<ConceptMap.SourceElementComponent> w : ws) getGroup(tgt, w.getSource(), w.getTarget()).addElement(w.getComp());
    }
    return tgt;
}
Also used : CanonicalType(org.hl7.fhir.r5.model.CanonicalType) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) SourceElementComponentWrapper(org.hl7.fhir.convertors.SourceElementComponentWrapper)

Example 90 with CanonicalType

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

the class JavaResourceGenerator method getTypeClassList.

private String getTypeClassList(ElementDefinition e, String tn, StructureDefinition structure) throws Exception {
    if (e.hasContentReference()) {
        ElementDefinition er = getElementForPath(structure, e.getContentReference().substring(1));
        String s = er.getUserString("java.type");
        return s + ".class";
    }
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    for (TypeRefComponent tr : e.getType()) {
        if (!Utilities.existsInList(tr.getCode(), "Element", "BackboneElement")) {
            if (tr.isResourceReference()) {
                for (CanonicalType p : tr.getTargetProfile()) {
                    String s = p.getValue().substring(40);
                    if (s.equalsIgnoreCase("Resource")) {
                        b.append("Reference.class");
                    } else {
                        if (s.equals("List")) {
                            b.append(s + "Resource.class");
                        // else if (definitions.hasLogicalModel(p)) {
                        // for (String s : definitions.getLogicalModel(p).getImplementations())
                        // b.append(s+".class");
                        } else
                            b.append(s + ".class");
                    }
                }
            } else if (definitions.hasPrimitiveType(tr.getWorkingCode())) {
                b.append(upFirst(tr.getWorkingCode()) + "Type.class");
            // } else if (tr.getName().startsWith("@")){
            // b.append(tn+".class");
            } else if (!tr.getName().equalsIgnoreCase("*") && !tr.getName().equalsIgnoreCase("xhtml")) {
                b.append(getTypename(tr) + ".class");
            }
        }
    }
    return b.toString();
}
Also used : TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) CanonicalType(org.hl7.fhir.r5.model.CanonicalType)

Aggregations

CanonicalType (org.hl7.fhir.r4.model.CanonicalType)45 CanonicalType (org.hl7.fhir.r5.model.CanonicalType)37 ArrayList (java.util.ArrayList)27 CanonicalType (org.hl7.fhir.r4b.model.CanonicalType)19 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)14 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)12 Test (org.junit.jupiter.api.Test)12 List (java.util.List)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)9 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 Extension (org.hl7.fhir.r4.model.Extension)7 Library (org.hl7.fhir.r4.model.Library)7 StringType (org.hl7.fhir.r4.model.StringType)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)5 Bundle (org.hl7.fhir.r4.model.Bundle)5 IdType (org.hl7.fhir.r4.model.IdType)5