001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017package ca.uhn.fhir.model.dstu2.resource;
018
019import java.math.BigDecimal;
020import java.net.URI;
021import java.util.*;
022import ca.uhn.fhir.model.api.*;
023import ca.uhn.fhir.model.api.annotation.*;
024import ca.uhn.fhir.rest.gclient.*;
025
026import ca.uhn.fhir.model.dstu2.valueset.AccountStatusEnum;
027import ca.uhn.fhir.model.dstu2.valueset.ActionListEnum;
028import ca.uhn.fhir.model.dstu2.composite.AddressDt;
029import ca.uhn.fhir.model.dstu2.valueset.AdjudicationCodesEnum;
030import ca.uhn.fhir.model.dstu2.valueset.AdjudicationErrorCodesEnum;
031import ca.uhn.fhir.model.dstu2.valueset.AdjustmentReasonCodesEnum;
032import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
033import ca.uhn.fhir.model.dstu2.valueset.AdmitSourceEnum;
034import ca.uhn.fhir.model.dstu2.resource.AllergyIntolerance;
035import ca.uhn.fhir.model.dstu2.valueset.AllergyIntoleranceCategoryEnum;
036import ca.uhn.fhir.model.dstu2.valueset.AllergyIntoleranceCertaintyEnum;
037import ca.uhn.fhir.model.dstu2.valueset.AllergyIntoleranceCriticalityEnum;
038import ca.uhn.fhir.model.dstu2.valueset.AllergyIntoleranceSeverityEnum;
039import ca.uhn.fhir.model.dstu2.valueset.AllergyIntoleranceStatusEnum;
040import ca.uhn.fhir.model.dstu2.valueset.AllergyIntoleranceTypeEnum;
041import ca.uhn.fhir.model.dstu2.composite.AnnotationDt;
042import ca.uhn.fhir.model.dstu2.valueset.AnswerFormatEnum;
043import ca.uhn.fhir.model.dstu2.resource.Appointment;
044import ca.uhn.fhir.model.dstu2.valueset.AppointmentStatusEnum;
045import ca.uhn.fhir.model.dstu2.valueset.AssertionDirectionTypeEnum;
046import ca.uhn.fhir.model.dstu2.valueset.AssertionOperatorTypeEnum;
047import ca.uhn.fhir.model.dstu2.valueset.AssertionResponseTypesEnum;
048import ca.uhn.fhir.model.dstu2.composite.AttachmentDt;
049import ca.uhn.fhir.model.dstu2.valueset.AuditEventActionEnum;
050import ca.uhn.fhir.model.dstu2.valueset.AuditEventObjectLifecycleEnum;
051import ca.uhn.fhir.model.dstu2.valueset.AuditEventObjectRoleEnum;
052import ca.uhn.fhir.model.dstu2.valueset.AuditEventObjectTypeEnum;
053import ca.uhn.fhir.model.dstu2.valueset.AuditEventOutcomeEnum;
054import ca.uhn.fhir.model.dstu2.valueset.AuditEventParticipantNetworkTypeEnum;
055import ca.uhn.fhir.model.dstu2.valueset.AuditEventSourceTypeEnum;
056import ca.uhn.fhir.model.dstu2.valueset.BindingStrengthEnum;
057import ca.uhn.fhir.model.dstu2.resource.BodySite;
058import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
059import ca.uhn.fhir.model.dstu2.resource.CarePlan;
060import ca.uhn.fhir.model.dstu2.valueset.CarePlanActivityStatusEnum;
061import ca.uhn.fhir.model.dstu2.valueset.CarePlanRelationshipEnum;
062import ca.uhn.fhir.model.dstu2.valueset.CarePlanStatusEnum;
063import ca.uhn.fhir.model.dstu2.resource.Claim;
064import ca.uhn.fhir.model.dstu2.resource.ClaimResponse;
065import ca.uhn.fhir.model.dstu2.valueset.ClaimTypeEnum;
066import ca.uhn.fhir.model.dstu2.resource.ClinicalImpression;
067import ca.uhn.fhir.model.dstu2.valueset.ClinicalImpressionStatusEnum;
068import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
069import ca.uhn.fhir.model.dstu2.composite.CodingDt;
070import ca.uhn.fhir.model.dstu2.resource.CommunicationRequest;
071import ca.uhn.fhir.model.dstu2.valueset.CommunicationRequestStatusEnum;
072import ca.uhn.fhir.model.dstu2.valueset.CommunicationStatusEnum;
073import ca.uhn.fhir.model.dstu2.resource.Composition;
074import ca.uhn.fhir.model.dstu2.valueset.CompositionAttestationModeEnum;
075import ca.uhn.fhir.model.dstu2.valueset.CompositionStatusEnum;
076import ca.uhn.fhir.model.dstu2.valueset.ConceptMapEquivalenceEnum;
077import ca.uhn.fhir.model.dstu2.resource.Condition;
078import ca.uhn.fhir.model.dstu2.valueset.ConditionCategoryCodesEnum;
079import ca.uhn.fhir.model.dstu2.valueset.ConditionClinicalStatusCodesEnum;
080import ca.uhn.fhir.model.dstu2.valueset.ConditionVerificationStatusEnum;
081import ca.uhn.fhir.model.dstu2.valueset.ConditionalDeleteStatusEnum;
082import ca.uhn.fhir.model.dstu2.resource.Conformance;
083import ca.uhn.fhir.model.dstu2.valueset.ConformanceEventModeEnum;
084import ca.uhn.fhir.model.dstu2.valueset.ConformanceResourceStatusEnum;
085import ca.uhn.fhir.model.dstu2.valueset.ConformanceStatementKindEnum;
086import ca.uhn.fhir.model.dstu2.composite.ContactPointDt;
087import ca.uhn.fhir.model.dstu2.valueset.ContentTypeEnum;
088import ca.uhn.fhir.model.dstu2.resource.Contract;
089import ca.uhn.fhir.model.dstu2.resource.Coverage;
090import ca.uhn.fhir.model.dstu2.valueset.DataElementStringencyEnum;
091import ca.uhn.fhir.model.dstu2.valueset.DaysOfWeekEnum;
092import ca.uhn.fhir.model.dstu2.valueset.DetectedIssueSeverityEnum;
093import ca.uhn.fhir.model.dstu2.resource.Device;
094import ca.uhn.fhir.model.dstu2.resource.DeviceComponent;
095import ca.uhn.fhir.model.dstu2.resource.DeviceMetric;
096import ca.uhn.fhir.model.dstu2.valueset.DeviceMetricCalibrationStateEnum;
097import ca.uhn.fhir.model.dstu2.valueset.DeviceMetricCalibrationTypeEnum;
098import ca.uhn.fhir.model.dstu2.valueset.DeviceMetricCategoryEnum;
099import ca.uhn.fhir.model.dstu2.valueset.DeviceMetricColorEnum;
100import ca.uhn.fhir.model.dstu2.valueset.DeviceMetricOperationalStatusEnum;
101import ca.uhn.fhir.model.dstu2.valueset.DeviceStatusEnum;
102import ca.uhn.fhir.model.dstu2.resource.DeviceUseRequest;
103import ca.uhn.fhir.model.dstu2.valueset.DeviceUseRequestPriorityEnum;
104import ca.uhn.fhir.model.dstu2.valueset.DeviceUseRequestStatusEnum;
105import ca.uhn.fhir.model.dstu2.resource.DiagnosticOrder;
106import ca.uhn.fhir.model.dstu2.valueset.DiagnosticOrderPriorityEnum;
107import ca.uhn.fhir.model.dstu2.valueset.DiagnosticOrderStatusEnum;
108import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
109import ca.uhn.fhir.model.dstu2.valueset.DiagnosticReportStatusEnum;
110import ca.uhn.fhir.model.dstu2.valueset.DigitalMediaTypeEnum;
111import ca.uhn.fhir.model.dstu2.valueset.DocumentModeEnum;
112import ca.uhn.fhir.model.dstu2.resource.DocumentReference;
113import ca.uhn.fhir.model.dstu2.valueset.DocumentReferenceStatusEnum;
114import ca.uhn.fhir.model.dstu2.valueset.DocumentRelationshipTypeEnum;
115import ca.uhn.fhir.model.dstu2.composite.ElementDefinitionDt;
116import ca.uhn.fhir.model.dstu2.resource.EligibilityRequest;
117import ca.uhn.fhir.model.dstu2.resource.Encounter;
118import ca.uhn.fhir.model.dstu2.valueset.EncounterClassEnum;
119import ca.uhn.fhir.model.dstu2.valueset.EncounterLocationStatusEnum;
120import ca.uhn.fhir.model.dstu2.valueset.EncounterStateEnum;
121import ca.uhn.fhir.model.dstu2.resource.EnrollmentRequest;
122import ca.uhn.fhir.model.dstu2.resource.EpisodeOfCare;
123import ca.uhn.fhir.model.dstu2.valueset.EpisodeOfCareStatusEnum;
124import ca.uhn.fhir.model.dstu2.valueset.ExtensionContextEnum;
125import ca.uhn.fhir.model.dstu2.valueset.FamilyHistoryStatusEnum;
126import ca.uhn.fhir.model.dstu2.resource.FamilyMemberHistory;
127import ca.uhn.fhir.model.dstu2.valueset.FilterOperatorEnum;
128import ca.uhn.fhir.model.dstu2.valueset.FlagStatusEnum;
129import ca.uhn.fhir.model.dstu2.resource.Goal;
130import ca.uhn.fhir.model.dstu2.valueset.GoalPriorityEnum;
131import ca.uhn.fhir.model.dstu2.valueset.GoalStatusEnum;
132import ca.uhn.fhir.model.dstu2.resource.Group;
133import ca.uhn.fhir.model.dstu2.valueset.GroupTypeEnum;
134import ca.uhn.fhir.model.dstu2.valueset.GuideDependencyTypeEnum;
135import ca.uhn.fhir.model.dstu2.valueset.GuidePageKindEnum;
136import ca.uhn.fhir.model.dstu2.valueset.GuideResourcePurposeEnum;
137import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
138import ca.uhn.fhir.model.dstu2.resource.HealthcareService;
139import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
140import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
141import ca.uhn.fhir.model.dstu2.valueset.IdentifierTypeCodesEnum;
142import ca.uhn.fhir.model.dstu2.valueset.IdentityAssuranceLevelEnum;
143import ca.uhn.fhir.model.dstu2.resource.ImagingObjectSelection;
144import ca.uhn.fhir.model.dstu2.resource.ImagingStudy;
145import ca.uhn.fhir.model.dstu2.resource.Immunization;
146import ca.uhn.fhir.model.dstu2.valueset.InstanceAvailabilityEnum;
147import ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum;
148import ca.uhn.fhir.model.dstu2.valueset.IssueTypeEnum;
149import ca.uhn.fhir.model.dstu2.valueset.KOStitleEnum;
150import ca.uhn.fhir.model.dstu2.valueset.LinkTypeEnum;
151import ca.uhn.fhir.model.dstu2.valueset.ListModeEnum;
152import ca.uhn.fhir.model.dstu2.valueset.ListOrderCodesEnum;
153import ca.uhn.fhir.model.dstu2.valueset.ListStatusEnum;
154import ca.uhn.fhir.model.dstu2.resource.Location;
155import ca.uhn.fhir.model.dstu2.valueset.LocationModeEnum;
156import ca.uhn.fhir.model.dstu2.valueset.LocationStatusEnum;
157import ca.uhn.fhir.model.dstu2.valueset.LocationTypeEnum;
158import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
159import ca.uhn.fhir.model.dstu2.valueset.MeasmntPrincipleEnum;
160import ca.uhn.fhir.model.dstu2.resource.Media;
161import ca.uhn.fhir.model.dstu2.resource.Medication;
162import ca.uhn.fhir.model.dstu2.valueset.MedicationAdministrationStatusEnum;
163import ca.uhn.fhir.model.dstu2.valueset.MedicationDispenseStatusEnum;
164import ca.uhn.fhir.model.dstu2.resource.MedicationOrder;
165import ca.uhn.fhir.model.dstu2.valueset.MedicationOrderStatusEnum;
166import ca.uhn.fhir.model.dstu2.resource.MedicationStatement;
167import ca.uhn.fhir.model.dstu2.valueset.MedicationStatementStatusEnum;
168import ca.uhn.fhir.model.dstu2.valueset.MessageEventEnum;
169import ca.uhn.fhir.model.dstu2.valueset.MessageSignificanceCategoryEnum;
170import ca.uhn.fhir.model.dstu2.valueset.MessageTransportEnum;
171import ca.uhn.fhir.model.dstu2.resource.NamingSystem;
172import ca.uhn.fhir.model.dstu2.valueset.NamingSystemIdentifierTypeEnum;
173import ca.uhn.fhir.model.dstu2.valueset.NamingSystemTypeEnum;
174import ca.uhn.fhir.model.dstu2.valueset.NoteTypeEnum;
175import ca.uhn.fhir.model.dstu2.resource.NutritionOrder;
176import ca.uhn.fhir.model.dstu2.valueset.NutritionOrderStatusEnum;
177import ca.uhn.fhir.model.dstu2.resource.Observation;
178import ca.uhn.fhir.model.dstu2.valueset.ObservationRelationshipTypeEnum;
179import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
180import ca.uhn.fhir.model.dstu2.resource.OperationDefinition;
181import ca.uhn.fhir.model.dstu2.valueset.OperationKindEnum;
182import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
183import ca.uhn.fhir.model.dstu2.valueset.OperationParameterUseEnum;
184import ca.uhn.fhir.model.dstu2.resource.Order;
185import ca.uhn.fhir.model.dstu2.valueset.OrderStatusEnum;
186import ca.uhn.fhir.model.dstu2.resource.Organization;
187import ca.uhn.fhir.model.dstu2.valueset.ParticipantRequiredEnum;
188import ca.uhn.fhir.model.dstu2.valueset.ParticipantStatusEnum;
189import ca.uhn.fhir.model.dstu2.valueset.ParticipantTypeEnum;
190import ca.uhn.fhir.model.dstu2.valueset.ParticipationStatusEnum;
191import ca.uhn.fhir.model.dstu2.resource.Patient;
192import ca.uhn.fhir.model.dstu2.valueset.PayeeTypeCodesEnum;
193import ca.uhn.fhir.model.dstu2.composite.PeriodDt;
194import ca.uhn.fhir.model.dstu2.resource.Person;
195import ca.uhn.fhir.model.dstu2.resource.Practitioner;
196import ca.uhn.fhir.model.dstu2.resource.Procedure;
197import ca.uhn.fhir.model.dstu2.resource.ProcedureRequest;
198import ca.uhn.fhir.model.dstu2.valueset.ProcedureRequestPriorityEnum;
199import ca.uhn.fhir.model.dstu2.valueset.ProcedureRequestStatusEnum;
200import ca.uhn.fhir.model.dstu2.valueset.ProcedureStatusEnum;
201import ca.uhn.fhir.model.dstu2.resource.ProcessRequest;
202import ca.uhn.fhir.model.dstu2.valueset.ProvenanceEntityRoleEnum;
203import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
204import ca.uhn.fhir.model.dstu2.resource.Questionnaire;
205import ca.uhn.fhir.model.dstu2.resource.QuestionnaireResponse;
206import ca.uhn.fhir.model.dstu2.valueset.QuestionnaireResponseStatusEnum;
207import ca.uhn.fhir.model.dstu2.valueset.QuestionnaireStatusEnum;
208import ca.uhn.fhir.model.dstu2.composite.RangeDt;
209import ca.uhn.fhir.model.dstu2.composite.RatioDt;
210import ca.uhn.fhir.model.dstu2.valueset.ReferralMethodEnum;
211import ca.uhn.fhir.model.dstu2.resource.ReferralRequest;
212import ca.uhn.fhir.model.dstu2.valueset.ReferralStatusEnum;
213import ca.uhn.fhir.model.dstu2.resource.RelatedPerson;
214import ca.uhn.fhir.model.dstu2.valueset.RemittanceOutcomeEnum;
215import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
216import ca.uhn.fhir.model.dstu2.valueset.ResourceVersionPolicyEnum;
217import ca.uhn.fhir.model.dstu2.valueset.ResponseTypeEnum;
218import ca.uhn.fhir.model.dstu2.valueset.RestfulConformanceModeEnum;
219import ca.uhn.fhir.model.dstu2.valueset.RestfulSecurityServiceEnum;
220import ca.uhn.fhir.model.dstu2.resource.RiskAssessment;
221import ca.uhn.fhir.model.dstu2.valueset.RulesetCodesEnum;
222import ca.uhn.fhir.model.dstu2.composite.SampledDataDt;
223import ca.uhn.fhir.model.dstu2.resource.Schedule;
224import ca.uhn.fhir.model.dstu2.valueset.SearchEntryModeEnum;
225import ca.uhn.fhir.model.dstu2.valueset.SearchModifierCodeEnum;
226import ca.uhn.fhir.model.dstu2.valueset.SearchParamTypeEnum;
227import ca.uhn.fhir.model.dstu2.valueset.ServiceProvisionConditionsEnum;
228import ca.uhn.fhir.model.dstu2.composite.SignatureDt;
229import ca.uhn.fhir.model.dstu2.resource.Slot;
230import ca.uhn.fhir.model.dstu2.valueset.SlotStatusEnum;
231import ca.uhn.fhir.model.dstu2.resource.Specimen;
232import ca.uhn.fhir.model.dstu2.valueset.SpecimenStatusEnum;
233import ca.uhn.fhir.model.dstu2.resource.StructureDefinition;
234import ca.uhn.fhir.model.dstu2.valueset.StructureDefinitionKindEnum;
235import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum;
236import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
237import ca.uhn.fhir.model.dstu2.resource.Substance;
238import ca.uhn.fhir.model.dstu2.valueset.SubstanceCategoryCodesEnum;
239import ca.uhn.fhir.model.dstu2.valueset.SupplyDeliveryStatusEnum;
240import ca.uhn.fhir.model.dstu2.resource.SupplyRequest;
241import ca.uhn.fhir.model.dstu2.valueset.SupplyRequestStatusEnum;
242import ca.uhn.fhir.model.dstu2.valueset.SystemRestfulInteractionEnum;
243import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
244import ca.uhn.fhir.model.dstu2.composite.TimingDt;
245import ca.uhn.fhir.model.dstu2.valueset.TransactionModeEnum;
246import ca.uhn.fhir.model.dstu2.valueset.TypeRestfulInteractionEnum;
247import ca.uhn.fhir.model.dstu2.valueset.UnknownContentCodeEnum;
248import ca.uhn.fhir.model.dstu2.valueset.UseEnum;
249import ca.uhn.fhir.model.dstu2.resource.ValueSet;
250import ca.uhn.fhir.model.dstu2.valueset.VisionBaseEnum;
251import ca.uhn.fhir.model.dstu2.valueset.VisionEyesEnum;
252import ca.uhn.fhir.model.dstu2.resource.VisionPrescription;
253import ca.uhn.fhir.model.dstu2.valueset.XPathUsageTypeEnum;
254import ca.uhn.fhir.model.api.IResource;
255import ca.uhn.fhir.model.dstu2.composite.AgeDt;
256import ca.uhn.fhir.model.dstu2.composite.BoundCodeableConceptDt;
257import ca.uhn.fhir.model.dstu2.composite.DurationDt;
258import ca.uhn.fhir.model.dstu2.composite.MoneyDt;
259import ca.uhn.fhir.model.dstu2.composite.NarrativeDt;
260import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
261import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt;
262import ca.uhn.fhir.model.primitive.Base64BinaryDt;
263import ca.uhn.fhir.model.primitive.BooleanDt;
264import ca.uhn.fhir.model.primitive.BoundCodeDt;
265import ca.uhn.fhir.model.primitive.CodeDt;
266import ca.uhn.fhir.model.primitive.DateDt;
267import ca.uhn.fhir.model.primitive.DateTimeDt;
268import ca.uhn.fhir.model.primitive.DecimalDt;
269import ca.uhn.fhir.model.primitive.IdDt;
270import ca.uhn.fhir.model.primitive.InstantDt;
271import ca.uhn.fhir.model.primitive.IntegerDt;
272import ca.uhn.fhir.model.primitive.OidDt;
273import ca.uhn.fhir.model.primitive.PositiveIntDt;
274import ca.uhn.fhir.model.primitive.StringDt;
275import ca.uhn.fhir.model.primitive.TimeDt;
276import ca.uhn.fhir.model.primitive.UnsignedIntDt;
277import ca.uhn.fhir.model.primitive.UriDt;
278
279
280/**
281 * HAPI/FHIR <b>MedicationOrder</b> Resource
282 * (clinical.medication)
283 *
284 * <p>
285 * <b>Definition:</b>
286 * An order for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called \"MedicationOrder\" rather than \"MedicationPrescription\" to generalize the use across inpatient and outpatient settings as well as for care plans, etc.
287 * </p> 
288 *
289 * <p>
290 * <b>Requirements:</b>
291 * 
292 * </p> 
293 *
294 * <p>
295 * <b>Profile Definition:</b>
296 * <a href="http://hl7.org/fhir/profiles/MedicationOrder">http://hl7.org/fhir/profiles/MedicationOrder</a> 
297 * </p>
298 *
299 */
300@ResourceDef(name="MedicationOrder", profile="http://hl7.org/fhir/profiles/MedicationOrder", id="medicationorder")
301public class MedicationOrder extends ca.uhn.fhir.model.dstu2.resource.BaseResource
302    implements  IResource     {
303
304        /**
305         * Search parameter constant for <b>datewritten</b>
306         * <p>
307         * Description: <b>Return prescriptions written on this date</b><br>
308         * Type: <b>date</b><br>
309         * Path: <b>MedicationOrder.dateWritten</b><br>
310         * </p>
311         */
312        @SearchParamDefinition(name="datewritten", path="MedicationOrder.dateWritten", description="Return prescriptions written on this date", type="date"  )
313        public static final String SP_DATEWRITTEN = "datewritten";
314
315        /**
316         * <b>Fluent Client</b> search parameter constant for <b>datewritten</b>
317         * <p>
318         * Description: <b>Return prescriptions written on this date</b><br>
319         * Type: <b>date</b><br>
320         * Path: <b>MedicationOrder.dateWritten</b><br>
321         * </p>
322         */
323        public static final DateClientParam DATEWRITTEN = new DateClientParam(SP_DATEWRITTEN);
324
325        /**
326         * Search parameter constant for <b>encounter</b>
327         * <p>
328         * Description: <b>Return prescriptions with this encounter identifier</b><br>
329         * Type: <b>reference</b><br>
330         * Path: <b>MedicationOrder.encounter</b><br>
331         * </p>
332         */
333        @SearchParamDefinition(name="encounter", path="MedicationOrder.encounter", description="Return prescriptions with this encounter identifier", type="reference" , providesMembershipIn={
334 @Compartment(name="Encounter")         }
335 )
336        public static final String SP_ENCOUNTER = "encounter";
337
338        /**
339         * <b>Fluent Client</b> search parameter constant for <b>encounter</b>
340         * <p>
341         * Description: <b>Return prescriptions with this encounter identifier</b><br>
342         * Type: <b>reference</b><br>
343         * Path: <b>MedicationOrder.encounter</b><br>
344         * </p>
345         */
346        public static final ReferenceClientParam ENCOUNTER = new ReferenceClientParam(SP_ENCOUNTER);
347
348        /**
349         * Search parameter constant for <b>identifier</b>
350         * <p>
351         * Description: <b>Return prescriptions with this external identifier</b><br>
352         * Type: <b>token</b><br>
353         * Path: <b>MedicationOrder.identifier</b><br>
354         * </p>
355         */
356        @SearchParamDefinition(name="identifier", path="MedicationOrder.identifier", description="Return prescriptions with this external identifier", type="token"  )
357        public static final String SP_IDENTIFIER = "identifier";
358
359        /**
360         * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
361         * <p>
362         * Description: <b>Return prescriptions with this external identifier</b><br>
363         * Type: <b>token</b><br>
364         * Path: <b>MedicationOrder.identifier</b><br>
365         * </p>
366         */
367        public static final TokenClientParam IDENTIFIER = new TokenClientParam(SP_IDENTIFIER);
368
369        /**
370         * Search parameter constant for <b>medication</b>
371         * <p>
372         * Description: <b>Return administrations of this medication reference</b><br>
373         * Type: <b>reference</b><br>
374         * Path: <b>MedicationOrder.medicationReference</b><br>
375         * </p>
376         */
377        @SearchParamDefinition(name="medication", path="MedicationOrder.medicationReference", description="Return administrations of this medication reference", type="reference"  )
378        public static final String SP_MEDICATION = "medication";
379
380        /**
381         * <b>Fluent Client</b> search parameter constant for <b>medication</b>
382         * <p>
383         * Description: <b>Return administrations of this medication reference</b><br>
384         * Type: <b>reference</b><br>
385         * Path: <b>MedicationOrder.medicationReference</b><br>
386         * </p>
387         */
388        public static final ReferenceClientParam MEDICATION = new ReferenceClientParam(SP_MEDICATION);
389
390        /**
391         * Search parameter constant for <b>code</b>
392         * <p>
393         * Description: <b>Return administrations of this medication code</b><br>
394         * Type: <b>token</b><br>
395         * Path: <b>MedicationOrder.medicationCodeableConcept</b><br>
396         * </p>
397         */
398        @SearchParamDefinition(name="code", path="MedicationOrder.medicationCodeableConcept", description="Return administrations of this medication code", type="token"  )
399        public static final String SP_CODE = "code";
400
401        /**
402         * <b>Fluent Client</b> search parameter constant for <b>code</b>
403         * <p>
404         * Description: <b>Return administrations of this medication code</b><br>
405         * Type: <b>token</b><br>
406         * Path: <b>MedicationOrder.medicationCodeableConcept</b><br>
407         * </p>
408         */
409        public static final TokenClientParam CODE = new TokenClientParam(SP_CODE);
410
411        /**
412         * Search parameter constant for <b>patient</b>
413         * <p>
414         * Description: <b>The identity of a patient to list orders  for</b><br>
415         * Type: <b>reference</b><br>
416         * Path: <b>MedicationOrder.patient</b><br>
417         * </p>
418         */
419        @SearchParamDefinition(name="patient", path="MedicationOrder.patient", description="The identity of a patient to list orders  for", type="reference" , providesMembershipIn={
420 @Compartment(name="Patient")   }
421 )
422        public static final String SP_PATIENT = "patient";
423
424        /**
425         * <b>Fluent Client</b> search parameter constant for <b>patient</b>
426         * <p>
427         * Description: <b>The identity of a patient to list orders  for</b><br>
428         * Type: <b>reference</b><br>
429         * Path: <b>MedicationOrder.patient</b><br>
430         * </p>
431         */
432        public static final ReferenceClientParam PATIENT = new ReferenceClientParam(SP_PATIENT);
433
434        /**
435         * Search parameter constant for <b>status</b>
436         * <p>
437         * Description: <b>Status of the prescription</b><br>
438         * Type: <b>token</b><br>
439         * Path: <b>MedicationOrder.status</b><br>
440         * </p>
441         */
442        @SearchParamDefinition(name="status", path="MedicationOrder.status", description="Status of the prescription", type="token"  )
443        public static final String SP_STATUS = "status";
444
445        /**
446         * <b>Fluent Client</b> search parameter constant for <b>status</b>
447         * <p>
448         * Description: <b>Status of the prescription</b><br>
449         * Type: <b>token</b><br>
450         * Path: <b>MedicationOrder.status</b><br>
451         * </p>
452         */
453        public static final TokenClientParam STATUS = new TokenClientParam(SP_STATUS);
454
455        /**
456         * Search parameter constant for <b>prescriber</b>
457         * <p>
458         * Description: <b></b><br>
459         * Type: <b>reference</b><br>
460         * Path: <b>MedicationOrder.prescriber</b><br>
461         * </p>
462         */
463        @SearchParamDefinition(name="prescriber", path="MedicationOrder.prescriber", description="", type="reference" , providesMembershipIn={
464 @Compartment(name="RelatedPerson")     }
465 )
466        public static final String SP_PRESCRIBER = "prescriber";
467
468        /**
469         * <b>Fluent Client</b> search parameter constant for <b>prescriber</b>
470         * <p>
471         * Description: <b></b><br>
472         * Type: <b>reference</b><br>
473         * Path: <b>MedicationOrder.prescriber</b><br>
474         * </p>
475         */
476        public static final ReferenceClientParam PRESCRIBER = new ReferenceClientParam(SP_PRESCRIBER);
477
478
479        /**
480         * Constant for fluent queries to be used to add include statements. Specifies
481         * the path value of "<b>MedicationOrder:encounter</b>".
482         */
483        public static final Include INCLUDE_ENCOUNTER = new Include("MedicationOrder:encounter");
484
485        /**
486         * Constant for fluent queries to be used to add include statements. Specifies
487         * the path value of "<b>MedicationOrder:medication</b>".
488         */
489        public static final Include INCLUDE_MEDICATION = new Include("MedicationOrder:medication");
490
491        /**
492         * Constant for fluent queries to be used to add include statements. Specifies
493         * the path value of "<b>MedicationOrder:patient</b>".
494         */
495        public static final Include INCLUDE_PATIENT = new Include("MedicationOrder:patient");
496
497        /**
498         * Constant for fluent queries to be used to add include statements. Specifies
499         * the path value of "<b>MedicationOrder:prescriber</b>".
500         */
501        public static final Include INCLUDE_PRESCRIBER = new Include("MedicationOrder:prescriber");
502
503
504        @Child(name="identifier", type=IdentifierDt.class, order=0, min=0, max=Child.MAX_UNLIMITED, summary=false, modifier=false)      
505        @Description(
506                shortDefinition="id",
507                formalDefinition="External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system."
508        )
509        private java.util.List<IdentifierDt> myIdentifier;
510        
511        @Child(name="dateWritten", type=DateTimeDt.class, order=1, min=0, max=1, summary=false, modifier=false) 
512        @Description(
513                shortDefinition="when.recorded",
514                formalDefinition="The date (and perhaps time) when the prescription was written"
515        )
516        private DateTimeDt myDateWritten;
517        
518        @Child(name="status", type=CodeDt.class, order=2, min=0, max=1, summary=false, modifier=true)   
519        @Description(
520                shortDefinition="status",
521                formalDefinition="A code specifying the state of the order.  Generally this will be active or completed state"
522        )
523        @ca.uhn.fhir.model.api.annotation.Binding(valueSet = "http://hl7.org/fhir/ValueSet/medication-order-status")
524        private BoundCodeDt<MedicationOrderStatusEnum> myStatus;
525        
526        @Child(name="dateEnded", type=DateTimeDt.class, order=3, min=0, max=1, summary=false, modifier=false)   
527        @Description(
528                shortDefinition="",
529                formalDefinition="The date (and perhaps time) when the prescription was stopped"
530        )
531        private DateTimeDt myDateEnded;
532        
533        @Child(name="reasonEnded", type=CodeableConceptDt.class, order=4, min=0, max=1, summary=false, modifier=false)  
534        @Description(
535                shortDefinition="",
536                formalDefinition="The reason why the prescription was stopped, if it was"
537        )
538        private CodeableConceptDt myReasonEnded;
539        
540        @Child(name="patient", order=5, min=0, max=1, summary=false, modifier=false, type={
541                ca.uhn.fhir.model.dstu2.resource.Patient.class  })
542        @Description(
543                shortDefinition="who.focus",
544                formalDefinition="A link to a resource representing the person to whom the medication will be given."
545        )
546        private ResourceReferenceDt myPatient;
547        
548        @Child(name="prescriber", order=6, min=0, max=1, summary=false, modifier=false, type={
549                ca.uhn.fhir.model.dstu2.resource.Practitioner.class     })
550        @Description(
551                shortDefinition="who.actor",
552                formalDefinition="The healthcare professional responsible for authorizing the prescription"
553        )
554        private ResourceReferenceDt myPrescriber;
555        
556        @Child(name="encounter", order=7, min=0, max=1, summary=false, modifier=false, type={
557                ca.uhn.fhir.model.dstu2.resource.Encounter.class        })
558        @Description(
559                shortDefinition="context",
560                formalDefinition="A link to a resource that identifies the particular occurrence of contact between patient and health care provider."
561        )
562        private ResourceReferenceDt myEncounter;
563        
564        @Child(name="reason", order=8, min=0, max=1, summary=false, modifier=false, type={
565                CodeableConceptDt.class,                Condition.class })
566        @Description(
567                shortDefinition="why",
568                formalDefinition="Can be the reason or the indication for writing the prescription."
569        )
570        private IDatatype myReason;
571        
572        @Child(name="note", type=StringDt.class, order=9, min=0, max=1, summary=false, modifier=false)  
573        @Description(
574                shortDefinition="",
575                formalDefinition="Extra information about the prescription that could not be conveyed by the other attributes."
576        )
577        private StringDt myNote;
578        
579        @Child(name="medication", order=10, min=1, max=1, summary=false, modifier=false, type={
580                CodeableConceptDt.class,                Medication.class        })
581        @Description(
582                shortDefinition="what",
583                formalDefinition="Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications."
584        )
585        private IDatatype myMedication;
586        
587        @Child(name="dosageInstruction", order=11, min=0, max=Child.MAX_UNLIMITED, summary=false, modifier=false)       
588        @Description(
589                shortDefinition="",
590                formalDefinition="Indicates how the medication is to be used by the patient"
591        )
592        private java.util.List<DosageInstruction> myDosageInstruction;
593        
594        @Child(name="dispenseRequest", order=12, min=0, max=1, summary=false, modifier=false)   
595        @Description(
596                shortDefinition="",
597                formalDefinition="Indicates the specific details for the dispense or medication supply part of a medication order (also known as a Medication Prescription).  Note that this information is NOT always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department."
598        )
599        private DispenseRequest myDispenseRequest;
600        
601        @Child(name="substitution", order=13, min=0, max=1, summary=false, modifier=false)      
602        @Description(
603                shortDefinition="",
604                formalDefinition="Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen, and in others it does not matter. This block explains the prescriber's intent. If nothing is specified substitution may be done."
605        )
606        private Substitution mySubstitution;
607        
608        @Child(name="priorPrescription", order=14, min=0, max=1, summary=false, modifier=false, type={
609                ca.uhn.fhir.model.dstu2.resource.MedicationOrder.class  })
610        @Description(
611                shortDefinition="",
612                formalDefinition="A link to a resource representing an earlier order or prescription that this order supersedes"
613        )
614        private ResourceReferenceDt myPriorPrescription;
615        
616
617        @Override
618        public boolean isEmpty() {
619                return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  myIdentifier,  myDateWritten,  myStatus,  myDateEnded,  myReasonEnded,  myPatient,  myPrescriber,  myEncounter,  myReason,  myNote,  myMedication,  myDosageInstruction,  myDispenseRequest,  mySubstitution,  myPriorPrescription);
620        }
621        
622        @Override
623        public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
624                return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myIdentifier, myDateWritten, myStatus, myDateEnded, myReasonEnded, myPatient, myPrescriber, myEncounter, myReason, myNote, myMedication, myDosageInstruction, myDispenseRequest, mySubstitution, myPriorPrescription);
625        }
626
627        /**
628         * Gets the value(s) for <b>identifier</b> (id).
629         * creating it if it does
630         * not exist. Will not return <code>null</code>.
631         *
632     * <p>
633     * <b>Definition:</b>
634     * External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.
635     * </p> 
636         */
637        public java.util.List<IdentifierDt> getIdentifier() {  
638                if (myIdentifier == null) {
639                        myIdentifier = new java.util.ArrayList<IdentifierDt>();
640                }
641                return myIdentifier;
642        }
643
644        /**
645         * Sets the value(s) for <b>identifier</b> (id)
646         *
647     * <p>
648     * <b>Definition:</b>
649     * External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.
650     * </p> 
651         */
652        public MedicationOrder setIdentifier(java.util.List<IdentifierDt> theValue) {
653                myIdentifier = theValue;
654                return this;
655        }
656        
657        
658
659        /**
660         * Adds and returns a new value for <b>identifier</b> (id)
661         *
662     * <p>
663     * <b>Definition:</b>
664     * External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.
665     * </p> 
666         */
667        public IdentifierDt addIdentifier() {
668                IdentifierDt newType = new IdentifierDt();
669                getIdentifier().add(newType);
670                return newType; 
671        }
672
673        /**
674         * Adds a given new value for <b>identifier</b> (id)
675         *
676         * <p>
677         * <b>Definition:</b>
678         * External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.
679         * </p>
680         * @param theValue The identifier to add (must not be <code>null</code>)
681         */
682        public MedicationOrder addIdentifier(IdentifierDt theValue) {
683                if (theValue == null) {
684                        throw new NullPointerException("theValue must not be null");
685                }
686                getIdentifier().add(theValue);
687                return this;
688        }
689
690        /**
691         * Gets the first repetition for <b>identifier</b> (id),
692         * creating it if it does not already exist.
693         *
694     * <p>
695     * <b>Definition:</b>
696     * External identifier - one that would be used by another non-FHIR system - for example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records have to be tracked through an entire system.
697     * </p> 
698         */
699        public IdentifierDt getIdentifierFirstRep() {
700                if (getIdentifier().isEmpty()) {
701                        return addIdentifier();
702                }
703                return getIdentifier().get(0); 
704        }
705  
706        /**
707         * Gets the value(s) for <b>dateWritten</b> (when.recorded).
708         * creating it if it does
709         * not exist. Will not return <code>null</code>.
710         *
711     * <p>
712     * <b>Definition:</b>
713     * The date (and perhaps time) when the prescription was written
714     * </p> 
715         */
716        public DateTimeDt getDateWrittenElement() {  
717                if (myDateWritten == null) {
718                        myDateWritten = new DateTimeDt();
719                }
720                return myDateWritten;
721        }
722
723        
724        /**
725         * Gets the value(s) for <b>dateWritten</b> (when.recorded).
726         * creating it if it does
727         * not exist. This method may return <code>null</code>.
728         *
729     * <p>
730     * <b>Definition:</b>
731     * The date (and perhaps time) when the prescription was written
732     * </p> 
733         */
734        public Date getDateWritten() {  
735                return getDateWrittenElement().getValue();
736        }
737
738        /**
739         * Sets the value(s) for <b>dateWritten</b> (when.recorded)
740         *
741     * <p>
742     * <b>Definition:</b>
743     * The date (and perhaps time) when the prescription was written
744     * </p> 
745         */
746        public MedicationOrder setDateWritten(DateTimeDt theValue) {
747                myDateWritten = theValue;
748                return this;
749        }
750        
751        
752
753        /**
754         * Sets the value for <b>dateWritten</b> (when.recorded)
755         *
756     * <p>
757     * <b>Definition:</b>
758     * The date (and perhaps time) when the prescription was written
759     * </p> 
760         */
761        public MedicationOrder setDateWritten( Date theDate,  TemporalPrecisionEnum thePrecision) {
762                myDateWritten = new DateTimeDt(theDate, thePrecision); 
763                return this; 
764        }
765
766        /**
767         * Sets the value for <b>dateWritten</b> (when.recorded)
768         *
769     * <p>
770     * <b>Definition:</b>
771     * The date (and perhaps time) when the prescription was written
772     * </p> 
773         */
774        public MedicationOrder setDateWrittenWithSecondsPrecision( Date theDate) {
775                myDateWritten = new DateTimeDt(theDate); 
776                return this; 
777        }
778
779 
780        /**
781         * Gets the value(s) for <b>status</b> (status).
782         * creating it if it does
783         * not exist. Will not return <code>null</code>.
784         *
785     * <p>
786     * <b>Definition:</b>
787     * A code specifying the state of the order.  Generally this will be active or completed state
788     * </p> 
789         */
790        public BoundCodeDt<MedicationOrderStatusEnum> getStatusElement() {  
791                if (myStatus == null) {
792                        myStatus = new BoundCodeDt<MedicationOrderStatusEnum>(MedicationOrderStatusEnum.VALUESET_BINDER);
793                }
794                return myStatus;
795        }
796
797        
798        /**
799         * Gets the value(s) for <b>status</b> (status).
800         * creating it if it does
801         * not exist. This method may return <code>null</code>.
802         *
803     * <p>
804     * <b>Definition:</b>
805     * A code specifying the state of the order.  Generally this will be active or completed state
806     * </p> 
807         */
808        public String getStatus() {  
809                return getStatusElement().getValue();
810        }
811
812        /**
813         * Sets the value(s) for <b>status</b> (status)
814         *
815     * <p>
816     * <b>Definition:</b>
817     * A code specifying the state of the order.  Generally this will be active or completed state
818     * </p> 
819         */
820        public MedicationOrder setStatus(BoundCodeDt<MedicationOrderStatusEnum> theValue) {
821                myStatus = theValue;
822                return this;
823        }
824        
825        
826
827        /**
828         * Sets the value(s) for <b>status</b> (status)
829         *
830     * <p>
831     * <b>Definition:</b>
832     * A code specifying the state of the order.  Generally this will be active or completed state
833     * </p> 
834         */
835        public MedicationOrder setStatus(MedicationOrderStatusEnum theValue) {
836                setStatus(new BoundCodeDt<MedicationOrderStatusEnum>(MedicationOrderStatusEnum.VALUESET_BINDER, theValue));
837                
838/*
839                getStatusElement().setValueAsEnum(theValue);
840*/
841                return this;
842        }
843
844  
845        /**
846         * Gets the value(s) for <b>dateEnded</b> ().
847         * creating it if it does
848         * not exist. Will not return <code>null</code>.
849         *
850     * <p>
851     * <b>Definition:</b>
852     * The date (and perhaps time) when the prescription was stopped
853     * </p> 
854         */
855        public DateTimeDt getDateEndedElement() {  
856                if (myDateEnded == null) {
857                        myDateEnded = new DateTimeDt();
858                }
859                return myDateEnded;
860        }
861
862        
863        /**
864         * Gets the value(s) for <b>dateEnded</b> ().
865         * creating it if it does
866         * not exist. This method may return <code>null</code>.
867         *
868     * <p>
869     * <b>Definition:</b>
870     * The date (and perhaps time) when the prescription was stopped
871     * </p> 
872         */
873        public Date getDateEnded() {  
874                return getDateEndedElement().getValue();
875        }
876
877        /**
878         * Sets the value(s) for <b>dateEnded</b> ()
879         *
880     * <p>
881     * <b>Definition:</b>
882     * The date (and perhaps time) when the prescription was stopped
883     * </p> 
884         */
885        public MedicationOrder setDateEnded(DateTimeDt theValue) {
886                myDateEnded = theValue;
887                return this;
888        }
889        
890        
891
892        /**
893         * Sets the value for <b>dateEnded</b> ()
894         *
895     * <p>
896     * <b>Definition:</b>
897     * The date (and perhaps time) when the prescription was stopped
898     * </p> 
899         */
900        public MedicationOrder setDateEnded( Date theDate,  TemporalPrecisionEnum thePrecision) {
901                myDateEnded = new DateTimeDt(theDate, thePrecision); 
902                return this; 
903        }
904
905        /**
906         * Sets the value for <b>dateEnded</b> ()
907         *
908     * <p>
909     * <b>Definition:</b>
910     * The date (and perhaps time) when the prescription was stopped
911     * </p> 
912         */
913        public MedicationOrder setDateEndedWithSecondsPrecision( Date theDate) {
914                myDateEnded = new DateTimeDt(theDate); 
915                return this; 
916        }
917
918 
919        /**
920         * Gets the value(s) for <b>reasonEnded</b> ().
921         * creating it if it does
922         * not exist. Will not return <code>null</code>.
923         *
924     * <p>
925     * <b>Definition:</b>
926     * The reason why the prescription was stopped, if it was
927     * </p> 
928         */
929        public CodeableConceptDt getReasonEnded() {  
930                if (myReasonEnded == null) {
931                        myReasonEnded = new CodeableConceptDt();
932                }
933                return myReasonEnded;
934        }
935
936        /**
937         * Sets the value(s) for <b>reasonEnded</b> ()
938         *
939     * <p>
940     * <b>Definition:</b>
941     * The reason why the prescription was stopped, if it was
942     * </p> 
943         */
944        public MedicationOrder setReasonEnded(CodeableConceptDt theValue) {
945                myReasonEnded = theValue;
946                return this;
947        }
948        
949        
950
951  
952        /**
953         * Gets the value(s) for <b>patient</b> (who.focus).
954         * creating it if it does
955         * not exist. Will not return <code>null</code>.
956         *
957     * <p>
958     * <b>Definition:</b>
959     * A link to a resource representing the person to whom the medication will be given.
960     * </p> 
961         */
962        public ResourceReferenceDt getPatient() {  
963                if (myPatient == null) {
964                        myPatient = new ResourceReferenceDt();
965                }
966                return myPatient;
967        }
968
969        /**
970         * Sets the value(s) for <b>patient</b> (who.focus)
971         *
972     * <p>
973     * <b>Definition:</b>
974     * A link to a resource representing the person to whom the medication will be given.
975     * </p> 
976         */
977        public MedicationOrder setPatient(ResourceReferenceDt theValue) {
978                myPatient = theValue;
979                return this;
980        }
981        
982        
983
984  
985        /**
986         * Gets the value(s) for <b>prescriber</b> (who.actor).
987         * creating it if it does
988         * not exist. Will not return <code>null</code>.
989         *
990     * <p>
991     * <b>Definition:</b>
992     * The healthcare professional responsible for authorizing the prescription
993     * </p> 
994         */
995        public ResourceReferenceDt getPrescriber() {  
996                if (myPrescriber == null) {
997                        myPrescriber = new ResourceReferenceDt();
998                }
999                return myPrescriber;
1000        }
1001
1002        /**
1003         * Sets the value(s) for <b>prescriber</b> (who.actor)
1004         *
1005     * <p>
1006     * <b>Definition:</b>
1007     * The healthcare professional responsible for authorizing the prescription
1008     * </p> 
1009         */
1010        public MedicationOrder setPrescriber(ResourceReferenceDt theValue) {
1011                myPrescriber = theValue;
1012                return this;
1013        }
1014        
1015        
1016
1017  
1018        /**
1019         * Gets the value(s) for <b>encounter</b> (context).
1020         * creating it if it does
1021         * not exist. Will not return <code>null</code>.
1022         *
1023     * <p>
1024     * <b>Definition:</b>
1025     * A link to a resource that identifies the particular occurrence of contact between patient and health care provider.
1026     * </p> 
1027         */
1028        public ResourceReferenceDt getEncounter() {  
1029                if (myEncounter == null) {
1030                        myEncounter = new ResourceReferenceDt();
1031                }
1032                return myEncounter;
1033        }
1034
1035        /**
1036         * Sets the value(s) for <b>encounter</b> (context)
1037         *
1038     * <p>
1039     * <b>Definition:</b>
1040     * A link to a resource that identifies the particular occurrence of contact between patient and health care provider.
1041     * </p> 
1042         */
1043        public MedicationOrder setEncounter(ResourceReferenceDt theValue) {
1044                myEncounter = theValue;
1045                return this;
1046        }
1047        
1048        
1049
1050  
1051        /**
1052         * Gets the value(s) for <b>reason[x]</b> (why).
1053         * creating it if it does
1054         * not exist. Will not return <code>null</code>.
1055         *
1056     * <p>
1057     * <b>Definition:</b>
1058     * Can be the reason or the indication for writing the prescription.
1059     * </p> 
1060         */
1061        public IDatatype getReason() {  
1062                return myReason;
1063        }
1064
1065        /**
1066         * Sets the value(s) for <b>reason[x]</b> (why)
1067         *
1068     * <p>
1069     * <b>Definition:</b>
1070     * Can be the reason or the indication for writing the prescription.
1071     * </p> 
1072         */
1073        public MedicationOrder setReason(IDatatype theValue) {
1074                myReason = theValue;
1075                return this;
1076        }
1077        
1078        
1079
1080  
1081        /**
1082         * Gets the value(s) for <b>note</b> ().
1083         * creating it if it does
1084         * not exist. Will not return <code>null</code>.
1085         *
1086     * <p>
1087     * <b>Definition:</b>
1088     * Extra information about the prescription that could not be conveyed by the other attributes.
1089     * </p> 
1090         */
1091        public StringDt getNoteElement() {  
1092                if (myNote == null) {
1093                        myNote = new StringDt();
1094                }
1095                return myNote;
1096        }
1097
1098        
1099        /**
1100         * Gets the value(s) for <b>note</b> ().
1101         * creating it if it does
1102         * not exist. This method may return <code>null</code>.
1103         *
1104     * <p>
1105     * <b>Definition:</b>
1106     * Extra information about the prescription that could not be conveyed by the other attributes.
1107     * </p> 
1108         */
1109        public String getNote() {  
1110                return getNoteElement().getValue();
1111        }
1112
1113        /**
1114         * Sets the value(s) for <b>note</b> ()
1115         *
1116     * <p>
1117     * <b>Definition:</b>
1118     * Extra information about the prescription that could not be conveyed by the other attributes.
1119     * </p> 
1120         */
1121        public MedicationOrder setNote(StringDt theValue) {
1122                myNote = theValue;
1123                return this;
1124        }
1125        
1126        
1127
1128        /**
1129         * Sets the value for <b>note</b> ()
1130         *
1131     * <p>
1132     * <b>Definition:</b>
1133     * Extra information about the prescription that could not be conveyed by the other attributes.
1134     * </p> 
1135         */
1136        public MedicationOrder setNote( String theString) {
1137                myNote = new StringDt(theString); 
1138                return this; 
1139        }
1140
1141 
1142        /**
1143         * Gets the value(s) for <b>medication[x]</b> (what).
1144         * creating it if it does
1145         * not exist. Will not return <code>null</code>.
1146         *
1147     * <p>
1148     * <b>Definition:</b>
1149     * Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.
1150     * </p> 
1151         */
1152        public IDatatype getMedication() {  
1153                return myMedication;
1154        }
1155
1156        /**
1157         * Sets the value(s) for <b>medication[x]</b> (what)
1158         *
1159     * <p>
1160     * <b>Definition:</b>
1161     * Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.
1162     * </p> 
1163         */
1164        public MedicationOrder setMedication(IDatatype theValue) {
1165                myMedication = theValue;
1166                return this;
1167        }
1168        
1169        
1170
1171  
1172        /**
1173         * Gets the value(s) for <b>dosageInstruction</b> ().
1174         * creating it if it does
1175         * not exist. Will not return <code>null</code>.
1176         *
1177     * <p>
1178     * <b>Definition:</b>
1179     * Indicates how the medication is to be used by the patient
1180     * </p> 
1181         */
1182        public java.util.List<DosageInstruction> getDosageInstruction() {  
1183                if (myDosageInstruction == null) {
1184                        myDosageInstruction = new java.util.ArrayList<DosageInstruction>();
1185                }
1186                return myDosageInstruction;
1187        }
1188
1189        /**
1190         * Sets the value(s) for <b>dosageInstruction</b> ()
1191         *
1192     * <p>
1193     * <b>Definition:</b>
1194     * Indicates how the medication is to be used by the patient
1195     * </p> 
1196         */
1197        public MedicationOrder setDosageInstruction(java.util.List<DosageInstruction> theValue) {
1198                myDosageInstruction = theValue;
1199                return this;
1200        }
1201        
1202        
1203
1204        /**
1205         * Adds and returns a new value for <b>dosageInstruction</b> ()
1206         *
1207     * <p>
1208     * <b>Definition:</b>
1209     * Indicates how the medication is to be used by the patient
1210     * </p> 
1211         */
1212        public DosageInstruction addDosageInstruction() {
1213                DosageInstruction newType = new DosageInstruction();
1214                getDosageInstruction().add(newType);
1215                return newType; 
1216        }
1217
1218        /**
1219         * Adds a given new value for <b>dosageInstruction</b> ()
1220         *
1221         * <p>
1222         * <b>Definition:</b>
1223         * Indicates how the medication is to be used by the patient
1224         * </p>
1225         * @param theValue The dosageInstruction to add (must not be <code>null</code>)
1226         */
1227        public MedicationOrder addDosageInstruction(DosageInstruction theValue) {
1228                if (theValue == null) {
1229                        throw new NullPointerException("theValue must not be null");
1230                }
1231                getDosageInstruction().add(theValue);
1232                return this;
1233        }
1234
1235        /**
1236         * Gets the first repetition for <b>dosageInstruction</b> (),
1237         * creating it if it does not already exist.
1238         *
1239     * <p>
1240     * <b>Definition:</b>
1241     * Indicates how the medication is to be used by the patient
1242     * </p> 
1243         */
1244        public DosageInstruction getDosageInstructionFirstRep() {
1245                if (getDosageInstruction().isEmpty()) {
1246                        return addDosageInstruction();
1247                }
1248                return getDosageInstruction().get(0); 
1249        }
1250  
1251        /**
1252         * Gets the value(s) for <b>dispenseRequest</b> ().
1253         * creating it if it does
1254         * not exist. Will not return <code>null</code>.
1255         *
1256     * <p>
1257     * <b>Definition:</b>
1258     * Indicates the specific details for the dispense or medication supply part of a medication order (also known as a Medication Prescription).  Note that this information is NOT always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.
1259     * </p> 
1260         */
1261        public DispenseRequest getDispenseRequest() {  
1262                if (myDispenseRequest == null) {
1263                        myDispenseRequest = new DispenseRequest();
1264                }
1265                return myDispenseRequest;
1266        }
1267
1268        /**
1269         * Sets the value(s) for <b>dispenseRequest</b> ()
1270         *
1271     * <p>
1272     * <b>Definition:</b>
1273     * Indicates the specific details for the dispense or medication supply part of a medication order (also known as a Medication Prescription).  Note that this information is NOT always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.
1274     * </p> 
1275         */
1276        public MedicationOrder setDispenseRequest(DispenseRequest theValue) {
1277                myDispenseRequest = theValue;
1278                return this;
1279        }
1280        
1281        
1282
1283  
1284        /**
1285         * Gets the value(s) for <b>substitution</b> ().
1286         * creating it if it does
1287         * not exist. Will not return <code>null</code>.
1288         *
1289     * <p>
1290     * <b>Definition:</b>
1291     * Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen, and in others it does not matter. This block explains the prescriber's intent. If nothing is specified substitution may be done.
1292     * </p> 
1293         */
1294        public Substitution getSubstitution() {  
1295                if (mySubstitution == null) {
1296                        mySubstitution = new Substitution();
1297                }
1298                return mySubstitution;
1299        }
1300
1301        /**
1302         * Sets the value(s) for <b>substitution</b> ()
1303         *
1304     * <p>
1305     * <b>Definition:</b>
1306     * Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen, and in others it does not matter. This block explains the prescriber's intent. If nothing is specified substitution may be done.
1307     * </p> 
1308         */
1309        public MedicationOrder setSubstitution(Substitution theValue) {
1310                mySubstitution = theValue;
1311                return this;
1312        }
1313        
1314        
1315
1316  
1317        /**
1318         * Gets the value(s) for <b>priorPrescription</b> ().
1319         * creating it if it does
1320         * not exist. Will not return <code>null</code>.
1321         *
1322     * <p>
1323     * <b>Definition:</b>
1324     * A link to a resource representing an earlier order or prescription that this order supersedes
1325     * </p> 
1326         */
1327        public ResourceReferenceDt getPriorPrescription() {  
1328                if (myPriorPrescription == null) {
1329                        myPriorPrescription = new ResourceReferenceDt();
1330                }
1331                return myPriorPrescription;
1332        }
1333
1334        /**
1335         * Sets the value(s) for <b>priorPrescription</b> ()
1336         *
1337     * <p>
1338     * <b>Definition:</b>
1339     * A link to a resource representing an earlier order or prescription that this order supersedes
1340     * </p> 
1341         */
1342        public MedicationOrder setPriorPrescription(ResourceReferenceDt theValue) {
1343                myPriorPrescription = theValue;
1344                return this;
1345        }
1346        
1347        
1348
1349  
1350        /**
1351         * Block class for child element: <b>MedicationOrder.dosageInstruction</b> ()
1352         *
1353     * <p>
1354     * <b>Definition:</b>
1355     * Indicates how the medication is to be used by the patient
1356     * </p> 
1357         */
1358        @Block()        
1359        public static class DosageInstruction 
1360            extends  BaseIdentifiableElement        implements IResourceBlock {
1361        
1362        @Child(name="text", type=StringDt.class, order=0, min=0, max=1, summary=false, modifier=false)  
1363        @Description(
1364                shortDefinition="",
1365                formalDefinition="Free text dosage instructions can be used for cases where the instructions are too complex to code.  The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated.  If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing."
1366        )
1367        private StringDt myText;
1368        
1369        @Child(name="additionalInstructions", type=CodeableConceptDt.class, order=1, min=0, max=1, summary=false, modifier=false)       
1370        @Description(
1371                shortDefinition="",
1372                formalDefinition="Additional instructions such as \"Swallow with plenty of water\" which may or may not be coded."
1373        )
1374        private CodeableConceptDt myAdditionalInstructions;
1375        
1376        @Child(name="timing", type=TimingDt.class, order=2, min=0, max=1, summary=false, modifier=false)        
1377        @Description(
1378                shortDefinition="",
1379                formalDefinition="The timing schedule for giving the medication to the patient. The Schedule data type allows many different expressions. For example: \"Every 8 hours\"; \"Three times a day\"; \"1/2 an hour before breakfast for 10 days from 23-Dec 2011:\"; \"15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\"."
1380        )
1381        private TimingDt myTiming;
1382        
1383        @Child(name="asNeeded", order=3, min=0, max=1, summary=false, modifier=false, type={
1384                BooleanDt.class,                CodeableConceptDt.class })
1385        @Description(
1386                shortDefinition="",
1387                formalDefinition="Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept)."
1388        )
1389        private IDatatype myAsNeeded;
1390        
1391        @Child(name="site", order=4, min=0, max=1, summary=false, modifier=false, type={
1392                CodeableConceptDt.class,                BodySite.class  })
1393        @Description(
1394                shortDefinition="",
1395                formalDefinition="A coded specification of the anatomic site where the medication first enters the body"
1396        )
1397        private IDatatype mySite;
1398        
1399        @Child(name="route", type=CodeableConceptDt.class, order=5, min=0, max=1, summary=false, modifier=false)        
1400        @Description(
1401                shortDefinition="",
1402                formalDefinition="A code specifying the route or physiological path of administration of a therapeutic agent into or onto a patient's body."
1403        )
1404        private CodeableConceptDt myRoute;
1405        
1406        @Child(name="method", type=CodeableConceptDt.class, order=6, min=0, max=1, summary=false, modifier=false)       
1407        @Description(
1408                shortDefinition="",
1409                formalDefinition="A coded value indicating the method by which the medication is introduced into or onto the body. Most commonly used for injections.  For examples, Slow Push; Deep IV."
1410        )
1411        private CodeableConceptDt myMethod;
1412        
1413        @Child(name="dose", order=7, min=0, max=1, summary=false, modifier=false, type={
1414                RangeDt.class,          SimpleQuantityDt.class  })
1415        @Description(
1416                shortDefinition="",
1417                formalDefinition="The amount of therapeutic or other substance given at one administration event."
1418        )
1419        private IDatatype myDose;
1420        
1421        @Child(name="rate", order=8, min=0, max=1, summary=false, modifier=false, type={
1422                RatioDt.class,          RangeDt.class   })
1423        @Description(
1424                shortDefinition="",
1425                formalDefinition="Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours"
1426        )
1427        private IDatatype myRate;
1428        
1429        @Child(name="maxDosePerPeriod", type=RatioDt.class, order=9, min=0, max=1, summary=false, modifier=false)       
1430        @Description(
1431                shortDefinition="",
1432                formalDefinition="The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours."
1433        )
1434        private RatioDt myMaxDosePerPeriod;
1435        
1436
1437        @Override
1438        public boolean isEmpty() {
1439                return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  myText,  myAdditionalInstructions,  myTiming,  myAsNeeded,  mySite,  myRoute,  myMethod,  myDose,  myRate,  myMaxDosePerPeriod);
1440        }
1441        
1442        @Override
1443        public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
1444                return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myText, myAdditionalInstructions, myTiming, myAsNeeded, mySite, myRoute, myMethod, myDose, myRate, myMaxDosePerPeriod);
1445        }
1446
1447        /**
1448         * Gets the value(s) for <b>text</b> ().
1449         * creating it if it does
1450         * not exist. Will not return <code>null</code>.
1451         *
1452     * <p>
1453     * <b>Definition:</b>
1454     * Free text dosage instructions can be used for cases where the instructions are too complex to code.  The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated.  If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing.
1455     * </p> 
1456         */
1457        public StringDt getTextElement() {  
1458                if (myText == null) {
1459                        myText = new StringDt();
1460                }
1461                return myText;
1462        }
1463
1464        
1465        /**
1466         * Gets the value(s) for <b>text</b> ().
1467         * creating it if it does
1468         * not exist. This method may return <code>null</code>.
1469         *
1470     * <p>
1471     * <b>Definition:</b>
1472     * Free text dosage instructions can be used for cases where the instructions are too complex to code.  The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated.  If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing.
1473     * </p> 
1474         */
1475        public String getText() {  
1476                return getTextElement().getValue();
1477        }
1478
1479        /**
1480         * Sets the value(s) for <b>text</b> ()
1481         *
1482     * <p>
1483     * <b>Definition:</b>
1484     * Free text dosage instructions can be used for cases where the instructions are too complex to code.  The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated.  If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing.
1485     * </p> 
1486         */
1487        public DosageInstruction setText(StringDt theValue) {
1488                myText = theValue;
1489                return this;
1490        }
1491        
1492        
1493
1494        /**
1495         * Sets the value for <b>text</b> ()
1496         *
1497     * <p>
1498     * <b>Definition:</b>
1499     * Free text dosage instructions can be used for cases where the instructions are too complex to code.  The content of this attribute does not include the name or description of the medication. When coded instructions are present, the free text instructions may still be present for display to humans taking or administering the medication. It is expected that the text instructions will always be populated.  If the dosage.timing attribute is also populated, then the dosage.text should reflect the same information as the timing.
1500     * </p> 
1501         */
1502        public DosageInstruction setText( String theString) {
1503                myText = new StringDt(theString); 
1504                return this; 
1505        }
1506
1507 
1508        /**
1509         * Gets the value(s) for <b>additionalInstructions</b> ().
1510         * creating it if it does
1511         * not exist. Will not return <code>null</code>.
1512         *
1513     * <p>
1514     * <b>Definition:</b>
1515     * Additional instructions such as \&quot;Swallow with plenty of water\&quot; which may or may not be coded.
1516     * </p> 
1517         */
1518        public CodeableConceptDt getAdditionalInstructions() {  
1519                if (myAdditionalInstructions == null) {
1520                        myAdditionalInstructions = new CodeableConceptDt();
1521                }
1522                return myAdditionalInstructions;
1523        }
1524
1525        /**
1526         * Sets the value(s) for <b>additionalInstructions</b> ()
1527         *
1528     * <p>
1529     * <b>Definition:</b>
1530     * Additional instructions such as \&quot;Swallow with plenty of water\&quot; which may or may not be coded.
1531     * </p> 
1532         */
1533        public DosageInstruction setAdditionalInstructions(CodeableConceptDt theValue) {
1534                myAdditionalInstructions = theValue;
1535                return this;
1536        }
1537        
1538        
1539
1540  
1541        /**
1542         * Gets the value(s) for <b>timing</b> ().
1543         * creating it if it does
1544         * not exist. Will not return <code>null</code>.
1545         *
1546     * <p>
1547     * <b>Definition:</b>
1548     * The timing schedule for giving the medication to the patient. The Schedule data type allows many different expressions. For example: \&quot;Every 8 hours\&quot;; \&quot;Three times a day\&quot;; \&quot;1/2 an hour before breakfast for 10 days from 23-Dec 2011:\&quot;; \&quot;15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\&quot;.
1549     * </p> 
1550         */
1551        public TimingDt getTiming() {  
1552                if (myTiming == null) {
1553                        myTiming = new TimingDt();
1554                }
1555                return myTiming;
1556        }
1557
1558        /**
1559         * Sets the value(s) for <b>timing</b> ()
1560         *
1561     * <p>
1562     * <b>Definition:</b>
1563     * The timing schedule for giving the medication to the patient. The Schedule data type allows many different expressions. For example: \&quot;Every 8 hours\&quot;; \&quot;Three times a day\&quot;; \&quot;1/2 an hour before breakfast for 10 days from 23-Dec 2011:\&quot;; \&quot;15 Oct 2013, 17 Oct 2013 and 1 Nov 2013\&quot;.
1564     * </p> 
1565         */
1566        public DosageInstruction setTiming(TimingDt theValue) {
1567                myTiming = theValue;
1568                return this;
1569        }
1570        
1571        
1572
1573  
1574        /**
1575         * Gets the value(s) for <b>asNeeded[x]</b> ().
1576         * creating it if it does
1577         * not exist. Will not return <code>null</code>.
1578         *
1579     * <p>
1580     * <b>Definition:</b>
1581     * Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).
1582     * </p> 
1583         */
1584        public IDatatype getAsNeeded() {  
1585                return myAsNeeded;
1586        }
1587
1588        /**
1589         * Sets the value(s) for <b>asNeeded[x]</b> ()
1590         *
1591     * <p>
1592     * <b>Definition:</b>
1593     * Indicates whether the Medication is only taken when needed within a specific dosing schedule (Boolean option), or it indicates the precondition for taking the Medication (CodeableConcept).
1594     * </p> 
1595         */
1596        public DosageInstruction setAsNeeded(IDatatype theValue) {
1597                myAsNeeded = theValue;
1598                return this;
1599        }
1600        
1601        
1602
1603  
1604        /**
1605         * Gets the value(s) for <b>site[x]</b> ().
1606         * creating it if it does
1607         * not exist. Will not return <code>null</code>.
1608         *
1609     * <p>
1610     * <b>Definition:</b>
1611     * A coded specification of the anatomic site where the medication first enters the body
1612     * </p> 
1613         */
1614        public IDatatype getSite() {  
1615                return mySite;
1616        }
1617
1618        /**
1619         * Sets the value(s) for <b>site[x]</b> ()
1620         *
1621     * <p>
1622     * <b>Definition:</b>
1623     * A coded specification of the anatomic site where the medication first enters the body
1624     * </p> 
1625         */
1626        public DosageInstruction setSite(IDatatype theValue) {
1627                mySite = theValue;
1628                return this;
1629        }
1630        
1631        
1632
1633  
1634        /**
1635         * Gets the value(s) for <b>route</b> ().
1636         * creating it if it does
1637         * not exist. Will not return <code>null</code>.
1638         *
1639     * <p>
1640     * <b>Definition:</b>
1641     * A code specifying the route or physiological path of administration of a therapeutic agent into or onto a patient's body.
1642     * </p> 
1643         */
1644        public CodeableConceptDt getRoute() {  
1645                if (myRoute == null) {
1646                        myRoute = new CodeableConceptDt();
1647                }
1648                return myRoute;
1649        }
1650
1651        /**
1652         * Sets the value(s) for <b>route</b> ()
1653         *
1654     * <p>
1655     * <b>Definition:</b>
1656     * A code specifying the route or physiological path of administration of a therapeutic agent into or onto a patient's body.
1657     * </p> 
1658         */
1659        public DosageInstruction setRoute(CodeableConceptDt theValue) {
1660                myRoute = theValue;
1661                return this;
1662        }
1663        
1664        
1665
1666  
1667        /**
1668         * Gets the value(s) for <b>method</b> ().
1669         * creating it if it does
1670         * not exist. Will not return <code>null</code>.
1671         *
1672     * <p>
1673     * <b>Definition:</b>
1674     * A coded value indicating the method by which the medication is introduced into or onto the body. Most commonly used for injections.  For examples, Slow Push; Deep IV.
1675     * </p> 
1676         */
1677        public CodeableConceptDt getMethod() {  
1678                if (myMethod == null) {
1679                        myMethod = new CodeableConceptDt();
1680                }
1681                return myMethod;
1682        }
1683
1684        /**
1685         * Sets the value(s) for <b>method</b> ()
1686         *
1687     * <p>
1688     * <b>Definition:</b>
1689     * A coded value indicating the method by which the medication is introduced into or onto the body. Most commonly used for injections.  For examples, Slow Push; Deep IV.
1690     * </p> 
1691         */
1692        public DosageInstruction setMethod(CodeableConceptDt theValue) {
1693                myMethod = theValue;
1694                return this;
1695        }
1696        
1697        
1698
1699  
1700        /**
1701         * Gets the value(s) for <b>dose[x]</b> ().
1702         * creating it if it does
1703         * not exist. Will not return <code>null</code>.
1704         *
1705     * <p>
1706     * <b>Definition:</b>
1707     * The amount of therapeutic or other substance given at one administration event.
1708     * </p> 
1709         */
1710        public IDatatype getDose() {  
1711                return myDose;
1712        }
1713
1714        /**
1715         * Sets the value(s) for <b>dose[x]</b> ()
1716         *
1717     * <p>
1718     * <b>Definition:</b>
1719     * The amount of therapeutic or other substance given at one administration event.
1720     * </p> 
1721         */
1722        public DosageInstruction setDose(IDatatype theValue) {
1723                myDose = theValue;
1724                return this;
1725        }
1726        
1727        
1728
1729  
1730        /**
1731         * Gets the value(s) for <b>rate[x]</b> ().
1732         * creating it if it does
1733         * not exist. Will not return <code>null</code>.
1734         *
1735     * <p>
1736     * <b>Definition:</b>
1737     * Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours
1738     * </p> 
1739         */
1740        public IDatatype getRate() {  
1741                return myRate;
1742        }
1743
1744        /**
1745         * Sets the value(s) for <b>rate[x]</b> ()
1746         *
1747     * <p>
1748     * <b>Definition:</b>
1749     * Identifies the speed with which the medication was or will be introduced into the patient. Typically the rate for an infusion e.g. 100 ml per 1 hour or 100 ml/hr.  May also be expressed as a rate per unit of time e.g. 500 ml per 2 hours.   Currently we do not specify a default of '1' in the denominator, but this is being discussed. Other examples: 200 mcg/min or 200 mcg/1 minute; 1 liter/8 hours
1750     * </p> 
1751         */
1752        public DosageInstruction setRate(IDatatype theValue) {
1753                myRate = theValue;
1754                return this;
1755        }
1756        
1757        
1758
1759  
1760        /**
1761         * Gets the value(s) for <b>maxDosePerPeriod</b> ().
1762         * creating it if it does
1763         * not exist. Will not return <code>null</code>.
1764         *
1765     * <p>
1766     * <b>Definition:</b>
1767     * The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours.
1768     * </p> 
1769         */
1770        public RatioDt getMaxDosePerPeriod() {  
1771                if (myMaxDosePerPeriod == null) {
1772                        myMaxDosePerPeriod = new RatioDt();
1773                }
1774                return myMaxDosePerPeriod;
1775        }
1776
1777        /**
1778         * Sets the value(s) for <b>maxDosePerPeriod</b> ()
1779         *
1780     * <p>
1781     * <b>Definition:</b>
1782     * The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time.  For example, 1000mg in 24 hours.
1783     * </p> 
1784         */
1785        public DosageInstruction setMaxDosePerPeriod(RatioDt theValue) {
1786                myMaxDosePerPeriod = theValue;
1787                return this;
1788        }
1789        
1790        
1791
1792  
1793
1794
1795        }
1796
1797
1798        /**
1799         * Block class for child element: <b>MedicationOrder.dispenseRequest</b> ()
1800         *
1801     * <p>
1802     * <b>Definition:</b>
1803     * Indicates the specific details for the dispense or medication supply part of a medication order (also known as a Medication Prescription).  Note that this information is NOT always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.
1804     * </p> 
1805         */
1806        @Block()        
1807        public static class DispenseRequest 
1808            extends  BaseIdentifiableElement        implements IResourceBlock {
1809        
1810        @Child(name="medication", order=0, min=0, max=1, summary=false, modifier=false, type={
1811                CodeableConceptDt.class,                Medication.class        })
1812        @Description(
1813                shortDefinition="",
1814                formalDefinition="Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications."
1815        )
1816        private IDatatype myMedication;
1817        
1818        @Child(name="validityPeriod", type=PeriodDt.class, order=1, min=0, max=1, summary=false, modifier=false)        
1819        @Description(
1820                shortDefinition="",
1821                formalDefinition="This indicates the validity period of a prescription (stale dating the Prescription)"
1822        )
1823        private PeriodDt myValidityPeriod;
1824        
1825        @Child(name="numberOfRepeatsAllowed", type=PositiveIntDt.class, order=2, min=0, max=1, summary=false, modifier=false)   
1826        @Description(
1827                shortDefinition="",
1828                formalDefinition="An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication.   Usage Notes: This integer does NOT include the original order dispense.   This means that if an order indicates dispense 30 tablets plus  \"3 repeats\", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets."
1829        )
1830        private PositiveIntDt myNumberOfRepeatsAllowed;
1831        
1832        @Child(name="quantity", type=SimpleQuantityDt.class, order=3, min=0, max=1, summary=false, modifier=false)      
1833        @Description(
1834                shortDefinition="",
1835                formalDefinition="The amount that is to be dispensed for one fill."
1836        )
1837        private SimpleQuantityDt myQuantity;
1838        
1839        @Child(name="expectedSupplyDuration", type=DurationDt.class, order=4, min=0, max=1, summary=false, modifier=false)      
1840        @Description(
1841                shortDefinition="",
1842                formalDefinition="Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last."
1843        )
1844        private DurationDt myExpectedSupplyDuration;
1845        
1846
1847        @Override
1848        public boolean isEmpty() {
1849                return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  myMedication,  myValidityPeriod,  myNumberOfRepeatsAllowed,  myQuantity,  myExpectedSupplyDuration);
1850        }
1851        
1852        @Override
1853        public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
1854                return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myMedication, myValidityPeriod, myNumberOfRepeatsAllowed, myQuantity, myExpectedSupplyDuration);
1855        }
1856
1857        /**
1858         * Gets the value(s) for <b>medication[x]</b> ().
1859         * creating it if it does
1860         * not exist. Will not return <code>null</code>.
1861         *
1862     * <p>
1863     * <b>Definition:</b>
1864     * Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.
1865     * </p> 
1866         */
1867        public IDatatype getMedication() {  
1868                return myMedication;
1869        }
1870
1871        /**
1872         * Sets the value(s) for <b>medication[x]</b> ()
1873         *
1874     * <p>
1875     * <b>Definition:</b>
1876     * Identifies the medication being administered. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.
1877     * </p> 
1878         */
1879        public DispenseRequest setMedication(IDatatype theValue) {
1880                myMedication = theValue;
1881                return this;
1882        }
1883        
1884        
1885
1886  
1887        /**
1888         * Gets the value(s) for <b>validityPeriod</b> ().
1889         * creating it if it does
1890         * not exist. Will not return <code>null</code>.
1891         *
1892     * <p>
1893     * <b>Definition:</b>
1894     * This indicates the validity period of a prescription (stale dating the Prescription)
1895     * </p> 
1896         */
1897        public PeriodDt getValidityPeriod() {  
1898                if (myValidityPeriod == null) {
1899                        myValidityPeriod = new PeriodDt();
1900                }
1901                return myValidityPeriod;
1902        }
1903
1904        /**
1905         * Sets the value(s) for <b>validityPeriod</b> ()
1906         *
1907     * <p>
1908     * <b>Definition:</b>
1909     * This indicates the validity period of a prescription (stale dating the Prescription)
1910     * </p> 
1911         */
1912        public DispenseRequest setValidityPeriod(PeriodDt theValue) {
1913                myValidityPeriod = theValue;
1914                return this;
1915        }
1916        
1917        
1918
1919  
1920        /**
1921         * Gets the value(s) for <b>numberOfRepeatsAllowed</b> ().
1922         * creating it if it does
1923         * not exist. Will not return <code>null</code>.
1924         *
1925     * <p>
1926     * <b>Definition:</b>
1927     * An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication.   Usage Notes: This integer does NOT include the original order dispense.   This means that if an order indicates dispense 30 tablets plus  \&quot;3 repeats\&quot;, then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
1928     * </p> 
1929         */
1930        public PositiveIntDt getNumberOfRepeatsAllowedElement() {  
1931                if (myNumberOfRepeatsAllowed == null) {
1932                        myNumberOfRepeatsAllowed = new PositiveIntDt();
1933                }
1934                return myNumberOfRepeatsAllowed;
1935        }
1936
1937        
1938        /**
1939         * Gets the value(s) for <b>numberOfRepeatsAllowed</b> ().
1940         * creating it if it does
1941         * not exist. This method may return <code>null</code>.
1942         *
1943     * <p>
1944     * <b>Definition:</b>
1945     * An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication.   Usage Notes: This integer does NOT include the original order dispense.   This means that if an order indicates dispense 30 tablets plus  \&quot;3 repeats\&quot;, then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
1946     * </p> 
1947         */
1948        public Integer getNumberOfRepeatsAllowed() {  
1949                return getNumberOfRepeatsAllowedElement().getValue();
1950        }
1951
1952        /**
1953         * Sets the value(s) for <b>numberOfRepeatsAllowed</b> ()
1954         *
1955     * <p>
1956     * <b>Definition:</b>
1957     * An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication.   Usage Notes: This integer does NOT include the original order dispense.   This means that if an order indicates dispense 30 tablets plus  \&quot;3 repeats\&quot;, then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
1958     * </p> 
1959         */
1960        public DispenseRequest setNumberOfRepeatsAllowed(PositiveIntDt theValue) {
1961                myNumberOfRepeatsAllowed = theValue;
1962                return this;
1963        }
1964        
1965        
1966
1967        /**
1968         * Sets the value for <b>numberOfRepeatsAllowed</b> ()
1969         *
1970     * <p>
1971     * <b>Definition:</b>
1972     * An integer indicating the number of additional times (aka refills or repeats) the patient can receive the prescribed medication.   Usage Notes: This integer does NOT include the original order dispense.   This means that if an order indicates dispense 30 tablets plus  \&quot;3 repeats\&quot;, then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.
1973     * </p> 
1974         */
1975        public DispenseRequest setNumberOfRepeatsAllowed( int theInteger) {
1976                myNumberOfRepeatsAllowed = new PositiveIntDt(theInteger); 
1977                return this; 
1978        }
1979
1980 
1981        /**
1982         * Gets the value(s) for <b>quantity</b> ().
1983         * creating it if it does
1984         * not exist. Will not return <code>null</code>.
1985         *
1986     * <p>
1987     * <b>Definition:</b>
1988     * The amount that is to be dispensed for one fill.
1989     * </p> 
1990         */
1991        public SimpleQuantityDt getQuantity() {  
1992                if (myQuantity == null) {
1993                        myQuantity = new SimpleQuantityDt();
1994                }
1995                return myQuantity;
1996        }
1997
1998        /**
1999         * Sets the value(s) for <b>quantity</b> ()
2000         *
2001     * <p>
2002     * <b>Definition:</b>
2003     * The amount that is to be dispensed for one fill.
2004     * </p> 
2005         */
2006        public DispenseRequest setQuantity(SimpleQuantityDt theValue) {
2007                myQuantity = theValue;
2008                return this;
2009        }
2010        
2011        
2012
2013  
2014        /**
2015         * Gets the value(s) for <b>expectedSupplyDuration</b> ().
2016         * creating it if it does
2017         * not exist. Will not return <code>null</code>.
2018         *
2019     * <p>
2020     * <b>Definition:</b>
2021     * Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.
2022     * </p> 
2023         */
2024        public DurationDt getExpectedSupplyDuration() {  
2025                if (myExpectedSupplyDuration == null) {
2026                        myExpectedSupplyDuration = new DurationDt();
2027                }
2028                return myExpectedSupplyDuration;
2029        }
2030
2031        /**
2032         * Sets the value(s) for <b>expectedSupplyDuration</b> ()
2033         *
2034     * <p>
2035     * <b>Definition:</b>
2036     * Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.
2037     * </p> 
2038         */
2039        public DispenseRequest setExpectedSupplyDuration(DurationDt theValue) {
2040                myExpectedSupplyDuration = theValue;
2041                return this;
2042        }
2043        
2044        
2045
2046  
2047
2048
2049        }
2050
2051
2052        /**
2053         * Block class for child element: <b>MedicationOrder.substitution</b> ()
2054         *
2055     * <p>
2056     * <b>Definition:</b>
2057     * Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen, and in others it does not matter. This block explains the prescriber's intent. If nothing is specified substitution may be done.
2058     * </p> 
2059         */
2060        @Block()        
2061        public static class Substitution 
2062            extends  BaseIdentifiableElement        implements IResourceBlock {
2063        
2064        @Child(name="type", type=CodeableConceptDt.class, order=0, min=1, max=1, summary=false, modifier=false) 
2065        @Description(
2066                shortDefinition="",
2067                formalDefinition="A code signifying whether a different drug should be dispensed from what was prescribed."
2068        )
2069        private CodeableConceptDt myType;
2070        
2071        @Child(name="reason", type=CodeableConceptDt.class, order=1, min=0, max=1, summary=false, modifier=false)       
2072        @Description(
2073                shortDefinition="",
2074                formalDefinition="Indicates the reason for the substitution, or why substitution must or must not be performed."
2075        )
2076        private CodeableConceptDt myReason;
2077        
2078
2079        @Override
2080        public boolean isEmpty() {
2081                return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(  myType,  myReason);
2082        }
2083        
2084        @Override
2085        public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
2086                return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myType, myReason);
2087        }
2088
2089        /**
2090         * Gets the value(s) for <b>type</b> ().
2091         * creating it if it does
2092         * not exist. Will not return <code>null</code>.
2093         *
2094     * <p>
2095     * <b>Definition:</b>
2096     * A code signifying whether a different drug should be dispensed from what was prescribed.
2097     * </p> 
2098         */
2099        public CodeableConceptDt getType() {  
2100                if (myType == null) {
2101                        myType = new CodeableConceptDt();
2102                }
2103                return myType;
2104        }
2105
2106        /**
2107         * Sets the value(s) for <b>type</b> ()
2108         *
2109     * <p>
2110     * <b>Definition:</b>
2111     * A code signifying whether a different drug should be dispensed from what was prescribed.
2112     * </p> 
2113         */
2114        public Substitution setType(CodeableConceptDt theValue) {
2115                myType = theValue;
2116                return this;
2117        }
2118        
2119        
2120
2121  
2122        /**
2123         * Gets the value(s) for <b>reason</b> ().
2124         * creating it if it does
2125         * not exist. Will not return <code>null</code>.
2126         *
2127     * <p>
2128     * <b>Definition:</b>
2129     * Indicates the reason for the substitution, or why substitution must or must not be performed.
2130     * </p> 
2131         */
2132        public CodeableConceptDt getReason() {  
2133                if (myReason == null) {
2134                        myReason = new CodeableConceptDt();
2135                }
2136                return myReason;
2137        }
2138
2139        /**
2140         * Sets the value(s) for <b>reason</b> ()
2141         *
2142     * <p>
2143     * <b>Definition:</b>
2144     * Indicates the reason for the substitution, or why substitution must or must not be performed.
2145     * </p> 
2146         */
2147        public Substitution setReason(CodeableConceptDt theValue) {
2148                myReason = theValue;
2149                return this;
2150        }
2151        
2152        
2153
2154  
2155
2156
2157        }
2158
2159
2160
2161
2162    @Override
2163    public String getResourceName() {
2164        return "MedicationOrder";
2165    }
2166    
2167    public ca.uhn.fhir.context.FhirVersionEnum getStructureFhirVersionEnum() {
2168        return ca.uhn.fhir.context.FhirVersionEnum.DSTU2;
2169    }
2170
2171
2172}