diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b06c6ab5..7459b628d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,5 @@ ## Other code changes -* no changes \ No newline at end of file +* no changes + diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/ActivityDefinition40_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/ActivityDefinition40_50.java index 7d046c543..0ecc71ced 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/ActivityDefinition40_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv40_50/resources40_50/ActivityDefinition40_50.java @@ -1,5 +1,6 @@ package org.hl7.fhir.convertors.conv40_50.resources40_50; +import org.hl7.fhir.convertors.VersionConvertorConstants; import org.hl7.fhir.convertors.context.ConversionContext40_50; import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; @@ -19,6 +20,7 @@ import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50; import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Dosage40_50; import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.model.CodeType; import org.hl7.fhir.r5.model.CodeableReference; /* @@ -295,9 +297,10 @@ public class ActivityDefinition40_50 { case SUPPLYREQUEST: tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.SUPPLYREQUEST); break; -// case TASK: -// tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.TASK); -// break; + case TASK: + tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.NULL); + tgt.addExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME, new CodeType("Task")); + break; case VISIONPRESCRIPTION: tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.VISIONPRESCRIPTION); break; @@ -312,8 +315,11 @@ public class ActivityDefinition40_50 { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4.model.Enumeration tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKindEnumFactory()); - ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); - switch (src.getValue()) { + ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME); + if (src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { + tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)); + } else { + switch (src.getValue()) { case APPOINTMENT: tgt.setValue(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.APPOINTMENT); break; @@ -353,15 +359,13 @@ public class ActivityDefinition40_50 { case SUPPLYREQUEST: tgt.setValue(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.SUPPLYREQUEST); break; -// case TASK: -// tgt.setValue(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.TASK); -// break; case VISIONPRESCRIPTION: tgt.setValue(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.VISIONPRESCRIPTION); break; default: tgt.setValue(org.hl7.fhir.r4.model.ActivityDefinition.ActivityDefinitionKind.NULL); break; + } } return tgt; } diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/ActivityDefinition43_50.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/ActivityDefinition43_50.java index bcf5e6d98..3a9b39bba 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/ActivityDefinition43_50.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/conv43_50/resources43_50/ActivityDefinition43_50.java @@ -1,5 +1,6 @@ package org.hl7.fhir.convertors.conv43_50.resources43_50; +import org.hl7.fhir.convertors.VersionConvertorConstants; import org.hl7.fhir.convertors.context.ConversionContext43_50; import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; @@ -19,6 +20,7 @@ import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50; import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Dosage43_50; import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.model.CodeType; import org.hl7.fhir.r5.model.CodeableReference; /* @@ -295,9 +297,10 @@ public class ActivityDefinition43_50 { case SUPPLYREQUEST: tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.SUPPLYREQUEST); break; -// case TASK: -// tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.); -// break; + case TASK: + tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.NULL); + tgt.addExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME, new CodeType("Task")); + break; case VISIONPRESCRIPTION: tgt.setValue(org.hl7.fhir.r5.model.ActivityDefinition.RequestResourceTypes.VISIONPRESCRIPTION); break; @@ -312,8 +315,11 @@ public class ActivityDefinition43_50 { if (src == null || src.isEmpty()) return null; org.hl7.fhir.r4b.model.Enumeration tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.ActivityDefinition.RequestResourceTypeEnumFactory()); - ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); - switch (src.getValue()) { + ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt, VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME); + if (src.hasExtension(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)) { + tgt.setValueAsString(src.getExtensionString(VersionConvertorConstants.EXT_ACTUAL_RESOURCE_NAME)); + } else { + switch (src.getValue()) { case APPOINTMENT: tgt.setValue(org.hl7.fhir.r4b.model.ActivityDefinition.RequestResourceType.APPOINTMENT); break; @@ -353,15 +359,13 @@ public class ActivityDefinition43_50 { case SUPPLYREQUEST: tgt.setValue(org.hl7.fhir.r4b.model.ActivityDefinition.RequestResourceType.SUPPLYREQUEST); break; -// case TASK: -// tgt.setValue(org.hl7.fhir.r4b.model.ActivityDefinition.RequestResourceType.TASK); -// break; case VISIONPRESCRIPTION: tgt.setValue(org.hl7.fhir.r4b.model.ActivityDefinition.RequestResourceType.VISIONPRESCRIPTION); break; default: tgt.setValue(org.hl7.fhir.r4b.model.ActivityDefinition.RequestResourceType.NULL); break; + } } return tgt; } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base.java index 13f3c447a..fcdfc547a 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/Base.java @@ -319,6 +319,9 @@ private Map userData; // -- converters for property setters public Type castToType(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Type) return (Type) b; else if (b.isMetadataBased()) @@ -329,6 +332,9 @@ private Map userData; public BooleanType castToBoolean(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof BooleanType) return (BooleanType) b; else @@ -336,6 +342,9 @@ private Map userData; } public IntegerType castToInteger(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof IntegerType) return (IntegerType) b; else @@ -343,6 +352,9 @@ private Map userData; } public DecimalType castToDecimal(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DecimalType) return (DecimalType) b; else if (b.hasPrimitiveValue()) @@ -352,6 +364,9 @@ private Map userData; } public Base64BinaryType castToBase64Binary(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Base64BinaryType) return (Base64BinaryType) b; else @@ -359,6 +374,9 @@ private Map userData; } public InstantType castToInstant(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof InstantType) return (InstantType) b; else @@ -366,6 +384,9 @@ private Map userData; } public StringType castToString(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof StringType) return (StringType) b; else if (b.hasPrimitiveValue()) @@ -375,6 +396,9 @@ private Map userData; } public UriType castToUri(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof UriType) return (UriType) b; else if (b.hasPrimitiveValue()) @@ -384,6 +408,9 @@ private Map userData; } public UrlType castToUrl(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof UrlType) return (UrlType) b; else if (b.hasPrimitiveValue()) @@ -393,6 +420,9 @@ private Map userData; } public CanonicalType castToCanonical(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof CanonicalType) return (CanonicalType) b; else if (b.hasPrimitiveValue()) @@ -402,6 +432,9 @@ private Map userData; } public DateType castToDate(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DateType) return (DateType) b; else if (b.hasPrimitiveValue()) @@ -411,6 +444,9 @@ private Map userData; } public DateTimeType castToDateTime(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DateTimeType) return (DateTimeType) b; else if (b.fhirType().equals("dateTime")) @@ -420,6 +456,9 @@ private Map userData; } public TimeType castToTime(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof TimeType) return (TimeType) b; else @@ -427,6 +466,9 @@ private Map userData; } public CodeType castToCode(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof CodeType) return (CodeType) b; else if (b.isPrimitive()) @@ -436,6 +478,9 @@ private Map userData; } public OidType castToOid(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof OidType) return (OidType) b; else @@ -443,6 +488,9 @@ private Map userData; } public IdType castToId(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof IdType) return (IdType) b; else @@ -450,6 +498,9 @@ private Map userData; } public UnsignedIntType castToUnsignedInt(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof UnsignedIntType) return (UnsignedIntType) b; else @@ -457,6 +508,9 @@ private Map userData; } public PositiveIntType castToPositiveInt(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof PositiveIntType) return (PositiveIntType) b; else @@ -464,6 +518,9 @@ private Map userData; } public MarkdownType castToMarkdown(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof MarkdownType) return (MarkdownType) b; else if (b.hasPrimitiveValue()) @@ -473,6 +530,9 @@ private Map userData; } public Annotation castToAnnotation(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Annotation) return (Annotation) b; else @@ -480,13 +540,20 @@ private Map userData; } public Dosage castToDosage(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Dosage) return (Dosage) b; - else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); + else + throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); } public Attachment castToAttachment(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Attachment) return (Attachment) b; else @@ -494,6 +561,9 @@ private Map userData; } public Identifier castToIdentifier(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Identifier) return (Identifier) b; else @@ -501,6 +571,9 @@ private Map userData; } public CodeableConcept castToCodeableConcept(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof CodeableConcept) return (CodeableConcept) b; else if (b instanceof Element) { @@ -514,6 +587,9 @@ private Map userData; } public Population castToPopulation(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Population) return (Population) b; else @@ -522,6 +598,9 @@ private Map userData; public Coding castToCoding(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Coding) return (Coding) b; else if (b instanceof Element) { @@ -537,6 +616,9 @@ private Map userData; } public Quantity castToQuantity(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Quantity) return (Quantity) b; else @@ -544,6 +626,9 @@ private Map userData; } public Money castToMoney(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Money) return (Money) b; else @@ -551,6 +636,9 @@ private Map userData; } public Duration castToDuration(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Duration) return (Duration) b; else @@ -558,6 +646,9 @@ private Map userData; } public SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof SimpleQuantity) return (SimpleQuantity) b; else if (b instanceof Quantity) { @@ -574,6 +665,9 @@ private Map userData; } public Range castToRange(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Range) return (Range) b; else @@ -581,6 +675,9 @@ private Map userData; } public Period castToPeriod(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Period) return (Period) b; else @@ -588,6 +685,9 @@ private Map userData; } public Ratio castToRatio(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Ratio) return (Ratio) b; else @@ -595,6 +695,9 @@ private Map userData; } public SampledData castToSampledData(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof SampledData) return (SampledData) b; else @@ -602,6 +705,9 @@ private Map userData; } public Signature castToSignature(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Signature) return (Signature) b; else @@ -609,6 +715,9 @@ private Map userData; } public HumanName castToHumanName(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof HumanName) return (HumanName) b; else @@ -616,6 +725,9 @@ private Map userData; } public Address castToAddress(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Address) return (Address) b; else @@ -623,6 +735,9 @@ private Map userData; } public ContactDetail castToContactDetail(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ContactDetail) return (ContactDetail) b; else @@ -630,6 +745,9 @@ private Map userData; } public Contributor castToContributor(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Contributor) return (Contributor) b; else @@ -637,6 +755,9 @@ private Map userData; } public UsageContext castToUsageContext(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof UsageContext) return (UsageContext) b; else @@ -644,6 +765,9 @@ private Map userData; } public RelatedArtifact castToRelatedArtifact(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof RelatedArtifact) return (RelatedArtifact) b; else @@ -651,6 +775,9 @@ private Map userData; } public ContactPoint castToContactPoint(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ContactPoint) return (ContactPoint) b; else @@ -658,6 +785,9 @@ private Map userData; } public Timing castToTiming(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Timing) return (Timing) b; else @@ -665,6 +795,9 @@ private Map userData; } public Reference castToReference(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Reference) return (Reference) b; else if (b.isPrimitive() && Utilities.isURL(b.primitiveValue())) @@ -677,6 +810,9 @@ private Map userData; } public Meta castToMeta(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Meta) return (Meta) b; else @@ -685,6 +821,9 @@ private Map userData; public MarketingStatus castToMarketingStatus(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof MarketingStatus) return (MarketingStatus) b; else @@ -692,6 +831,9 @@ private Map userData; } public ProductShelfLife castToProductShelfLife(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ProductShelfLife) return (ProductShelfLife) b; else @@ -699,6 +841,9 @@ private Map userData; } public ProdCharacteristic castToProdCharacteristic(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ProdCharacteristic) return (ProdCharacteristic) b; else @@ -707,6 +852,9 @@ private Map userData; public SubstanceAmount castToSubstanceAmount(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof SubstanceAmount) return (SubstanceAmount) b; else @@ -714,6 +862,9 @@ private Map userData; } public Extension castToExtension(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Extension) return (Extension) b; else @@ -721,6 +872,9 @@ private Map userData; } public Resource castToResource(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Resource) return (Resource) b; else @@ -728,6 +882,9 @@ private Map userData; } public Narrative castToNarrative(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Narrative) return (Narrative) b; else @@ -736,6 +893,9 @@ private Map userData; public ElementDefinition castToElementDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ElementDefinition) return (ElementDefinition) b; else @@ -743,6 +903,9 @@ private Map userData; } public DataRequirement castToDataRequirement(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DataRequirement) return (DataRequirement) b; else @@ -750,6 +913,9 @@ private Map userData; } public Expression castToExpression(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Expression) return (Expression) b; else @@ -758,6 +924,9 @@ private Map userData; public ParameterDefinition castToParameterDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ParameterDefinition) return (ParameterDefinition) b; else @@ -765,6 +934,9 @@ private Map userData; } public TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof TriggerDefinition) return (TriggerDefinition) b; else @@ -772,6 +944,9 @@ private Map userData; } public XhtmlNode castToXhtml(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Element) { return ((Element) b).getXhtml(); } else if (b instanceof XhtmlType) { @@ -787,6 +962,9 @@ private Map userData; } public String castToXhtmlString(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Element) { return ((Element) b).getValue(); } else if (b instanceof XhtmlType) { diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/TypeConvertor.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/TypeConvertor.java index af44c2fa7..fe2a76457 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/TypeConvertor.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/model/TypeConvertor.java @@ -15,6 +15,10 @@ public class TypeConvertor { // -- converters for property setters public static DataType castToType(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DataType) return (DataType) b; else if (b.isMetadataBased()) @@ -25,6 +29,10 @@ public class TypeConvertor { public static BooleanType castToBoolean(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof BooleanType) return (BooleanType) b; else @@ -32,6 +40,10 @@ public class TypeConvertor { } public static IntegerType castToInteger(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof IntegerType) return (IntegerType) b; else @@ -39,6 +51,10 @@ public class TypeConvertor { } public static Integer64Type castToInteger64(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Integer64Type) return (Integer64Type) b; else @@ -46,6 +62,10 @@ public class TypeConvertor { } public static DecimalType castToDecimal(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DecimalType) return (DecimalType) b; else if (b.hasPrimitiveValue()) @@ -55,6 +75,10 @@ public class TypeConvertor { } public static Base64BinaryType castToBase64Binary(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Base64BinaryType) return (Base64BinaryType) b; else @@ -62,6 +86,10 @@ public class TypeConvertor { } public static InstantType castToInstant(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof InstantType) return (InstantType) b; else @@ -69,6 +97,10 @@ public class TypeConvertor { } public static StringType castToString(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof StringType) return (StringType) b; else if (b.hasPrimitiveValue()) @@ -78,6 +110,10 @@ public class TypeConvertor { } public static UriType castToUri(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof UriType) return (UriType) b; else if (b.hasPrimitiveValue()) @@ -87,6 +123,10 @@ public class TypeConvertor { } public static UrlType castToUrl(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof UrlType) return (UrlType) b; else if (b.hasPrimitiveValue()) @@ -96,6 +136,10 @@ public class TypeConvertor { } public static CanonicalType castToCanonical(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CanonicalType) return (CanonicalType) b; else if (b.hasPrimitiveValue()) @@ -105,6 +149,10 @@ public class TypeConvertor { } public static DateType castToDate(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DateType) return (DateType) b; else if (b.hasPrimitiveValue()) @@ -114,6 +162,10 @@ public class TypeConvertor { } public static DateTimeType castToDateTime(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DateTimeType) return (DateTimeType) b; else if (b.fhirType().equals("dateTime")) @@ -123,6 +175,9 @@ public class TypeConvertor { } public static TimeType castToTime(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof TimeType) return (TimeType) b; else @@ -130,6 +185,9 @@ public class TypeConvertor { } public static CodeType castToCode(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof CodeType) return (CodeType) b; else if (b.isPrimitive()) @@ -139,6 +197,9 @@ public class TypeConvertor { } public static OidType castToOid(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof OidType) return (OidType) b; else @@ -146,6 +207,9 @@ public class TypeConvertor { } public static IdType castToId(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof IdType) return (IdType) b; else @@ -153,6 +217,9 @@ public class TypeConvertor { } public static UnsignedIntType castToUnsignedInt(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof UnsignedIntType) return (UnsignedIntType) b; else @@ -160,6 +227,9 @@ public class TypeConvertor { } public static PositiveIntType castToPositiveInt(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof PositiveIntType) return (PositiveIntType) b; else @@ -167,6 +237,9 @@ public class TypeConvertor { } public static MarkdownType castToMarkdown(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof MarkdownType) return (MarkdownType) b; else if (b.hasPrimitiveValue()) @@ -176,6 +249,9 @@ public class TypeConvertor { } public static Annotation castToAnnotation(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Annotation) return (Annotation) b; else @@ -183,13 +259,21 @@ public class TypeConvertor { } public static Dosage castToDosage(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Dosage) return (Dosage) b; - else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); + else + throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); } public static Attachment castToAttachment(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Attachment) return (Attachment) b; else @@ -197,6 +281,10 @@ public class TypeConvertor { } public static Identifier castToIdentifier(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Identifier) return (Identifier) b; else @@ -204,6 +292,10 @@ public class TypeConvertor { } public static CodeableConcept castToCodeableConcept(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CodeableConcept) return (CodeableConcept) b; else if (b instanceof Element) { @@ -221,6 +313,10 @@ public class TypeConvertor { } public static CodeableReference castToCodeableReference(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CodeableReference) { return (CodeableReference) b; } else if (b instanceof CodeType) { @@ -240,6 +336,10 @@ public class TypeConvertor { } public static Population castToPopulation(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Population) return (Population) b; else @@ -248,6 +348,10 @@ public class TypeConvertor { public static Coding castToCoding(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Coding) return (Coding) b; else if (b instanceof Element) { @@ -270,6 +374,10 @@ public class TypeConvertor { } public static Quantity castToQuantity(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Quantity) return (Quantity) b; else @@ -277,6 +385,10 @@ public class TypeConvertor { } public static Money castToMoney(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Money) return (Money) b; else @@ -284,6 +396,10 @@ public class TypeConvertor { } public static Duration castToDuration(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Duration) return (Duration) b; else @@ -291,6 +407,11 @@ public class TypeConvertor { } public static SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException { + if (b == null) { + return null; + } + + if (b instanceof SimpleQuantity) return (SimpleQuantity) b; else if (b instanceof Quantity) { @@ -307,6 +428,10 @@ public class TypeConvertor { } public static Range castToRange(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Range) return (Range) b; else @@ -314,6 +439,10 @@ public class TypeConvertor { } public static Period castToPeriod(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Period) return (Period) b; else @@ -321,6 +450,10 @@ public class TypeConvertor { } public static Ratio castToRatio(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Ratio) return (Ratio) b; else @@ -328,6 +461,11 @@ public class TypeConvertor { } public static SampledData castToSampledData(Base b) throws FHIRException { + if (b == null) { + return null; + } + + if (b instanceof SampledData) return (SampledData) b; else @@ -335,6 +473,9 @@ public class TypeConvertor { } public static Signature castToSignature(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Signature) return (Signature) b; else @@ -342,6 +483,9 @@ public class TypeConvertor { } public static HumanName castToHumanName(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof HumanName) return (HumanName) b; else @@ -349,6 +493,9 @@ public class TypeConvertor { } public static Address castToAddress(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Address) return (Address) b; else @@ -356,6 +503,9 @@ public class TypeConvertor { } public static ContactDetail castToContactDetail(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ContactDetail) return (ContactDetail) b; else @@ -363,6 +513,9 @@ public class TypeConvertor { } public static Contributor castToContributor(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Contributor) return (Contributor) b; else @@ -370,6 +523,9 @@ public class TypeConvertor { } public static UsageContext castToUsageContext(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof UsageContext) return (UsageContext) b; else @@ -377,6 +533,9 @@ public class TypeConvertor { } public static RelatedArtifact castToRelatedArtifact(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof RelatedArtifact) return (RelatedArtifact) b; else @@ -384,6 +543,9 @@ public class TypeConvertor { } public static ContactPoint castToContactPoint(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ContactPoint) return (ContactPoint) b; else @@ -391,6 +553,9 @@ public class TypeConvertor { } public static Timing castToTiming(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Timing) return (Timing) b; else @@ -398,6 +563,9 @@ public class TypeConvertor { } public static Reference castToReference(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Reference) return (Reference) b; else if (b.isPrimitive() && Utilities.isURL(b.primitiveValue())) @@ -410,6 +578,9 @@ public class TypeConvertor { } public static Meta castToMeta(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Meta) return (Meta) b; else @@ -418,6 +589,9 @@ public class TypeConvertor { public static MarketingStatus castToMarketingStatus(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof MarketingStatus) return (MarketingStatus) b; else @@ -425,6 +599,9 @@ public class TypeConvertor { } public static Statistic castToStatistic(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Statistic) return (Statistic) b; else @@ -433,6 +610,9 @@ public class TypeConvertor { public static OrderedDistribution castToOrderedDistribution(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof OrderedDistribution) return (OrderedDistribution) b; else @@ -440,6 +620,9 @@ public class TypeConvertor { } public static ProductShelfLife castToProductShelfLife(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ProductShelfLife) return (ProductShelfLife) b; else @@ -447,6 +630,9 @@ public class TypeConvertor { } public static ProdCharacteristic castToProdCharacteristic(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ProdCharacteristic) return (ProdCharacteristic) b; else @@ -455,6 +641,9 @@ public class TypeConvertor { public static SubstanceAmount castToSubstanceAmount(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof SubstanceAmount) return (SubstanceAmount) b; else @@ -462,6 +651,9 @@ public class TypeConvertor { } public static Extension castToExtension(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Extension) return (Extension) b; else @@ -469,6 +661,9 @@ public class TypeConvertor { } public static Resource castToResource(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Resource) return (Resource) b; else @@ -476,6 +671,9 @@ public class TypeConvertor { } public static Narrative castToNarrative(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Narrative) return (Narrative) b; else @@ -484,6 +682,9 @@ public class TypeConvertor { public static ElementDefinition castToElementDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ElementDefinition) return (ElementDefinition) b; else @@ -491,6 +692,9 @@ public class TypeConvertor { } public static DataRequirement castToDataRequirement(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DataRequirement) return (DataRequirement) b; else @@ -498,6 +702,9 @@ public class TypeConvertor { } public static Expression castToExpression(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Expression) return (Expression) b; else @@ -506,6 +713,9 @@ public class TypeConvertor { public static ParameterDefinition castToParameterDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof ParameterDefinition) return (ParameterDefinition) b; else @@ -513,6 +723,9 @@ public class TypeConvertor { } public static TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof TriggerDefinition) return (TriggerDefinition) b; else @@ -520,6 +733,9 @@ public class TypeConvertor { } public static XhtmlNode castToXhtml(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Element) { return ((Element) b).getXhtml(); } else if (b instanceof XhtmlType) { @@ -535,6 +751,9 @@ public class TypeConvertor { } public static String castToXhtmlString(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Element) { return ((Element) b).getValue(); } else if (b instanceof XhtmlType) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/TypeConvertor.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/TypeConvertor.java index f775d8979..10d483951 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/TypeConvertor.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/TypeConvertor.java @@ -15,6 +15,9 @@ public class TypeConvertor { // -- converters for property setters public static DataType castToType(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DataType) return (DataType) b; else if (b.isMetadataBased()) @@ -25,6 +28,9 @@ public class TypeConvertor { public static BooleanType castToBoolean(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof BooleanType) return (BooleanType) b; else @@ -32,6 +38,9 @@ public class TypeConvertor { } public static IntegerType castToInteger(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof IntegerType) return (IntegerType) b; else @@ -39,6 +48,9 @@ public class TypeConvertor { } public static Integer64Type castToInteger64(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Integer64Type) return (Integer64Type) b; else @@ -46,6 +58,9 @@ public class TypeConvertor { } public static DecimalType castToDecimal(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof DecimalType) return (DecimalType) b; else if (b.hasPrimitiveValue()) @@ -55,6 +70,9 @@ public class TypeConvertor { } public static Base64BinaryType castToBase64Binary(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof Base64BinaryType) return (Base64BinaryType) b; else @@ -62,6 +80,9 @@ public class TypeConvertor { } public static InstantType castToInstant(Base b) throws FHIRException { + if (b == null) { + return null; + } if (b instanceof InstantType) return (InstantType) b; else @@ -69,6 +90,10 @@ public class TypeConvertor { } public static StringType castToString(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof StringType) return (StringType) b; else if (b.hasPrimitiveValue()) @@ -78,6 +103,10 @@ public class TypeConvertor { } public static UriType castToUri(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof UriType) return (UriType) b; else if (b.hasPrimitiveValue()) @@ -87,6 +116,10 @@ public class TypeConvertor { } public static UrlType castToUrl(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof UrlType) return (UrlType) b; else if (b.hasPrimitiveValue()) @@ -96,6 +129,10 @@ public class TypeConvertor { } public static CanonicalType castToCanonical(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CanonicalType) return (CanonicalType) b; else if (b.hasPrimitiveValue()) @@ -105,6 +142,10 @@ public class TypeConvertor { } public static DateType castToDate(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DateType) return (DateType) b; else if (b.hasPrimitiveValue()) @@ -114,6 +155,10 @@ public class TypeConvertor { } public static DateTimeType castToDateTime(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DateTimeType) return (DateTimeType) b; else if (b.fhirType().equals("dateTime")) @@ -123,6 +168,10 @@ public class TypeConvertor { } public static TimeType castToTime(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof TimeType) return (TimeType) b; else @@ -130,6 +179,10 @@ public class TypeConvertor { } public static CodeType castToCode(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CodeType) return (CodeType) b; else if (b.isPrimitive()) @@ -139,6 +192,10 @@ public class TypeConvertor { } public static OidType castToOid(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof OidType) return (OidType) b; else @@ -146,6 +203,10 @@ public class TypeConvertor { } public static IdType castToId(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof IdType) return (IdType) b; else @@ -153,6 +214,10 @@ public class TypeConvertor { } public static UnsignedIntType castToUnsignedInt(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof UnsignedIntType) return (UnsignedIntType) b; else @@ -160,6 +225,10 @@ public class TypeConvertor { } public static PositiveIntType castToPositiveInt(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof PositiveIntType) return (PositiveIntType) b; else @@ -167,6 +236,10 @@ public class TypeConvertor { } public static MarkdownType castToMarkdown(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof MarkdownType) return (MarkdownType) b; else if (b.hasPrimitiveValue()) @@ -176,6 +249,10 @@ public class TypeConvertor { } public static Annotation castToAnnotation(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Annotation) return (Annotation) b; else @@ -183,13 +260,22 @@ public class TypeConvertor { } public static Dosage castToDosage(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Dosage) return (Dosage) b; - else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); + else + throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction"); } public static Attachment castToAttachment(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Attachment) return (Attachment) b; else @@ -197,6 +283,10 @@ public class TypeConvertor { } public static Identifier castToIdentifier(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Identifier) return (Identifier) b; else @@ -204,6 +294,10 @@ public class TypeConvertor { } public static CodeableConcept castToCodeableConcept(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CodeableConcept) return (CodeableConcept) b; else if (b instanceof Element) { @@ -221,6 +315,10 @@ public class TypeConvertor { } public static CodeableReference castToCodeableReference(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof CodeableReference) { return (CodeableReference) b; } else if (b instanceof CodeType) { @@ -240,6 +338,10 @@ public class TypeConvertor { } public static Population castToPopulation(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Population) return (Population) b; else @@ -248,6 +350,10 @@ public class TypeConvertor { public static Coding castToCoding(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Coding) return (Coding) b; else if (b instanceof Element) { @@ -270,6 +376,10 @@ public class TypeConvertor { } public static Quantity castToQuantity(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Quantity) return (Quantity) b; else @@ -277,6 +387,10 @@ public class TypeConvertor { } public static Count castToCount(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Count) return (Count) b; else @@ -284,6 +398,10 @@ public class TypeConvertor { } public static Money castToMoney(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Money) return (Money) b; else @@ -291,6 +409,10 @@ public class TypeConvertor { } public static Duration castToDuration(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Duration) return (Duration) b; else @@ -298,6 +420,10 @@ public class TypeConvertor { } public static SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof SimpleQuantity) return (SimpleQuantity) b; else if (b instanceof Quantity) { @@ -314,6 +440,10 @@ public class TypeConvertor { } public static Range castToRange(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Range) return (Range) b; else @@ -321,6 +451,10 @@ public class TypeConvertor { } public static Period castToPeriod(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Period) return (Period) b; else @@ -328,6 +462,10 @@ public class TypeConvertor { } public static Ratio castToRatio(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Ratio) return (Ratio) b; else @@ -335,6 +473,10 @@ public class TypeConvertor { } public static SampledData castToSampledData(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof SampledData) return (SampledData) b; else @@ -342,6 +484,10 @@ public class TypeConvertor { } public static Signature castToSignature(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Signature) return (Signature) b; else @@ -349,6 +495,10 @@ public class TypeConvertor { } public static HumanName castToHumanName(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof HumanName) return (HumanName) b; else @@ -356,6 +506,10 @@ public class TypeConvertor { } public static Address castToAddress(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Address) return (Address) b; else @@ -363,6 +517,10 @@ public class TypeConvertor { } public static ContactDetail castToContactDetail(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ContactDetail) return (ContactDetail) b; else @@ -370,6 +528,10 @@ public class TypeConvertor { } public static Contributor castToContributor(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Contributor) return (Contributor) b; else @@ -377,6 +539,10 @@ public class TypeConvertor { } public static UsageContext castToUsageContext(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof UsageContext) return (UsageContext) b; else @@ -384,6 +550,10 @@ public class TypeConvertor { } public static RelatedArtifact castToRelatedArtifact(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof RelatedArtifact) return (RelatedArtifact) b; else @@ -391,6 +561,10 @@ public class TypeConvertor { } public static ContactPoint castToContactPoint(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ContactPoint) return (ContactPoint) b; else @@ -398,6 +572,10 @@ public class TypeConvertor { } public static Timing castToTiming(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Timing) return (Timing) b; else @@ -405,6 +583,10 @@ public class TypeConvertor { } public static Reference castToReference(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Reference) return (Reference) b; else if (b.isPrimitive() && Utilities.isURL(b.primitiveValue())) @@ -417,6 +599,10 @@ public class TypeConvertor { } public static Meta castToMeta(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Meta) return (Meta) b; else @@ -425,6 +611,10 @@ public class TypeConvertor { public static MarketingStatus castToMarketingStatus(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof MarketingStatus) return (MarketingStatus) b; else @@ -432,6 +622,10 @@ public class TypeConvertor { } public static Statistic castToStatistic(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Statistic) return (Statistic) b; else @@ -440,13 +634,21 @@ public class TypeConvertor { public static OrderedDistribution castToOrderedDistribution(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof OrderedDistribution) return (OrderedDistribution) b; else throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a OrderedDistribution"); } - public static ProductShelfLife castToProductShelfLife(Base b) throws FHIRException { + public static ProductShelfLife castToProductShelfLife(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ProductShelfLife) return (ProductShelfLife) b; else @@ -454,6 +656,10 @@ public class TypeConvertor { } public static ProdCharacteristic castToProdCharacteristic(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ProdCharacteristic) return (ProdCharacteristic) b; else @@ -462,6 +668,10 @@ public class TypeConvertor { public static SubstanceAmount castToSubstanceAmount(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof SubstanceAmount) return (SubstanceAmount) b; else @@ -469,6 +679,10 @@ public class TypeConvertor { } public static Extension castToExtension(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Extension) return (Extension) b; else @@ -476,6 +690,10 @@ public class TypeConvertor { } public static Resource castToResource(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Resource) return (Resource) b; else @@ -483,6 +701,10 @@ public class TypeConvertor { } public static Narrative castToNarrative(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Narrative) return (Narrative) b; else @@ -491,6 +713,10 @@ public class TypeConvertor { public static ElementDefinition castToElementDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ElementDefinition) return (ElementDefinition) b; else @@ -498,6 +724,10 @@ public class TypeConvertor { } public static DataRequirement castToDataRequirement(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof DataRequirement) return (DataRequirement) b; else @@ -505,6 +735,10 @@ public class TypeConvertor { } public static Expression castToExpression(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Expression) return (Expression) b; else @@ -513,6 +747,10 @@ public class TypeConvertor { public static ParameterDefinition castToParameterDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ParameterDefinition) return (ParameterDefinition) b; else @@ -520,6 +758,10 @@ public class TypeConvertor { } public static TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof TriggerDefinition) return (TriggerDefinition) b; else @@ -527,6 +769,10 @@ public class TypeConvertor { } public static ExtendedContactDetail castToExtendedContactDetail(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof ExtendedContactDetail) return (ExtendedContactDetail) b; else @@ -537,6 +783,10 @@ public class TypeConvertor { public static XhtmlNode castToXhtml(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Element) { return ((Element) b).getXhtml(); } else if (b instanceof XhtmlType) { @@ -552,6 +802,10 @@ public class TypeConvertor { } public static String castToXhtmlString(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Element) { return ((Element) b).getValue(); } else if (b instanceof XhtmlType) { @@ -568,6 +822,10 @@ public class TypeConvertor { public static VirtualServiceDetail castToVirtualServiceDetail(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof VirtualServiceDetail) return (VirtualServiceDetail) b; else @@ -576,6 +834,10 @@ public class TypeConvertor { public static Availability castToAvailability(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof Availability) return (Availability) b; else @@ -584,6 +846,10 @@ public class TypeConvertor { public static MonetaryComponent castToMonetaryComponent(Base b) throws FHIRException { + if (b == null) { + return null; + } + if (b instanceof MonetaryComponent) return (MonetaryComponent) b; else diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java index 619d5e960..32125968a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/StructureDefinitionRenderer.java @@ -382,7 +382,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer { public void scanBindings(Set cols, List list, ElementDefinition ed) { if (ed.hasBinding()) { - if (ed.getBinding().hasValueSet()) { + if (ed.getBinding().hasValueSet() && ed.getBinding().hasStrength()) { switch (ed.getBinding().getStrength()) { case EXAMPLE: cols.add("example"); @@ -770,7 +770,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer { List res = new ArrayList<>(); if (element.hasBinding()) { ElementDefinitionBindingComponent b = element.getBinding(); - if (type.equals(b.getStrength().toCode())) { + if (b.hasStrength() && type.equals(b.getStrength().toCode())) { ElementDefinitionBindingAdditionalComponent ab = new ElementDefinitionBindingAdditionalComponent(); res.add(ab.setAny(false).setDocumentation(b.getDescription()).setValueSet(b.getValueSet())); } @@ -990,6 +990,9 @@ public class StructureDefinitionRenderer extends ResourceRenderer { } private Row makeChoiceElementRow(HierarchicalTableGenerator gen, Row prow, ElementChoiceGroup grp, ElementDefinition parent, boolean isConstraintMode) { + if (context.getStructureMode() != StructureDefinitionRendererMode.SUMMARY) { + return prow; + } Row row = gen.new Row(); row.setAnchor(parent.getPath()+"-"+grp.getName()); row.setColor(context.getProfileUtilities().getRowColor(parent, isConstraintMode));