From 4b099cf057a6b7f4932827b00913e53bbb604dd6 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 15 Nov 2018 16:11:55 +0100 Subject: [PATCH] Fix #944 - NPE when using a custom resource class that has a @Block child --- .../ca/uhn/fhir/context/ModelScanner.java | 152 +-- .../fhir/context/FhirContextDstu3Test.java | 36 +- .../uhn/fhir/context/MyEpisodeOfCareFHIR.java | 867 ++++++++++++++++++ .../fhir/context/_EventMarkerComponent.java | 101 ++ .../_MyReferralInformationComponent.java | 162 ++++ .../fhir/context/_MyReferrerComponent.java | 140 +++ .../fhir/context/_OtherReferrerComponent.java | 122 +++ .../ca/uhn/fhir/context/_PayorComponent.java | 119 +++ .../uhn/fhir/context/_PreviousComponent.java | 101 ++ src/changes/changes.xml | 5 + 10 files changed, 1724 insertions(+), 81 deletions(-) create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/MyEpisodeOfCareFHIR.java create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_EventMarkerComponent.java create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferralInformationComponent.java create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferrerComponent.java create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_OtherReferrerComponent.java create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PayorComponent.java create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PreviousComponent.java diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java index a40954b9290..f754d2ce020 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java @@ -9,9 +9,9 @@ package ca.uhn.fhir.context; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,17 +19,6 @@ package ca.uhn.fhir.context; * limitations under the License. * #L% */ -import static org.apache.commons.lang3.StringUtils.isBlank; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.*; -import java.util.*; -import java.util.Map.Entry; - -import org.apache.commons.io.IOUtils; -import org.hl7.fhir.instance.model.api.*; import ca.uhn.fhir.context.RuntimeSearchParam.RuntimeSearchParamStatusEnum; import ca.uhn.fhir.model.api.*; @@ -38,6 +27,19 @@ import ca.uhn.fhir.model.primitive.BoundCodeDt; import ca.uhn.fhir.model.primitive.XhtmlDt; import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum; import ca.uhn.fhir.util.ReflectionUtil; +import org.hl7.fhir.instance.model.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.*; +import java.util.Map.Entry; + +import static org.apache.commons.lang3.StringUtils.isBlank; class ModelScanner { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class); @@ -55,7 +57,7 @@ class ModelScanner { private Set> myVersionTypes; ModelScanner(FhirContext theContext, FhirVersionEnum theVersion, Map, BaseRuntimeElementDefinition> theExistingDefinitions, - Collection> theResourceTypes) throws ConfigurationException { + Collection> theResourceTypes) throws ConfigurationException { myContext = theContext; myVersion = theVersion; Set> toScan; @@ -67,32 +69,6 @@ class ModelScanner { init(theExistingDefinitions, toScan); } - static Class determineElementType(Field next) { - Class nextElementType = next.getType(); - if (List.class.equals(nextElementType)) { - nextElementType = ReflectionUtil.getGenericCollectionTypeOfField(next); - } else if (Collection.class.isAssignableFrom(nextElementType)) { - throw new ConfigurationException("Field '" + next.getName() + "' in type '" + next.getClass().getCanonicalName() + "' is a Collection - Only java.util.List curently supported"); - } - return nextElementType; - } - - @SuppressWarnings("unchecked") - static IValueSetEnumBinder> getBoundCodeBinder(Field theNext) { - Class bound = getGenericCollectionTypeOfCodedField(theNext); - if (bound == null) { - throw new ConfigurationException("Field '" + theNext + "' has no parameter for " + BoundCodeDt.class.getSimpleName() + " to determine enum type"); - } - - String fieldName = "VALUESET_BINDER"; - try { - Field bindingField = bound.getField(fieldName); - return (IValueSetEnumBinder>) bindingField.get(null); - } catch (Exception e) { - throw new ConfigurationException("Field '" + theNext + "' has type parameter " + bound.getCanonicalName() + " but this class has no valueset binding field (must have a field called " + fieldName + ")", e); - } - } - public Map, BaseRuntimeElementDefinition> getClassToElementDefinitions() { return myClassToElementDefinitions; } @@ -137,7 +113,7 @@ class ModelScanner { for (Class nextClass : typesToScan) { scan(nextClass); } - for (Iterator> iter = myScanAlso.iterator(); iter.hasNext();) { + for (Iterator> iter = myScanAlso.iterator(); iter.hasNext(); ) { if (myClassToElementDefinitions.containsKey(iter.next())) { iter.remove(); } @@ -152,7 +128,7 @@ class ModelScanner { continue; } BaseRuntimeElementDefinition next = nextEntry.getValue(); - + boolean deferredSeal = false; if (myContext.getPerformanceOptions().contains(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING)) { if (next instanceof BaseRuntimeElementCompositeDefinition) { @@ -177,16 +153,6 @@ class ModelScanner { return retVal; } - /** - * There are two implementations of all of the annotations (e.g. {@link Child} since the HL7.org ones will eventually replace the HAPI - * ones. Annotations can't extend each other or implement interfaces or anything like that, so rather than duplicate all of the annotation processing code this method just creates an interface - * Proxy to simulate the HAPI annotations if the HL7.org ones are found instead. - */ - static T pullAnnotation(AnnotatedElement theTarget, Class theAnnotationType) { - T retVal = theTarget.getAnnotation(theAnnotationType); - return retVal; - } - private void scan(Class theClass) throws ConfigurationException { BaseRuntimeElementDefinition existingDef = myClassToElementDefinitions.get(theClass); if (existingDef != null) { @@ -197,7 +163,7 @@ class ModelScanner { if (resourceDefinition != null) { if (!IBaseResource.class.isAssignableFrom(theClass)) { throw new ConfigurationException( - "Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName()); + "Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName()); } @SuppressWarnings("unchecked") Class resClass = (Class) theClass; @@ -212,11 +178,11 @@ class ModelScanner { Class resClass = (Class) theClass; scanCompositeDatatype(resClass, datatypeDefinition); } else if (IPrimitiveType.class.isAssignableFrom(theClass)) { - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings({"unchecked"}) Class> resClass = (Class>) theClass; scanPrimitiveDatatype(resClass, datatypeDefinition); - } - + } + return; } @@ -227,13 +193,13 @@ class ModelScanner { scanBlock(theClass); } else { throw new ConfigurationException( - "Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName()); + "Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName()); } } if (blockDefinition == null //Redundant checking && datatypeDefinition == null && resourceDefinition == null - ) { + ) { throw new ConfigurationException("Resource class[" + theClass.getName() + "] does not contain any valid HAPI-FHIR annotations"); } } @@ -247,6 +213,8 @@ class ModelScanner { } RuntimeResourceBlockDefinition blockDef = new RuntimeResourceBlockDefinition(resourceName, theClass, isStandardType(theClass), myContext, myClassToElementDefinitions); + blockDef.populateScanAlso(myScanAlso); + myClassToElementDefinitions.put(theClass, blockDef); } @@ -272,14 +240,6 @@ class ModelScanner { elementDef.populateScanAlso(myScanAlso); } - - - static Class> determineEnumTypeForBoundField(Field next) { - @SuppressWarnings("unchecked") - Class> enumType = (Class>) ReflectionUtil.getGenericCollectionTypeOfFieldWithSecondOrderForList(next); - return enumType; - } - private String scanPrimitiveDatatype(Class> theClass, DatatypeDef theDatatypeDefinition) { ourLog.debug("Scanning resource class: {}", theClass.getName()); @@ -333,7 +293,7 @@ class ModelScanner { } if (isBlank(resourceName)) { throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name(): " + theClass.getCanonicalName() - + " - This is only allowed for types that extend other resource types "); + + " - This is only allowed for types that extend other resource types "); } } @@ -345,12 +305,12 @@ class ModelScanner { primaryNameProvider = false; } } - + String resourceId = resourceDefinition.id(); if (!isBlank(resourceId)) { if (myIdToResourceDefinition.containsKey(resourceId)) { throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and " - + myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName()); + + myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName()); } } @@ -372,7 +332,7 @@ class ModelScanner { * sure that this type gets scanned as well */ resourceDef.populateScanAlso(myScanAlso); - + return resourceName; } @@ -393,7 +353,7 @@ class ModelScanner { } nextClass = nextClass.getSuperclass(); } while (nextClass.equals(Object.class) == false); - + /* * Now scan the fields for search params */ @@ -420,7 +380,7 @@ class ModelScanner { } providesMembershipInCompartments.add(next.name()); } - + if (paramType == RestSearchParameterTypeEnum.COMPOSITE) { compositeFields.put(nextField, searchParam); continue; @@ -442,7 +402,7 @@ class ModelScanner { RuntimeSearchParam param = nameToParam.get(nextName); if (param == null) { ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}", - new Object[] { theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() }); + new Object[]{theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet()}); continue; } compositeOf.add(param); @@ -455,17 +415,59 @@ class ModelScanner { private Set toTargetList(Class[] theTarget) { HashSet retVal = new HashSet(); - + for (Class nextType : theTarget) { ResourceDef resourceDef = nextType.getAnnotation(ResourceDef.class); if (resourceDef != null) { retVal.add(resourceDef.name()); } } - + return retVal; } + static Class determineElementType(Field next) { + Class nextElementType = next.getType(); + if (List.class.equals(nextElementType)) { + nextElementType = ReflectionUtil.getGenericCollectionTypeOfField(next); + } else if (Collection.class.isAssignableFrom(nextElementType)) { + throw new ConfigurationException("Field '" + next.getName() + "' in type '" + next.getClass().getCanonicalName() + "' is a Collection - Only java.util.List curently supported"); + } + return nextElementType; + } + + @SuppressWarnings("unchecked") + static IValueSetEnumBinder> getBoundCodeBinder(Field theNext) { + Class bound = getGenericCollectionTypeOfCodedField(theNext); + if (bound == null) { + throw new ConfigurationException("Field '" + theNext + "' has no parameter for " + BoundCodeDt.class.getSimpleName() + " to determine enum type"); + } + + String fieldName = "VALUESET_BINDER"; + try { + Field bindingField = bound.getField(fieldName); + return (IValueSetEnumBinder>) bindingField.get(null); + } catch (Exception e) { + throw new ConfigurationException("Field '" + theNext + "' has type parameter " + bound.getCanonicalName() + " but this class has no valueset binding field (must have a field called " + fieldName + ")", e); + } + } + + /** + * There are two implementations of all of the annotations (e.g. {@link Child} since the HL7.org ones will eventually replace the HAPI + * ones. Annotations can't extend each other or implement interfaces or anything like that, so rather than duplicate all of the annotation processing code this method just creates an interface + * Proxy to simulate the HAPI annotations if the HL7.org ones are found instead. + */ + static T pullAnnotation(AnnotatedElement theTarget, Class theAnnotationType) { + T retVal = theTarget.getAnnotation(theAnnotationType); + return retVal; + } + + static Class> determineEnumTypeForBoundField(Field next) { + @SuppressWarnings("unchecked") + Class> enumType = (Class>) ReflectionUtil.getGenericCollectionTypeOfFieldWithSecondOrderForList(next); + return enumType; + } + private static Class getGenericCollectionTypeOfCodedField(Field next) { Class type; ParameterizedType collectionType = (ParameterizedType) next.getGenericType(); diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java index 80a04f1f097..1ece9388c92 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/FhirContextDstu3Test.java @@ -3,16 +3,12 @@ package ca.uhn.fhir.context; import ca.uhn.fhir.rest.client.MyPatientWithExtensions; import ca.uhn.fhir.util.OperationOutcomeUtil; import ca.uhn.fhir.util.TestUtil; +import org.hl7.fhir.dstu3.model.*; import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender; -import org.hl7.fhir.dstu3.model.Patient; -import org.hl7.fhir.dstu3.model.Reference; -import org.hl7.fhir.dstu3.model.StructureDefinition; import org.junit.AfterClass; import org.junit.Test; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -148,6 +144,34 @@ public class FhirContextDstu3Test { assertEquals(null, genderChild.getBoundEnumType()); } + /** + * See #944 + */ + @Test + public void testNullPointerException() { + Bundle bundle = new Bundle(); + MyEpisodeOfCareFHIR myEpisodeOfCare = new MyEpisodeOfCareFHIR(); + _MyReferralInformationComponent myReferralInformation = new _MyReferralInformationComponent(); + myReferralInformation._setReferralType(new Coding("someSystem", "someCode", "someDisplay")); + myReferralInformation._setFreeChoice(new Coding("someSystem2", "someCode", "someDisplay2")); + myReferralInformation._setReceived(new DateTimeType(createDate(2017, Calendar.JULY, 31))); + myReferralInformation._setReferringOrganisation(new Reference().setReference("someReference").setDisplay("someDisplay3")); + myEpisodeOfCare._setReferralInformation(myReferralInformation); + bundle.addEntry().setResource(myEpisodeOfCare); + FhirContext ctx = FhirContext.forDstu3(); + ctx.newXmlParser().encodeResourceToString(bundle); + } + + private static Date createDate( + int year, + int month, + int day) { + Calendar CAL = Calendar.getInstance(); + CAL.clear(); + CAL.set(year, month, day); + return CAL.getTime(); + } + @AfterClass public static void afterClassClearContext() { TestUtil.clearAllStaticFieldsForUnitTest(); diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/MyEpisodeOfCareFHIR.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/MyEpisodeOfCareFHIR.java new file mode 100644 index 00000000000..4925ba21881 --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/MyEpisodeOfCareFHIR.java @@ -0,0 +1,867 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.model.api.annotation.ResourceDef; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.*; + +import java.util.ArrayList; +import java.util.List; + + +@ResourceDef(name = MyEpisodeOfCareFHIR.FHIR_RESOURCE_NAME, id = MyEpisodeOfCareFHIR.FHIR_PROFILE_NAME, profile = MyEpisodeOfCareFHIR.FHIR_PROFILE_URI) +public class MyEpisodeOfCareFHIR extends EpisodeOfCare { + + public static final String FHIR_RESOURCE_NAME = "EpisodeOfCare"; + public static final String FHIR_PROFILE_NAME = "MyEpisodeOfCare"; + public static final String FHIR_PROFILE_URI = "http://myfhir.dk/p/MyEpisodeOfCare"; + /** + * dischargeTo (extension) + */ + @Child(name = FIELD_DISCHARGETO, min = 0, max = 1, type = {StringType.class}) + @Description(shortDefinition = "", formalDefinition = "Discharge to") + @Extension(url = EXTURL_DISCHARGETO, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.StringType ourDischargeTo; + public static final String EXTURL_DISCHARGETO = "http://myfhir.dk/x/MyEpisodeOfCare-discharge-to"; + public static final String FIELD_DISCHARGETO = "dischargeTo"; + /** + * dischargeDisposition (extension) + */ + @Child(name = FIELD_DISCHARGEDISPOSITION, min = 0, max = 1, type = {Coding.class}) + @Description(shortDefinition = "", formalDefinition = "Category or kind of location after discharge.") + @Extension(url = EXTURL_DISCHARGEDISPOSITION, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Coding ourDischargeDisposition; + public static final String EXTURL_DISCHARGEDISPOSITION = "http://myfhir.dk/x/MyEpisodeOfCare-discharge-disposition"; + public static final String FIELD_DISCHARGEDISPOSITION = "dischargeDisposition"; + /** + * previous (extension) + */ + @Child(name = FIELD_PREVIOUS, min = 0, max = 1, type = {_PreviousComponent.class}) + @Description(shortDefinition = "", formalDefinition = "Previous reference between episode of care.") + @Extension(url = EXTURL_PREVIOUS, definedLocally = false, isModifier = false) + protected _PreviousComponent ourPrevious; + public static final String EXTURL_PREVIOUS = "http://myfhir.dk/x/MyEpisodeOfCare-previous"; + public static final String FIELD_PREVIOUS = "previous"; + /** + * referralInformation (extension) + */ + @Child(name = FIELD_REFERRALINFORMATION, min = 1, max = 1, type = {_MyReferralInformationComponent.class}) + @Description(shortDefinition = "", formalDefinition = "Referral information related to this episode of care.") + @Extension(url = EXTURL_REFERRALINFORMATION, definedLocally = false, isModifier = false) + protected _MyReferralInformationComponent ourReferralInformation; + public static final String EXTURL_REFERRALINFORMATION = "http://myfhir.dk/x/MyEpisodeOfCare-referral-information"; + public static final String FIELD_REFERRALINFORMATION = "referralInformation"; + /** + * eventMarker (extension) + */ + @Child(name = FIELD_EVENTMARKER, min = 0, max = Child.MAX_UNLIMITED, type = {_EventMarkerComponent.class}) + @Description(shortDefinition = "", formalDefinition = "Marks specific times on an episode of care with clinical or administrative relevance.") + @Extension(url = EXTURL_EVENTMARKER, definedLocally = false, isModifier = false) + protected List<_EventMarkerComponent> ourEventMarker; + public static final String EXTURL_EVENTMARKER = "http://myfhir.dk/x/MyEpisodeOfCare-event-marker"; + public static final String FIELD_EVENTMARKER = "eventMarker"; + /** + * payor (extension) + */ + @Child(name = FIELD_PAYOR, min = 0, max = Child.MAX_UNLIMITED, type = {_PayorComponent.class}) + @Description(shortDefinition = "", formalDefinition = "Payor information for time periods") + @Extension(url = EXTURL_PAYOR, definedLocally = false, isModifier = false) + protected List<_PayorComponent> ourPayor; + public static final String EXTURL_PAYOR = "http://myfhir.dk/x/MyEpisodeOfCare-payor"; + public static final String FIELD_PAYOR = "payor"; + /** + * healthIssue (extension) + */ + @Child(name = FIELD_HEALTHISSUE, min = 0, max = 1, type = {Condition.class}) + @Description(shortDefinition = "", formalDefinition = "The health issue this episode of care is related to.") + @Extension(url = EXTURL_HEALTHISSUE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Reference ourHealthIssue; + public static final String EXTURL_HEALTHISSUE = "http://myfhir.dk/x/MyEpisodeOfCare-health-issue"; + public static final String FIELD_HEALTHISSUE = "healthIssue"; + /** + * identifier + */ + @Child(name = FIELD_IDENTIFIER, min = 0, max = Child.MAX_UNLIMITED, order = Child.REPLACE_PARENT, type = {Identifier.class}) + @Description(shortDefinition = "Business Identifier(s) relevant for this EpisodeOfCare", formalDefinition = "Identifiers which the episode of care is known by.") + protected List ourIdentifier; + public static final String FIELD_IDENTIFIER = "identifier"; + /** + * status + */ + @Child(name = FIELD_STATUS, min = 1, max = 1, order = Child.REPLACE_PARENT, modifier = true, summary = true, type = {CodeType.class}) + @Description(shortDefinition = "planned | waitlist | active | onhold | finished | cancelled | entered-in-error", formalDefinition = "Status of the episode of care.") + protected org.hl7.fhir.dstu3.model.Enumeration ourStatus; + public static final String FIELD_STATUS = "status"; + /** + * patient + */ + @Child(name = FIELD_PATIENT, min = 1, max = 1, order = Child.REPLACE_PARENT, summary = true, type = {Patient.class}) + @Description(shortDefinition = "The patient who is the focus of this episode of care", formalDefinition = "The patient who is the subject of this episode of care.") + protected org.hl7.fhir.dstu3.model.Reference ourPatient; + public static final String FIELD_PATIENT = "patient"; + /** + * managingOrganization + */ + @Child(name = FIELD_MANAGINGORGANIZATION, min = 0, max = 1, order = Child.REPLACE_PARENT, summary = true, type = {Organization.class}) + @Description(shortDefinition = "Organization that assumes care", formalDefinition = "The organization that assumes care.") + protected org.hl7.fhir.dstu3.model.Reference ourManagingOrganization; + public static final String FIELD_MANAGINGORGANIZATION = "managingOrganization"; + /** + * period + */ + @Child(name = FIELD_PERIOD, min = 1, max = 1, order = Child.REPLACE_PARENT, summary = true, type = {Period.class}) + @Description(shortDefinition = "Interval during responsibility is assumed", formalDefinition = "The start and end time of the episode of care.") + protected Period ourPeriod; + public static final String FIELD_PERIOD = "period"; + /** + * careManager + */ + @Child(name = FIELD_CAREMANAGER, min = 0, max = 1, order = Child.REPLACE_PARENT, type = {Practitioner.class}) + @Description(shortDefinition = "Care manager/care co-ordinator for the patient", formalDefinition = "Care manager") + protected org.hl7.fhir.dstu3.model.Reference ourCareManager; + public static final String FIELD_CAREMANAGER = "careManager"; + /** + * + */ + @Child(name = "statusHistory", min = 0, max = 0, order = Child.REPLACE_PARENT) + @Deprecated + protected ca.uhn.fhir.model.api.IElement ourStatusHistory; + /** + * + */ + @Child(name = "type", min = 0, max = 0, order = Child.REPLACE_PARENT) + @Deprecated + protected ca.uhn.fhir.model.api.IElement ourType; + /** + * + */ + @Child(name = "diagnosis", min = 0, max = 0, order = Child.REPLACE_PARENT) + @Deprecated + protected ca.uhn.fhir.model.api.IElement ourDiagnosis; + /** + * + */ + @Child(name = "referralRequest", min = 0, max = 0, order = Child.REPLACE_PARENT) + @Deprecated + protected ca.uhn.fhir.model.api.IElement ourReferralRequest; + /** + * + */ + @Child(name = "team", min = 0, max = 0, order = Child.REPLACE_PARENT) + @Deprecated + protected ca.uhn.fhir.model.api.IElement ourTeam; + /** + * + */ + @Child(name = "account", min = 0, max = 0, order = Child.REPLACE_PARENT) + @Deprecated + protected ca.uhn.fhir.model.api.IElement ourAccount; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourDischargeTo, ourDischargeDisposition, ourPrevious, ourReferralInformation, ourEventMarker, ourPayor, ourHealthIssue, ourIdentifier, ourStatus, ourPatient, ourManagingOrganization, ourPeriod, ourCareManager); + } + + @Override + public MyEpisodeOfCareFHIR copy() { + MyEpisodeOfCareFHIR dst = new MyEpisodeOfCareFHIR(); + copyValues(dst); + dst.ourDischargeTo = ourDischargeTo == null ? null : ourDischargeTo.copy(); + dst.ourDischargeDisposition = ourDischargeDisposition == null ? null : ourDischargeDisposition.copy(); + dst.ourPrevious = ourPrevious == null ? null : ourPrevious.copy(); + dst.ourReferralInformation = ourReferralInformation == null ? null : ourReferralInformation.copy(); + if (ourEventMarker != null) { + dst.ourEventMarker = new ArrayList<_EventMarkerComponent>(); + for (_EventMarkerComponent i : ourEventMarker) { + dst.ourEventMarker.add(i.copy()); + } + } + if (ourPayor != null) { + dst.ourPayor = new ArrayList<_PayorComponent>(); + for (_PayorComponent i : ourPayor) { + dst.ourPayor.add(i.copy()); + } + } + dst.ourHealthIssue = ourHealthIssue == null ? null : ourHealthIssue.copy(); + if (ourIdentifier != null) { + dst.ourIdentifier = new ArrayList(); + for (org.hl7.fhir.dstu3.model.Identifier i : ourIdentifier) { + dst.ourIdentifier.add(i.copy()); + } + } + dst.ourStatus = ourStatus == null ? null : ourStatus.copy(); + dst.ourPatient = ourPatient == null ? null : ourPatient.copy(); + dst.ourManagingOrganization = ourManagingOrganization == null ? null : ourManagingOrganization.copy(); + dst.ourPeriod = ourPeriod == null ? null : ourPeriod.copy(); + dst.ourCareManager = ourCareManager == null ? null : ourCareManager.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof MyEpisodeOfCareFHIR)) { + return false; + } + MyEpisodeOfCareFHIR that = (MyEpisodeOfCareFHIR) other; + return compareDeep(ourDischargeTo, that.ourDischargeTo, true) && compareDeep(ourDischargeDisposition, that.ourDischargeDisposition, true) && compareDeep(ourPrevious, that.ourPrevious, true) && compareDeep(ourReferralInformation, that.ourReferralInformation, true) + && compareDeep(ourEventMarker, that.ourEventMarker, true) && compareDeep(ourPayor, that.ourPayor, true) && compareDeep(ourHealthIssue, that.ourHealthIssue, true) && compareDeep(ourIdentifier, that.ourIdentifier, true) && compareDeep(ourStatus, that.ourStatus, true) + && compareDeep(ourPatient, that.ourPatient, true) && compareDeep(ourManagingOrganization, that.ourManagingOrganization, true) && compareDeep(ourPeriod, that.ourPeriod, true) && compareDeep(ourCareManager, that.ourCareManager, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof MyEpisodeOfCareFHIR)) { + return false; + } + MyEpisodeOfCareFHIR that = (MyEpisodeOfCareFHIR) other; + return compareValues(ourDischargeTo, that.ourDischargeTo, true) && compareValues(ourStatus, that.ourStatus, true); + } + + public org.hl7.fhir.dstu3.model.StringType _getDischargeTo() { + if (ourDischargeTo == null) + ourDischargeTo = new org.hl7.fhir.dstu3.model.StringType(); + return ourDischargeTo; + } + + public MyEpisodeOfCareFHIR _setDischargeTo(org.hl7.fhir.dstu3.model.StringType theValue) { + ourDischargeTo = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Coding _getDischargeDisposition() { + if (ourDischargeDisposition == null) + ourDischargeDisposition = new org.hl7.fhir.dstu3.model.Coding(); + return ourDischargeDisposition; + } + + public MyEpisodeOfCareFHIR _setDischargeDisposition(org.hl7.fhir.dstu3.model.Coding theValue) { + ourDischargeDisposition = theValue; + return this; + } + + public _PreviousComponent _getPrevious() { + if (ourPrevious == null) + ourPrevious = new _PreviousComponent(); + return ourPrevious; + } + + public MyEpisodeOfCareFHIR _setPrevious(_PreviousComponent theValue) { + ourPrevious = theValue; + return this; + } + + public _MyReferralInformationComponent _getReferralInformation() { + if (ourReferralInformation == null) + ourReferralInformation = new _MyReferralInformationComponent(); + return ourReferralInformation; + } + + public MyEpisodeOfCareFHIR _setReferralInformation(_MyReferralInformationComponent theValue) { + ourReferralInformation = theValue; + return this; + } + + public List<_EventMarkerComponent> _getEventMarker() { + if (ourEventMarker == null) + ourEventMarker = new ArrayList<>(); + return ourEventMarker; + } + + public MyEpisodeOfCareFHIR _setEventMarker(List<_EventMarkerComponent> theValue) { + ourEventMarker = theValue; + return this; + } + + public List<_PayorComponent> _getPayor() { + if (ourPayor == null) + ourPayor = new ArrayList<>(); + return ourPayor; + } + + public MyEpisodeOfCareFHIR _setPayor(List<_PayorComponent> theValue) { + ourPayor = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Reference _getHealthIssue() { + if (ourHealthIssue == null) + ourHealthIssue = new org.hl7.fhir.dstu3.model.Reference(); + return ourHealthIssue; + } + + public MyEpisodeOfCareFHIR _setHealthIssue(org.hl7.fhir.dstu3.model.Reference theValue) { + ourHealthIssue = theValue; + return this; + } + + public List _getIdentifier() { + if (ourIdentifier == null) + ourIdentifier = new ArrayList<>(); + return ourIdentifier; + } + + public MyEpisodeOfCareFHIR _setIdentifier(List theValue) { + ourIdentifier = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Enumeration _getStatus() { + if (ourStatus == null) + ourStatus = new org.hl7.fhir.dstu3.model.Enumeration(new EpisodeOfCareStatusEnumFactory()); + return ourStatus; + } + + public MyEpisodeOfCareFHIR _setStatus(org.hl7.fhir.dstu3.model.Enumeration theValue) { + ourStatus = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Reference _getPatient() { + if (ourPatient == null) + ourPatient = new org.hl7.fhir.dstu3.model.Reference(); + return ourPatient; + } + + public MyEpisodeOfCareFHIR _setPatient(org.hl7.fhir.dstu3.model.Reference theValue) { + ourPatient = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Reference _getManagingOrganization() { + if (ourManagingOrganization == null) + ourManagingOrganization = new org.hl7.fhir.dstu3.model.Reference(); + return ourManagingOrganization; + } + + public MyEpisodeOfCareFHIR _setManagingOrganization(org.hl7.fhir.dstu3.model.Reference theValue) { + ourManagingOrganization = theValue; + return this; + } + + public Period _getPeriod() { + if (ourPeriod == null) + ourPeriod = new Period(); + return ourPeriod; + } + + public MyEpisodeOfCareFHIR _setPeriod(Period theValue) { + ourPeriod = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Reference _getCareManager() { + if (ourCareManager == null) + ourCareManager = new org.hl7.fhir.dstu3.model.Reference(); + return ourCareManager; + } + + public MyEpisodeOfCareFHIR _setCareManager(org.hl7.fhir.dstu3.model.Reference theValue) { + ourCareManager = theValue; + return this; + } + + @Override + @Deprecated + public void listChildren(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasAccount() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasCareManager() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasDiagnosis() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasIdentifier() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasManagingOrganization() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasPatient() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasPeriod() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasReferralRequest() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasStatus() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasStatusElement() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasStatusHistory() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasTeam() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public boolean hasType() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public String fhirType() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public String[] getTypesForProperty(int p0, String p1) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getAccount() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getAccountTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getDiagnosis() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getIdentifier() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getReferralRequest() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getReferralRequestTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getStatusHistory() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getTeam() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getTeamTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public List getType() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Account addAccountTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Base addChild(String p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Base makeProperty(int p0, String p1) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Base setProperty(int p0, String p1, Base p2) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Base setProperty(String p0, Base p1) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Base[] getProperty(int p0, String p1, boolean p2) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public CareTeam addTeamTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public CodeableConcept addType() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public CodeableConcept getTypeFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Enumeration getStatusElement() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addAccount(Reference p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addDiagnosis(DiagnosisComponent p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addIdentifier(Identifier p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addReferralRequest(Reference p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addStatusHistory(EpisodeOfCareStatusHistoryComponent p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addTeam(Reference p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare addType(CodeableConcept p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setAccount(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setCareManager(Reference p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setCareManagerTarget(Practitioner p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setDiagnosis(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setIdentifier(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setManagingOrganization(Reference p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setManagingOrganizationTarget(Organization p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setPatient(Reference p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setPatientTarget(Patient p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setPeriod(Period p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setReferralRequest(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setStatus(EpisodeOfCareStatus p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setStatusElement(Enumeration p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setStatusHistory(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setTeam(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCare setType(List p0) { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public DiagnosisComponent addDiagnosis() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public DiagnosisComponent getDiagnosisFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCareStatus getStatus() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCareStatusHistoryComponent addStatusHistory() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public EpisodeOfCareStatusHistoryComponent getStatusHistoryFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Identifier addIdentifier() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Identifier getIdentifierFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Organization getManagingOrganizationTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Patient getPatientTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Period getPeriod() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Practitioner getCareManagerTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference addAccount() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference addReferralRequest() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference addTeam() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference getAccountFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference getCareManager() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference getManagingOrganization() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference getPatient() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference getReferralRequestFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public Reference getTeamFirstRep() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public ReferralRequest addReferralRequestTarget() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + @Deprecated + public ResourceType getResourceType() { + throw new UnsupportedOperationException("Deprecated method"); + } + + @Override + protected MyEpisodeOfCareFHIR typedCopy() { + return copy(); + } +} diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_EventMarkerComponent.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_EventMarkerComponent.java new file mode 100644 index 00000000000..a78d6c3e85f --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_EventMarkerComponent.java @@ -0,0 +1,101 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.BackboneElement; +import org.hl7.fhir.dstu3.model.Base; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.DateTimeType; + +@Block +public class _EventMarkerComponent extends BackboneElement implements org.hl7.fhir.instance.model.api.IBaseBackboneElement { + + /** + * eventType (extension) + */ + @Child(name = FIELD_EVENTTYPE, min = 1, max = 1, type = {Coding.class}) + @Description(shortDefinition = "", formalDefinition = "The type of event marker on an episode of care.") + @Extension(url = EXTURL_EVENTTYPE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Coding ourEventType; + public static final String EXTURL_EVENTTYPE = "http://myfhir.dk/x/MyEpisodeOfCare-event-marker/eventType"; + public static final String FIELD_EVENTTYPE = "eventType"; + /** + * eventTimestamp (extension) + */ + @Child(name = FIELD_EVENTTIMESTAMP, min = 1, max = 1, type = {DateTimeType.class}) + @Description(shortDefinition = "", formalDefinition = "Time in which the event marker was created.") + @Extension(url = EXTURL_EVENTTIMESTAMP, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.DateTimeType ourEventTimestamp; + public static final String EXTURL_EVENTTIMESTAMP = "http://myfhir.dk/x/MyEpisodeOfCare-event-marker/eventTimestamp"; + public static final String FIELD_EVENTTIMESTAMP = "eventTimestamp"; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourEventType, ourEventTimestamp); + } + + @Override + public _EventMarkerComponent copy() { + _EventMarkerComponent dst = new _EventMarkerComponent(); + copyValues(dst); + dst.ourEventType = ourEventType == null ? null : ourEventType.copy(); + dst.ourEventTimestamp = ourEventTimestamp == null ? null : ourEventTimestamp.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof _EventMarkerComponent)) { + return false; + } + _EventMarkerComponent that = (_EventMarkerComponent) other; + return compareDeep(ourEventType, that.ourEventType, true) && compareDeep(ourEventTimestamp, that.ourEventTimestamp, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof _EventMarkerComponent)) { + return false; + } + _EventMarkerComponent that = (_EventMarkerComponent) other; + return compareValues(ourEventTimestamp, that.ourEventTimestamp, true); + } + + public org.hl7.fhir.dstu3.model.Coding _getEventType() { + if (ourEventType == null) + ourEventType = new org.hl7.fhir.dstu3.model.Coding(); + return ourEventType; + } + + public _EventMarkerComponent _setEventType(org.hl7.fhir.dstu3.model.Coding theValue) { + ourEventType = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.DateTimeType _getEventTimestamp() { + if (ourEventTimestamp == null) + ourEventTimestamp = new org.hl7.fhir.dstu3.model.DateTimeType(); + return ourEventTimestamp; + } + + public _EventMarkerComponent _setEventTimestamp(org.hl7.fhir.dstu3.model.DateTimeType theValue) { + ourEventTimestamp = theValue; + return this; + } + +} diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferralInformationComponent.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferralInformationComponent.java new file mode 100644 index 00000000000..50fea802e9d --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferralInformationComponent.java @@ -0,0 +1,162 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.*; + +@Block +public class _MyReferralInformationComponent extends BackboneElement implements org.hl7.fhir.instance.model.api.IBaseBackboneElement { + + /** + * referralType (extension) + */ + @Child(name = FIELD_REFERRALTYPE, min = 1, max = 1, type = {Coding.class}) + @Description(shortDefinition = "", formalDefinition = "Referral type in referral info.") + @Extension(url = EXTURL_REFERRALTYPE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Coding ourReferralType; + public static final String EXTURL_REFERRALTYPE = "http://myfhir.dk/x/MyReferralInformation/referralType"; + public static final String FIELD_REFERRALTYPE = "referralType"; + /** + * referringOrganisation (extension) + */ + @Child(name = FIELD_REFERRINGORGANISATION, min = 0, max = 1, type = {Organization.class}) + @Description(shortDefinition = "", formalDefinition = "The organization which the referral originates from.") + @Extension(url = EXTURL_REFERRINGORGANISATION, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Reference ourReferringOrganisation; + public static final String EXTURL_REFERRINGORGANISATION = "http://myfhir.dk/x/MyReferralInformation/referringOrganisation"; + public static final String FIELD_REFERRINGORGANISATION = "referringOrganisation"; + /** + * freeChoice (extension) + */ + @Child(name = FIELD_FREECHOICE, min = 1, max = 1, type = {Coding.class}) + @Description(shortDefinition = "", formalDefinition = "Type of free choice in relation to the referral decision.") + @Extension(url = EXTURL_FREECHOICE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Coding ourFreeChoice; + public static final String EXTURL_FREECHOICE = "http://myfhir.dk/x/MyReferralInformation/freeChoice"; + public static final String FIELD_FREECHOICE = "freeChoice"; + /** + * received (extension) + */ + @Child(name = FIELD_RECEIVED, min = 1, max = 1, type = {DateTimeType.class}) + @Description(shortDefinition = "", formalDefinition = "Time in which the referral was received.") + @Extension(url = EXTURL_RECEIVED, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.DateTimeType ourReceived; + public static final String EXTURL_RECEIVED = "http://myfhir.dk/x/MyReferralInformation/received"; + public static final String FIELD_RECEIVED = "received"; + /** + * referrer (extension) + */ + @Child(name = FIELD_REFERRER, min = 0, max = 1, type = {_MyReferrerComponent.class}) + @Description(shortDefinition = "", formalDefinition = "Referring organization, doctor or other.") + @Extension(url = EXTURL_REFERRER, definedLocally = false, isModifier = false) + protected _MyReferrerComponent ourReferrer; + public static final String EXTURL_REFERRER = "http://myfhir.dk/x/MyReferralInformation-referrer"; + public static final String FIELD_REFERRER = "referrer"; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourReferralType, ourReferringOrganisation, ourFreeChoice, ourReceived, ourReferrer); + } + + @Override + public _MyReferralInformationComponent copy() { + _MyReferralInformationComponent dst = new _MyReferralInformationComponent(); + copyValues(dst); + dst.ourReferralType = ourReferralType == null ? null : ourReferralType.copy(); + dst.ourReferringOrganisation = ourReferringOrganisation == null ? null : ourReferringOrganisation.copy(); + dst.ourFreeChoice = ourFreeChoice == null ? null : ourFreeChoice.copy(); + dst.ourReceived = ourReceived == null ? null : ourReceived.copy(); + dst.ourReferrer = ourReferrer == null ? null : ourReferrer.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof _MyReferralInformationComponent)) { + return false; + } + _MyReferralInformationComponent that = (_MyReferralInformationComponent) other; + return compareDeep(ourReferralType, that.ourReferralType, true) && compareDeep(ourReferringOrganisation, that.ourReferringOrganisation, true) && compareDeep(ourFreeChoice, that.ourFreeChoice, true) && compareDeep(ourReceived, that.ourReceived, true) + && compareDeep(ourReferrer, that.ourReferrer, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof _MyReferralInformationComponent)) { + return false; + } + _MyReferralInformationComponent that = (_MyReferralInformationComponent) other; + return compareValues(ourReceived, that.ourReceived, true); + } + + public org.hl7.fhir.dstu3.model.Coding _getReferralType() { + if (ourReferralType == null) + ourReferralType = new org.hl7.fhir.dstu3.model.Coding(); + return ourReferralType; + } + + public _MyReferralInformationComponent _setReferralType(org.hl7.fhir.dstu3.model.Coding theValue) { + ourReferralType = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Reference _getReferringOrganisation() { + if (ourReferringOrganisation == null) + ourReferringOrganisation = new org.hl7.fhir.dstu3.model.Reference(); + return ourReferringOrganisation; + } + + public _MyReferralInformationComponent _setReferringOrganisation(org.hl7.fhir.dstu3.model.Reference theValue) { + ourReferringOrganisation = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Coding _getFreeChoice() { + if (ourFreeChoice == null) + ourFreeChoice = new org.hl7.fhir.dstu3.model.Coding(); + return ourFreeChoice; + } + + public _MyReferralInformationComponent _setFreeChoice(org.hl7.fhir.dstu3.model.Coding theValue) { + ourFreeChoice = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.DateTimeType _getReceived() { + if (ourReceived == null) + ourReceived = new org.hl7.fhir.dstu3.model.DateTimeType(); + return ourReceived; + } + + public _MyReferralInformationComponent _setReceived(org.hl7.fhir.dstu3.model.DateTimeType theValue) { + ourReceived = theValue; + return this; + } + + public _MyReferrerComponent _getReferrer() { + if (ourReferrer == null) + ourReferrer = new _MyReferrerComponent(); + return ourReferrer; + } + + public _MyReferralInformationComponent _setReferrer(_MyReferrerComponent theValue) { + ourReferrer = theValue; + return this; + } + +} diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferrerComponent.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferrerComponent.java new file mode 100644 index 00000000000..7969362186b --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_MyReferrerComponent.java @@ -0,0 +1,140 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.*; + +@Block +public class _MyReferrerComponent extends BackboneElement implements org.hl7.fhir.instance.model.api.IBaseBackboneElement { + + /** + * referrerType (extension) + */ + @Child(name = FIELD_REFERRERTYPE, min = 1, max = 1, type = {StringType.class}) + @Description(shortDefinition = "", formalDefinition = "Type of the selected referrer") + @Extension(url = EXTURL_REFERRERTYPE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.StringType ourReferrerType; + public static final String EXTURL_REFERRERTYPE = "http://myfhir.dk/x/MyReferrer/referrerType"; + public static final String FIELD_REFERRERTYPE = "referrerType"; + /** + * hospitalReferrer (extension) + */ + @Child(name = FIELD_HOSPITALREFERRER, min = 0, max = 1, type = {CodeType.class}) + @Description(shortDefinition = "", formalDefinition = "Hospital department reference.") + @Extension(url = EXTURL_HOSPITALREFERRER, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.CodeType ourHospitalReferrer; + public static final String EXTURL_HOSPITALREFERRER = "http://myfhir.dk/x/MyReferrer/hospitalReferrer"; + public static final String FIELD_HOSPITALREFERRER = "hospitalReferrer"; + /** + * doctorReferrer (extension) + */ + @Child(name = FIELD_DOCTORREFERRER, min = 0, max = 1, type = {Practitioner.class}) + @Description(shortDefinition = "", formalDefinition = "Reference to a medical practitioner or a specialist doctor.") + @Extension(url = EXTURL_DOCTORREFERRER, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Reference ourDoctorReferrer; + public static final String EXTURL_DOCTORREFERRER = "http://myfhir.dk/x/MyReferrer/doctorReferrer"; + public static final String FIELD_DOCTORREFERRER = "doctorReferrer"; + /** + * otherReferrer (extension) + */ + @Child(name = FIELD_OTHERREFERRER, min = 0, max = 1, type = {_OtherReferrerComponent.class}) + @Description(shortDefinition = "", formalDefinition = "Name, address and phone number of the referrer.") + @Extension(url = EXTURL_OTHERREFERRER, definedLocally = false, isModifier = false) + protected _OtherReferrerComponent ourOtherReferrer; + public static final String EXTURL_OTHERREFERRER = "http://myfhir.dk/x/MyReferrer/otherReferrer"; + public static final String FIELD_OTHERREFERRER = "otherReferrer"; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourReferrerType, ourHospitalReferrer, ourDoctorReferrer, ourOtherReferrer); + } + + @Override + public _MyReferrerComponent copy() { + _MyReferrerComponent dst = new _MyReferrerComponent(); + copyValues(dst); + dst.ourReferrerType = ourReferrerType == null ? null : ourReferrerType.copy(); + dst.ourHospitalReferrer = ourHospitalReferrer == null ? null : ourHospitalReferrer.copy(); + dst.ourDoctorReferrer = ourDoctorReferrer == null ? null : ourDoctorReferrer.copy(); + dst.ourOtherReferrer = ourOtherReferrer == null ? null : ourOtherReferrer.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof _MyReferrerComponent)) { + return false; + } + _MyReferrerComponent that = (_MyReferrerComponent) other; + return compareDeep(ourReferrerType, that.ourReferrerType, true) && compareDeep(ourHospitalReferrer, that.ourHospitalReferrer, true) && compareDeep(ourDoctorReferrer, that.ourDoctorReferrer, true) && compareDeep(ourOtherReferrer, that.ourOtherReferrer, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof _MyReferrerComponent)) { + return false; + } + _MyReferrerComponent that = (_MyReferrerComponent) other; + return compareValues(ourReferrerType, that.ourReferrerType, true) && compareValues(ourHospitalReferrer, that.ourHospitalReferrer, true); + } + + public org.hl7.fhir.dstu3.model.StringType _getReferrerType() { + if (ourReferrerType == null) + ourReferrerType = new org.hl7.fhir.dstu3.model.StringType(); + return ourReferrerType; + } + + public _MyReferrerComponent _setReferrerType(org.hl7.fhir.dstu3.model.StringType theValue) { + ourReferrerType = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.CodeType _getHospitalReferrer() { + if (ourHospitalReferrer == null) + ourHospitalReferrer = new org.hl7.fhir.dstu3.model.CodeType(); + return ourHospitalReferrer; + } + + public _MyReferrerComponent _setHospitalReferrer(org.hl7.fhir.dstu3.model.CodeType theValue) { + ourHospitalReferrer = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Reference _getDoctorReferrer() { + if (ourDoctorReferrer == null) + ourDoctorReferrer = new org.hl7.fhir.dstu3.model.Reference(); + return ourDoctorReferrer; + } + + public _MyReferrerComponent _setDoctorReferrer(org.hl7.fhir.dstu3.model.Reference theValue) { + ourDoctorReferrer = theValue; + return this; + } + + public _OtherReferrerComponent _getOtherReferrer() { + if (ourOtherReferrer == null) + ourOtherReferrer = new _OtherReferrerComponent(); + return ourOtherReferrer; + } + + public _MyReferrerComponent _setOtherReferrer(_OtherReferrerComponent theValue) { + ourOtherReferrer = theValue; + return this; + } + +} diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_OtherReferrerComponent.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_OtherReferrerComponent.java new file mode 100644 index 00000000000..00087dfdaa6 --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_OtherReferrerComponent.java @@ -0,0 +1,122 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.Address; +import org.hl7.fhir.dstu3.model.BackboneElement; +import org.hl7.fhir.dstu3.model.Base; +import org.hl7.fhir.dstu3.model.StringType; + +@Block +public class _OtherReferrerComponent extends BackboneElement implements org.hl7.fhir.instance.model.api.IBaseBackboneElement { + + /** + * name (extension) + */ + @Child(name = FIELD_NAME, min = 0, max = 1, type = {StringType.class}) + @Description(shortDefinition = "", formalDefinition = "Name of the referrer") + @Extension(url = EXTURL_NAME, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.StringType ourName; + public static final String EXTURL_NAME = "http://myfhir.dk/x/MyReferrer/otherReferrer/name"; + public static final String FIELD_NAME = "name"; + /** + * address (extension) + */ + @Child(name = FIELD_ADDRESS, min = 0, max = 1, type = {Address.class}) + @Description(shortDefinition = "", formalDefinition = "Address of the referrer") + @Extension(url = EXTURL_ADDRESS, definedLocally = false, isModifier = false) + protected Address ourAddress; + public static final String EXTURL_ADDRESS = "http://myfhir.dk/x/MyReferrer/otherReferrer/address"; + public static final String FIELD_ADDRESS = "address"; + /** + * phoneNumber (extension) + */ + @Child(name = FIELD_PHONENUMBER, min = 0, max = 1, type = {StringType.class}) + @Description(shortDefinition = "", formalDefinition = "Phone number of the referrer") + @Extension(url = EXTURL_PHONENUMBER, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.StringType ourPhoneNumber; + public static final String EXTURL_PHONENUMBER = "http://myfhir.dk/x/MyReferrer/otherReferrer/phoneNumber"; + public static final String FIELD_PHONENUMBER = "phoneNumber"; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourName, ourAddress, ourPhoneNumber); + } + + @Override + public _OtherReferrerComponent copy() { + _OtherReferrerComponent dst = new _OtherReferrerComponent(); + copyValues(dst); + dst.ourName = ourName == null ? null : ourName.copy(); + dst.ourAddress = ourAddress == null ? null : ourAddress.copy(); + dst.ourPhoneNumber = ourPhoneNumber == null ? null : ourPhoneNumber.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof _OtherReferrerComponent)) { + return false; + } + _OtherReferrerComponent that = (_OtherReferrerComponent) other; + return compareDeep(ourName, that.ourName, true) && compareDeep(ourAddress, that.ourAddress, true) && compareDeep(ourPhoneNumber, that.ourPhoneNumber, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof _OtherReferrerComponent)) { + return false; + } + _OtherReferrerComponent that = (_OtherReferrerComponent) other; + return compareValues(ourName, that.ourName, true) && compareValues(ourPhoneNumber, that.ourPhoneNumber, true); + } + + public org.hl7.fhir.dstu3.model.StringType _getName() { + if (ourName == null) + ourName = new org.hl7.fhir.dstu3.model.StringType(); + return ourName; + } + + public _OtherReferrerComponent _setName(org.hl7.fhir.dstu3.model.StringType theValue) { + ourName = theValue; + return this; + } + + public Address _getAddress() { + if (ourAddress == null) + ourAddress = new Address(); + return ourAddress; + } + + public _OtherReferrerComponent _setAddress(Address theValue) { + ourAddress = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.StringType _getPhoneNumber() { + if (ourPhoneNumber == null) + ourPhoneNumber = new org.hl7.fhir.dstu3.model.StringType(); + return ourPhoneNumber; + } + + public _OtherReferrerComponent _setPhoneNumber(org.hl7.fhir.dstu3.model.StringType theValue) { + ourPhoneNumber = theValue; + return this; + } + +} diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PayorComponent.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PayorComponent.java new file mode 100644 index 00000000000..963d32b016c --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PayorComponent.java @@ -0,0 +1,119 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.*; + +@Block +public class _PayorComponent extends BackboneElement implements org.hl7.fhir.instance.model.api.IBaseBackboneElement { + + /** + * payorCode (extension) + */ + @Child(name = FIELD_PAYORCODE, min = 1, max = 1, type = {Coding.class}) + @Description(shortDefinition = "", formalDefinition = "The payor code for the duration") + @Extension(url = EXTURL_PAYORCODE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Coding ourPayorCode; + public static final String EXTURL_PAYORCODE = "http://myfhir.dk/x/MyEpisodeOfCare-payor/payorCode"; + public static final String FIELD_PAYORCODE = "payorCode"; + /** + * period (extension) + */ + @Child(name = FIELD_PERIOD, min = 1, max = 1, type = {Period.class}) + @Description(shortDefinition = "", formalDefinition = "The duration for the responsible payor.") + @Extension(url = EXTURL_PERIOD, definedLocally = false, isModifier = false) + protected Period ourPeriod; + public static final String EXTURL_PERIOD = "http://myfhir.dk/x/MyEpisodeOfCare-payor/period"; + public static final String FIELD_PERIOD = "period"; + /** + * userDefined (extension) + */ + @Child(name = FIELD_USERDEFINED, min = 1, max = 1, type = {BooleanType.class}) + @Description(shortDefinition = "", formalDefinition = "True if the payor information is defined by a user.") + @Extension(url = EXTURL_USERDEFINED, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.BooleanType ourUserDefined; + public static final String EXTURL_USERDEFINED = "http://myfhir.dk/x/MyEpisodeOfCare-payor/userDefined"; + public static final String FIELD_USERDEFINED = "userDefined"; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourPayorCode, ourPeriod, ourUserDefined); + } + + @Override + public _PayorComponent copy() { + _PayorComponent dst = new _PayorComponent(); + copyValues(dst); + dst.ourPayorCode = ourPayorCode == null ? null : ourPayorCode.copy(); + dst.ourPeriod = ourPeriod == null ? null : ourPeriod.copy(); + dst.ourUserDefined = ourUserDefined == null ? null : ourUserDefined.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof _PayorComponent)) { + return false; + } + _PayorComponent that = (_PayorComponent) other; + return compareDeep(ourPayorCode, that.ourPayorCode, true) && compareDeep(ourPeriod, that.ourPeriod, true) && compareDeep(ourUserDefined, that.ourUserDefined, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof _PayorComponent)) { + return false; + } + _PayorComponent that = (_PayorComponent) other; + return compareValues(ourUserDefined, that.ourUserDefined, true); + } + + public org.hl7.fhir.dstu3.model.Coding _getPayorCode() { + if (ourPayorCode == null) + ourPayorCode = new org.hl7.fhir.dstu3.model.Coding(); + return ourPayorCode; + } + + public _PayorComponent _setPayorCode(org.hl7.fhir.dstu3.model.Coding theValue) { + ourPayorCode = theValue; + return this; + } + + public Period _getPeriod() { + if (ourPeriod == null) + ourPeriod = new Period(); + return ourPeriod; + } + + public _PayorComponent _setPeriod(Period theValue) { + ourPeriod = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.BooleanType _getUserDefined() { + if (ourUserDefined == null) + ourUserDefined = new org.hl7.fhir.dstu3.model.BooleanType(); + return ourUserDefined; + } + + public _PayorComponent _setUserDefined(org.hl7.fhir.dstu3.model.BooleanType theValue) { + ourUserDefined = theValue; + return this; + } + +} diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PreviousComponent.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PreviousComponent.java new file mode 100644 index 00000000000..b4693042b96 --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/context/_PreviousComponent.java @@ -0,0 +1,101 @@ +package ca.uhn.fhir.context; + +import ca.uhn.fhir.model.api.annotation.Block; +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.model.api.annotation.Extension; +import ca.uhn.fhir.util.ElementUtil; +import org.hl7.fhir.dstu3.model.BackboneElement; +import org.hl7.fhir.dstu3.model.Base; +import org.hl7.fhir.dstu3.model.Coding; +import org.hl7.fhir.dstu3.model.StringType; + +@Block +public class _PreviousComponent extends BackboneElement implements org.hl7.fhir.instance.model.api.IBaseBackboneElement { + + /** + * previousReference (extension) + */ + @Child(name = FIELD_PREVIOUSREFERENCE, min = 1, max = 1, type = {StringType.class}) + @Description(shortDefinition = "", formalDefinition = "Reference to the previous episode of care which may be external.") + @Extension(url = EXTURL_PREVIOUSREFERENCE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.StringType ourPreviousReference; + public static final String EXTURL_PREVIOUSREFERENCE = "http://myfhir.dk/x/MyEpisodeOfCare-previous/previousReference"; + public static final String FIELD_PREVIOUSREFERENCE = "previousReference"; + /** + * referenceType (extension) + */ + @Child(name = FIELD_REFERENCETYPE, min = 1, max = 1, type = {Coding.class}) + @Description(shortDefinition = "", formalDefinition = "The type of reference to a previous episode of care.") + @Extension(url = EXTURL_REFERENCETYPE, definedLocally = false, isModifier = false) + protected org.hl7.fhir.dstu3.model.Coding ourReferenceType; + public static final String EXTURL_REFERENCETYPE = "http://myfhir.dk/x/MyEpisodeOfCare-previous/referenceType"; + public static final String FIELD_REFERENCETYPE = "referenceType"; + + @Override + public boolean isEmpty() { + return super.isEmpty() && ElementUtil.isEmpty(ourPreviousReference, ourReferenceType); + } + + @Override + public _PreviousComponent copy() { + _PreviousComponent dst = new _PreviousComponent(); + copyValues(dst); + dst.ourPreviousReference = ourPreviousReference == null ? null : ourPreviousReference.copy(); + dst.ourReferenceType = ourReferenceType == null ? null : ourReferenceType.copy(); + return dst; + } + + @Override + public boolean equalsDeep(Base other) { + if (this == other) { + return true; + } + if (!super.equalsDeep(other)) { + return false; + } + if (!(other instanceof _PreviousComponent)) { + return false; + } + _PreviousComponent that = (_PreviousComponent) other; + return compareDeep(ourPreviousReference, that.ourPreviousReference, true) && compareDeep(ourReferenceType, that.ourReferenceType, true); + } + + @Override + public boolean equalsShallow(Base other) { + if (this == other) { + return true; + } + if (!super.equalsShallow(other)) { + return false; + } + if (!(other instanceof _PreviousComponent)) { + return false; + } + _PreviousComponent that = (_PreviousComponent) other; + return compareValues(ourPreviousReference, that.ourPreviousReference, true); + } + + public org.hl7.fhir.dstu3.model.StringType _getPreviousReference() { + if (ourPreviousReference == null) + ourPreviousReference = new org.hl7.fhir.dstu3.model.StringType(); + return ourPreviousReference; + } + + public _PreviousComponent _setPreviousReference(org.hl7.fhir.dstu3.model.StringType theValue) { + ourPreviousReference = theValue; + return this; + } + + public org.hl7.fhir.dstu3.model.Coding _getReferenceType() { + if (ourReferenceType == null) + ourReferenceType = new org.hl7.fhir.dstu3.model.Coding(); + return ourReferenceType; + } + + public _PreviousComponent _setReferenceType(org.hl7.fhir.dstu3.model.Coding theValue) { + ourReferenceType = theValue; + return this; + } + +} diff --git a/src/changes/changes.xml b/src/changes/changes.xml index cf6786817c6..2aee1cb01be 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -28,6 +28,11 @@ A badly formatted log message when handing exceptions was cleaned up. Thanks to Magnus Watn for the pull request! + + A NullPointerException has been fixed when using custom resource classes that + have a @Block class as a child element. Thanks to Lars Gram Mathiasen for + reporting and providing a test case! +