better error messages converting types
This commit is contained in:
parent
90bcab6554
commit
d9c632d9ad
|
@ -23,7 +23,7 @@ public class TypeConvertor {
|
|||
else if (b.isMetadataBased())
|
||||
return ((org.hl7.fhir.r5.elementmodel.Element) b).asType();
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Reference");
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class TypeConvertor {
|
|||
if (b instanceof BooleanType)
|
||||
return (BooleanType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Boolean");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Boolean");
|
||||
}
|
||||
|
||||
public static IntegerType castToInteger(Base b) throws FHIRException {
|
||||
|
@ -44,7 +44,7 @@ public class TypeConvertor {
|
|||
if (b instanceof IntegerType)
|
||||
return (IntegerType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Integer");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Integer");
|
||||
}
|
||||
|
||||
public static Integer64Type castToInteger64(Base b) throws FHIRException {
|
||||
|
@ -54,7 +54,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Integer64Type)
|
||||
return (Integer64Type) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Integer");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Integer");
|
||||
}
|
||||
|
||||
public static DecimalType castToDecimal(Base b) throws FHIRException {
|
||||
|
@ -66,7 +66,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new DecimalType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Decimal");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Decimal");
|
||||
}
|
||||
|
||||
public static Base64BinaryType castToBase64Binary(Base b) throws FHIRException {
|
||||
|
@ -76,7 +76,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Base64BinaryType)
|
||||
return (Base64BinaryType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Base64Binary");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Base64Binary");
|
||||
}
|
||||
|
||||
public static InstantType castToInstant(Base b) throws FHIRException {
|
||||
|
@ -86,7 +86,7 @@ public class TypeConvertor {
|
|||
if (b instanceof InstantType)
|
||||
return (InstantType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Instant");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Instant");
|
||||
}
|
||||
|
||||
public static StringType castToString(Base b) throws FHIRException {
|
||||
|
@ -99,7 +99,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new StringType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a String");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a String");
|
||||
}
|
||||
|
||||
public static UriType castToUri(Base b) throws FHIRException {
|
||||
|
@ -112,7 +112,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new UriType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Uri");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Uri");
|
||||
}
|
||||
|
||||
public static UrlType castToUrl(Base b) throws FHIRException {
|
||||
|
@ -125,7 +125,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new UrlType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Uri");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Uri");
|
||||
}
|
||||
|
||||
public static CanonicalType castToCanonical(Base b) throws FHIRException {
|
||||
|
@ -138,7 +138,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new CanonicalType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Uri");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Uri");
|
||||
}
|
||||
|
||||
public static DateType castToDate(Base b) throws FHIRException {
|
||||
|
@ -151,7 +151,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new DateType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Date");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Date");
|
||||
}
|
||||
|
||||
public static DateTimeType castToDateTime(Base b) throws FHIRException {
|
||||
|
@ -164,7 +164,7 @@ public class TypeConvertor {
|
|||
else if (b.fhirType().equals("dateTime"))
|
||||
return new DateTimeType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DateTime");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a DateTime");
|
||||
}
|
||||
|
||||
public static TimeType castToTime(Base b) throws FHIRException {
|
||||
|
@ -175,7 +175,7 @@ public class TypeConvertor {
|
|||
if (b instanceof TimeType)
|
||||
return (TimeType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Time");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Time");
|
||||
}
|
||||
|
||||
public static CodeType castToCode(Base b) throws FHIRException {
|
||||
|
@ -190,7 +190,7 @@ public class TypeConvertor {
|
|||
} else if (b.isPrimitive())
|
||||
return new CodeType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Code");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Code");
|
||||
}
|
||||
|
||||
public static OidType castToOid(Base b) throws FHIRException {
|
||||
|
@ -201,7 +201,7 @@ public class TypeConvertor {
|
|||
if (b instanceof OidType)
|
||||
return (OidType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Oid");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Oid");
|
||||
}
|
||||
|
||||
public static IdType castToId(Base b) throws FHIRException {
|
||||
|
@ -212,7 +212,7 @@ public class TypeConvertor {
|
|||
if (b instanceof IdType)
|
||||
return (IdType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Id");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Id");
|
||||
}
|
||||
|
||||
public static UnsignedIntType castToUnsignedInt(Base b) throws FHIRException {
|
||||
|
@ -223,7 +223,7 @@ public class TypeConvertor {
|
|||
if (b instanceof UnsignedIntType)
|
||||
return (UnsignedIntType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a UnsignedInt");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a UnsignedInt");
|
||||
}
|
||||
|
||||
public static PositiveIntType castToPositiveInt(Base b) throws FHIRException {
|
||||
|
@ -234,7 +234,7 @@ public class TypeConvertor {
|
|||
if (b instanceof PositiveIntType)
|
||||
return (PositiveIntType) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a PositiveInt");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a PositiveInt");
|
||||
}
|
||||
|
||||
public static MarkdownType castToMarkdown(Base b) throws FHIRException {
|
||||
|
@ -247,7 +247,7 @@ public class TypeConvertor {
|
|||
else if (b.hasPrimitiveValue())
|
||||
return new MarkdownType(b.primitiveValue());
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Markdown");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Markdown");
|
||||
}
|
||||
|
||||
public static Annotation castToAnnotation(Base b) throws FHIRException {
|
||||
|
@ -258,7 +258,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Annotation)
|
||||
return (Annotation) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Annotation");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Annotation");
|
||||
}
|
||||
|
||||
public static Dosage castToDosage(Base b) throws FHIRException {
|
||||
|
@ -269,7 +269,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Dosage)
|
||||
return (Dosage) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an DosageInstruction");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an DosageInstruction");
|
||||
}
|
||||
|
||||
|
||||
|
@ -281,7 +281,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Attachment)
|
||||
return (Attachment) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Attachment");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Attachment");
|
||||
}
|
||||
|
||||
public static Identifier castToIdentifier(Base b) throws FHIRException {
|
||||
|
@ -292,7 +292,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Identifier)
|
||||
return (Identifier) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Identifier");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Identifier");
|
||||
}
|
||||
|
||||
public static CodeableConcept castToCodeableConcept(Base b) throws FHIRException {
|
||||
|
@ -313,7 +313,7 @@ public class TypeConvertor {
|
|||
cc.addCoding().setCode(((StringType) b).asStringValue());
|
||||
return cc;
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a CodeableConcept");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a CodeableConcept");
|
||||
}
|
||||
|
||||
public static CodeableReference castToCodeableReference(Base b) throws FHIRException {
|
||||
|
@ -336,7 +336,7 @@ public class TypeConvertor {
|
|||
cc.getConcept().addCoding().setCode(((StringType) b).asStringValue());
|
||||
return cc;
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a CodeableConcept");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a CodeableConcept");
|
||||
}
|
||||
|
||||
public static Population castToPopulation(Base b) throws FHIRException {
|
||||
|
@ -347,7 +347,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Population)
|
||||
return (Population) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Population");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Population");
|
||||
}
|
||||
|
||||
|
||||
|
@ -370,7 +370,7 @@ public class TypeConvertor {
|
|||
} else if (b.isPrimitive()) {
|
||||
return new Coding().setCode(b.primitiveValue());
|
||||
} else {
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Coding");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Coding");
|
||||
}
|
||||
} else if (b instanceof ICoding) {
|
||||
ICoding c = (ICoding) b;
|
||||
|
@ -383,7 +383,7 @@ public class TypeConvertor {
|
|||
} else if (b.isPrimitive()) {
|
||||
return new Coding().setCode(b.primitiveValue());
|
||||
} else {
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Coding");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Coding");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Quantity)
|
||||
return (Quantity) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Quantity");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Quantity");
|
||||
}
|
||||
|
||||
public static Count castToCount(Base b) throws FHIRException {
|
||||
|
@ -406,7 +406,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Count)
|
||||
return (Count) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Count");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Count");
|
||||
}
|
||||
|
||||
public static Money castToMoney(Base b) throws FHIRException {
|
||||
|
@ -416,8 +416,11 @@ public class TypeConvertor {
|
|||
|
||||
if (b instanceof Money)
|
||||
return (Money) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Money");
|
||||
else if (b instanceof org.hl7.fhir.r5.elementmodel.Element && Utilities.tail(b.fhirType()).equals("Money")) {
|
||||
org.hl7.fhir.r5.elementmodel.Element e = (org.hl7.fhir.r5.elementmodel.Element) b;
|
||||
return new Money().setCurrency(e.getChildValue("currency")).setValue(Long.parseLong(e.getChildValue("value")));
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Money");
|
||||
}
|
||||
|
||||
public static Duration castToDuration(Base b) throws FHIRException {
|
||||
|
@ -428,7 +431,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Duration)
|
||||
return (Duration) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an Duration");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an Duration");
|
||||
}
|
||||
|
||||
public static SimpleQuantity castToSimpleQuantity(Base b) throws FHIRException {
|
||||
|
@ -448,7 +451,7 @@ public class TypeConvertor {
|
|||
sq.setCodeElement(q.getCodeElement());
|
||||
return sq;
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to an SimpleQuantity");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to an SimpleQuantity");
|
||||
}
|
||||
|
||||
public static Range castToRange(Base b) throws FHIRException {
|
||||
|
@ -459,7 +462,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Range)
|
||||
return (Range) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Range");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Range");
|
||||
}
|
||||
|
||||
public static Period castToPeriod(Base b) throws FHIRException {
|
||||
|
@ -470,7 +473,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Period)
|
||||
return (Period) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Period");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Period");
|
||||
}
|
||||
|
||||
public static Ratio castToRatio(Base b) throws FHIRException {
|
||||
|
@ -481,7 +484,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Ratio)
|
||||
return (Ratio) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Ratio");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Ratio");
|
||||
}
|
||||
|
||||
public static SampledData castToSampledData(Base b) throws FHIRException {
|
||||
|
@ -492,7 +495,7 @@ public class TypeConvertor {
|
|||
if (b instanceof SampledData)
|
||||
return (SampledData) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a SampledData");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a SampledData");
|
||||
}
|
||||
|
||||
public static Signature castToSignature(Base b) throws FHIRException {
|
||||
|
@ -503,7 +506,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Signature)
|
||||
return (Signature) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Signature");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Signature");
|
||||
}
|
||||
|
||||
public static HumanName castToHumanName(Base b) throws FHIRException {
|
||||
|
@ -514,7 +517,7 @@ public class TypeConvertor {
|
|||
if (b instanceof HumanName)
|
||||
return (HumanName) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a HumanName");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a HumanName");
|
||||
}
|
||||
|
||||
public static Address castToAddress(Base b) throws FHIRException {
|
||||
|
@ -525,7 +528,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Address)
|
||||
return (Address) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Address");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Address");
|
||||
}
|
||||
|
||||
public static ContactDetail castToContactDetail(Base b) throws FHIRException {
|
||||
|
@ -536,7 +539,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ContactDetail)
|
||||
return (ContactDetail) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ContactDetail");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ContactDetail");
|
||||
}
|
||||
|
||||
public static Contributor castToContributor(Base b) throws FHIRException {
|
||||
|
@ -547,7 +550,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Contributor)
|
||||
return (Contributor) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Contributor");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Contributor");
|
||||
}
|
||||
|
||||
public static UsageContext castToUsageContext(Base b) throws FHIRException {
|
||||
|
@ -558,7 +561,7 @@ public class TypeConvertor {
|
|||
if (b instanceof UsageContext)
|
||||
return (UsageContext) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a UsageContext");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a UsageContext");
|
||||
}
|
||||
|
||||
public static RelatedArtifact castToRelatedArtifact(Base b) throws FHIRException {
|
||||
|
@ -569,7 +572,7 @@ public class TypeConvertor {
|
|||
if (b instanceof RelatedArtifact)
|
||||
return (RelatedArtifact) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a RelatedArtifact");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a RelatedArtifact");
|
||||
}
|
||||
|
||||
public static ContactPoint castToContactPoint(Base b) throws FHIRException {
|
||||
|
@ -580,7 +583,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ContactPoint)
|
||||
return (ContactPoint) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ContactPoint");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ContactPoint");
|
||||
}
|
||||
|
||||
public static Timing castToTiming(Base b) throws FHIRException {
|
||||
|
@ -591,7 +594,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Timing)
|
||||
return (Timing) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Timing");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Timing");
|
||||
}
|
||||
|
||||
public static Reference castToReference(Base b) throws FHIRException {
|
||||
|
@ -603,11 +606,11 @@ public class TypeConvertor {
|
|||
return (Reference) b;
|
||||
else if (b.isPrimitive() && Utilities.isURL(b.primitiveValue()))
|
||||
return new Reference().setReference(b.primitiveValue());
|
||||
else if (b instanceof org.hl7.fhir.r5.elementmodel.Element && b.fhirType().equals("Reference")) {
|
||||
else if (b instanceof org.hl7.fhir.r5.elementmodel.Element && Utilities.tail(b.fhirType()).equals("Reference")) {
|
||||
org.hl7.fhir.r5.elementmodel.Element e = (org.hl7.fhir.r5.elementmodel.Element) b;
|
||||
return new Reference().setReference(e.getChildValue("reference")).setDisplay(e.getChildValue("display"));
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Reference");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Reference");
|
||||
}
|
||||
|
||||
public static Meta castToMeta(Base b) throws FHIRException {
|
||||
|
@ -618,7 +621,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Meta)
|
||||
return (Meta) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Meta");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Meta");
|
||||
}
|
||||
|
||||
|
||||
|
@ -630,7 +633,7 @@ public class TypeConvertor {
|
|||
if (b instanceof MarketingStatus)
|
||||
return (MarketingStatus) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a MarketingStatus");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a MarketingStatus");
|
||||
}
|
||||
|
||||
public static Statistic castToStatistic(Base b) throws FHIRException {
|
||||
|
@ -641,7 +644,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Statistic)
|
||||
return (Statistic) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Statistic");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Statistic");
|
||||
}
|
||||
|
||||
|
||||
|
@ -653,7 +656,7 @@ public class TypeConvertor {
|
|||
if (b instanceof OrderedDistribution)
|
||||
return (OrderedDistribution) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a OrderedDistribution");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a OrderedDistribution");
|
||||
}
|
||||
|
||||
public static ProductShelfLife castToProductShelfLife(Base b) throws FHIRException {
|
||||
|
@ -664,7 +667,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ProductShelfLife)
|
||||
return (ProductShelfLife) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ProductShelfLife");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ProductShelfLife");
|
||||
}
|
||||
|
||||
public static ProdCharacteristic castToProdCharacteristic(Base b) throws FHIRException {
|
||||
|
@ -675,7 +678,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ProdCharacteristic)
|
||||
return (ProdCharacteristic) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ProdCharacteristic");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ProdCharacteristic");
|
||||
}
|
||||
|
||||
|
||||
|
@ -687,7 +690,7 @@ public class TypeConvertor {
|
|||
if (b instanceof SubstanceAmount)
|
||||
return (SubstanceAmount) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a SubstanceAmount");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a SubstanceAmount");
|
||||
}
|
||||
|
||||
public static Extension castToExtension(Base b) throws FHIRException {
|
||||
|
@ -698,7 +701,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Extension)
|
||||
return (Extension) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Extension");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Extension");
|
||||
}
|
||||
|
||||
public static Resource castToResource(Base b) throws FHIRException {
|
||||
|
@ -709,7 +712,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Resource)
|
||||
return (Resource) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Resource");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Resource");
|
||||
}
|
||||
|
||||
public static Narrative castToNarrative(Base b) throws FHIRException {
|
||||
|
@ -720,7 +723,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Narrative)
|
||||
return (Narrative) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Narrative");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Narrative");
|
||||
}
|
||||
|
||||
|
||||
|
@ -732,7 +735,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ElementDefinition)
|
||||
return (ElementDefinition) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ElementDefinition");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ElementDefinition");
|
||||
}
|
||||
|
||||
public static DataRequirement castToDataRequirement(Base b) throws FHIRException {
|
||||
|
@ -743,7 +746,7 @@ public class TypeConvertor {
|
|||
if (b instanceof DataRequirement)
|
||||
return (DataRequirement) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a DataRequirement");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a DataRequirement");
|
||||
}
|
||||
|
||||
public static Expression castToExpression(Base b) throws FHIRException {
|
||||
|
@ -754,7 +757,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Expression)
|
||||
return (Expression) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Expression");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Expression");
|
||||
}
|
||||
|
||||
|
||||
|
@ -766,7 +769,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ParameterDefinition)
|
||||
return (ParameterDefinition) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ParameterDefinition");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ParameterDefinition");
|
||||
}
|
||||
|
||||
public static TriggerDefinition castToTriggerDefinition(Base b) throws FHIRException {
|
||||
|
@ -777,7 +780,7 @@ public class TypeConvertor {
|
|||
if (b instanceof TriggerDefinition)
|
||||
return (TriggerDefinition) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a TriggerDefinition");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a TriggerDefinition");
|
||||
}
|
||||
|
||||
public static ExtendedContactDetail castToExtendedContactDetail(Base b) throws FHIRException {
|
||||
|
@ -788,7 +791,7 @@ public class TypeConvertor {
|
|||
if (b instanceof ExtendedContactDetail)
|
||||
return (ExtendedContactDetail) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a ExtendedContactDetail");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a ExtendedContactDetail");
|
||||
}
|
||||
|
||||
|
||||
|
@ -810,7 +813,7 @@ public class TypeConvertor {
|
|||
throw new FHIRException(e);
|
||||
}
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to XHtml");
|
||||
}
|
||||
|
||||
public static String castToXhtmlString(Base b) throws FHIRException {
|
||||
|
@ -829,7 +832,7 @@ public class TypeConvertor {
|
|||
} else if (b instanceof StringType) {
|
||||
return ((StringType) b).asStringValue();
|
||||
} else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to XHtml string");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to XHtml string");
|
||||
}
|
||||
|
||||
|
||||
|
@ -841,7 +844,7 @@ public class TypeConvertor {
|
|||
if (b instanceof VirtualServiceDetail)
|
||||
return (VirtualServiceDetail) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a VirtualServiceDetail");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a VirtualServiceDetail");
|
||||
}
|
||||
|
||||
|
||||
|
@ -853,7 +856,7 @@ public class TypeConvertor {
|
|||
if (b instanceof Availability)
|
||||
return (Availability) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Availability");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Availability");
|
||||
}
|
||||
|
||||
|
||||
|
@ -865,6 +868,6 @@ public class TypeConvertor {
|
|||
if (b instanceof MonetaryComponent)
|
||||
return (MonetaryComponent) b;
|
||||
else
|
||||
throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a MonetaryComponent");
|
||||
throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a MonetaryComponent");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue