001package org.hl7.fhir.dstu2.model;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009  
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030*/
031
032// Generated on Wed, Jul 13, 2016 05:32+1000 for FHIR v1.0.2
033import java.util.ArrayList;
034import java.util.Date;
035import java.util.List;
036
037import ca.uhn.fhir.model.api.annotation.Child;
038import ca.uhn.fhir.model.api.annotation.Description;
039import ca.uhn.fhir.model.api.annotation.ResourceDef;
040import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
041import org.hl7.fhir.exceptions.FHIRException;
042
043/**
044 * A request for a procedure to be performed. May be a proposal or an order.
045 */
046@ResourceDef(name = "ProcedureRequest", profile = "http://hl7.org/fhir/Profile/ProcedureRequest")
047public class ProcedureRequest extends DomainResource {
048
049  public enum ProcedureRequestStatus {
050    /**
051     * The request has been proposed.
052     */
053    PROPOSED,
054    /**
055     * The request is in preliminary form, prior to being requested.
056     */
057    DRAFT,
058    /**
059     * The request has been placed.
060     */
061    REQUESTED,
062    /**
063     * The receiving system has received the request but not yet decided whether it
064     * will be performed.
065     */
066    RECEIVED,
067    /**
068     * The receiving system has accepted the request, but work has not yet
069     * commenced.
070     */
071    ACCEPTED,
072    /**
073     * The work to fulfill the request is happening.
074     */
075    INPROGRESS,
076    /**
077     * The work has been completed, the report(s) released, and no further work is
078     * planned.
079     */
080    COMPLETED,
081    /**
082     * The request has been held by originating system/user request.
083     */
084    SUSPENDED,
085    /**
086     * The receiving system has declined to fulfill the request.
087     */
088    REJECTED,
089    /**
090     * The request was attempted, but due to some procedural error, it could not be
091     * completed.
092     */
093    ABORTED,
094    /**
095     * added to help the parsers
096     */
097    NULL;
098
099    public static ProcedureRequestStatus fromCode(String codeString) throws FHIRException {
100      if (codeString == null || "".equals(codeString))
101        return null;
102      if ("proposed".equals(codeString))
103        return PROPOSED;
104      if ("draft".equals(codeString))
105        return DRAFT;
106      if ("requested".equals(codeString))
107        return REQUESTED;
108      if ("received".equals(codeString))
109        return RECEIVED;
110      if ("accepted".equals(codeString))
111        return ACCEPTED;
112      if ("in-progress".equals(codeString))
113        return INPROGRESS;
114      if ("completed".equals(codeString))
115        return COMPLETED;
116      if ("suspended".equals(codeString))
117        return SUSPENDED;
118      if ("rejected".equals(codeString))
119        return REJECTED;
120      if ("aborted".equals(codeString))
121        return ABORTED;
122      throw new FHIRException("Unknown ProcedureRequestStatus code '" + codeString + "'");
123    }
124
125    public String toCode() {
126      switch (this) {
127      case PROPOSED:
128        return "proposed";
129      case DRAFT:
130        return "draft";
131      case REQUESTED:
132        return "requested";
133      case RECEIVED:
134        return "received";
135      case ACCEPTED:
136        return "accepted";
137      case INPROGRESS:
138        return "in-progress";
139      case COMPLETED:
140        return "completed";
141      case SUSPENDED:
142        return "suspended";
143      case REJECTED:
144        return "rejected";
145      case ABORTED:
146        return "aborted";
147      case NULL:
148        return null;
149      default:
150        return "?";
151      }
152    }
153
154    public String getSystem() {
155      switch (this) {
156      case PROPOSED:
157        return "http://hl7.org/fhir/procedure-request-status";
158      case DRAFT:
159        return "http://hl7.org/fhir/procedure-request-status";
160      case REQUESTED:
161        return "http://hl7.org/fhir/procedure-request-status";
162      case RECEIVED:
163        return "http://hl7.org/fhir/procedure-request-status";
164      case ACCEPTED:
165        return "http://hl7.org/fhir/procedure-request-status";
166      case INPROGRESS:
167        return "http://hl7.org/fhir/procedure-request-status";
168      case COMPLETED:
169        return "http://hl7.org/fhir/procedure-request-status";
170      case SUSPENDED:
171        return "http://hl7.org/fhir/procedure-request-status";
172      case REJECTED:
173        return "http://hl7.org/fhir/procedure-request-status";
174      case ABORTED:
175        return "http://hl7.org/fhir/procedure-request-status";
176      case NULL:
177        return null;
178      default:
179        return "?";
180      }
181    }
182
183    public String getDefinition() {
184      switch (this) {
185      case PROPOSED:
186        return "The request has been proposed.";
187      case DRAFT:
188        return "The request is in preliminary form, prior to being requested.";
189      case REQUESTED:
190        return "The request has been placed.";
191      case RECEIVED:
192        return "The receiving system has received the request but not yet decided whether it will be performed.";
193      case ACCEPTED:
194        return "The receiving system has accepted the request, but work has not yet commenced.";
195      case INPROGRESS:
196        return "The work to fulfill the request is happening.";
197      case COMPLETED:
198        return "The work has been completed, the report(s) released, and no further work is planned.";
199      case SUSPENDED:
200        return "The request has been held by originating system/user request.";
201      case REJECTED:
202        return "The receiving system has declined to fulfill the request.";
203      case ABORTED:
204        return "The request was attempted, but due to some procedural error, it could not be completed.";
205      case NULL:
206        return null;
207      default:
208        return "?";
209      }
210    }
211
212    public String getDisplay() {
213      switch (this) {
214      case PROPOSED:
215        return "Proposed";
216      case DRAFT:
217        return "Draft";
218      case REQUESTED:
219        return "Requested";
220      case RECEIVED:
221        return "Received";
222      case ACCEPTED:
223        return "Accepted";
224      case INPROGRESS:
225        return "In Progress";
226      case COMPLETED:
227        return "Completed";
228      case SUSPENDED:
229        return "Suspended";
230      case REJECTED:
231        return "Rejected";
232      case ABORTED:
233        return "Aborted";
234      case NULL:
235        return null;
236      default:
237        return "?";
238      }
239    }
240  }
241
242  public static class ProcedureRequestStatusEnumFactory implements EnumFactory<ProcedureRequestStatus> {
243    public ProcedureRequestStatus fromCode(String codeString) throws IllegalArgumentException {
244      if (codeString == null || "".equals(codeString))
245        if (codeString == null || "".equals(codeString))
246          return null;
247      if ("proposed".equals(codeString))
248        return ProcedureRequestStatus.PROPOSED;
249      if ("draft".equals(codeString))
250        return ProcedureRequestStatus.DRAFT;
251      if ("requested".equals(codeString))
252        return ProcedureRequestStatus.REQUESTED;
253      if ("received".equals(codeString))
254        return ProcedureRequestStatus.RECEIVED;
255      if ("accepted".equals(codeString))
256        return ProcedureRequestStatus.ACCEPTED;
257      if ("in-progress".equals(codeString))
258        return ProcedureRequestStatus.INPROGRESS;
259      if ("completed".equals(codeString))
260        return ProcedureRequestStatus.COMPLETED;
261      if ("suspended".equals(codeString))
262        return ProcedureRequestStatus.SUSPENDED;
263      if ("rejected".equals(codeString))
264        return ProcedureRequestStatus.REJECTED;
265      if ("aborted".equals(codeString))
266        return ProcedureRequestStatus.ABORTED;
267      throw new IllegalArgumentException("Unknown ProcedureRequestStatus code '" + codeString + "'");
268    }
269
270    public Enumeration<ProcedureRequestStatus> fromType(Base code) throws FHIRException {
271      if (code == null || code.isEmpty())
272        return null;
273      String codeString = ((PrimitiveType) code).asStringValue();
274      if (codeString == null || "".equals(codeString))
275        return null;
276      if ("proposed".equals(codeString))
277        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.PROPOSED);
278      if ("draft".equals(codeString))
279        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.DRAFT);
280      if ("requested".equals(codeString))
281        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.REQUESTED);
282      if ("received".equals(codeString))
283        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.RECEIVED);
284      if ("accepted".equals(codeString))
285        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.ACCEPTED);
286      if ("in-progress".equals(codeString))
287        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.INPROGRESS);
288      if ("completed".equals(codeString))
289        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.COMPLETED);
290      if ("suspended".equals(codeString))
291        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.SUSPENDED);
292      if ("rejected".equals(codeString))
293        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.REJECTED);
294      if ("aborted".equals(codeString))
295        return new Enumeration<ProcedureRequestStatus>(this, ProcedureRequestStatus.ABORTED);
296      throw new FHIRException("Unknown ProcedureRequestStatus code '" + codeString + "'");
297    }
298
299    public String toCode(ProcedureRequestStatus code) {
300      if (code == ProcedureRequestStatus.PROPOSED)
301        return "proposed";
302      if (code == ProcedureRequestStatus.DRAFT)
303        return "draft";
304      if (code == ProcedureRequestStatus.REQUESTED)
305        return "requested";
306      if (code == ProcedureRequestStatus.RECEIVED)
307        return "received";
308      if (code == ProcedureRequestStatus.ACCEPTED)
309        return "accepted";
310      if (code == ProcedureRequestStatus.INPROGRESS)
311        return "in-progress";
312      if (code == ProcedureRequestStatus.COMPLETED)
313        return "completed";
314      if (code == ProcedureRequestStatus.SUSPENDED)
315        return "suspended";
316      if (code == ProcedureRequestStatus.REJECTED)
317        return "rejected";
318      if (code == ProcedureRequestStatus.ABORTED)
319        return "aborted";
320      return "?";
321    }
322  }
323
324  public enum ProcedureRequestPriority {
325    /**
326     * The request has a normal priority.
327     */
328    ROUTINE,
329    /**
330     * The request should be done urgently.
331     */
332    URGENT,
333    /**
334     * The request is time-critical.
335     */
336    STAT,
337    /**
338     * The request should be acted on as soon as possible.
339     */
340    ASAP,
341    /**
342     * added to help the parsers
343     */
344    NULL;
345
346    public static ProcedureRequestPriority fromCode(String codeString) throws FHIRException {
347      if (codeString == null || "".equals(codeString))
348        return null;
349      if ("routine".equals(codeString))
350        return ROUTINE;
351      if ("urgent".equals(codeString))
352        return URGENT;
353      if ("stat".equals(codeString))
354        return STAT;
355      if ("asap".equals(codeString))
356        return ASAP;
357      throw new FHIRException("Unknown ProcedureRequestPriority code '" + codeString + "'");
358    }
359
360    public String toCode() {
361      switch (this) {
362      case ROUTINE:
363        return "routine";
364      case URGENT:
365        return "urgent";
366      case STAT:
367        return "stat";
368      case ASAP:
369        return "asap";
370      case NULL:
371        return null;
372      default:
373        return "?";
374      }
375    }
376
377    public String getSystem() {
378      switch (this) {
379      case ROUTINE:
380        return "http://hl7.org/fhir/procedure-request-priority";
381      case URGENT:
382        return "http://hl7.org/fhir/procedure-request-priority";
383      case STAT:
384        return "http://hl7.org/fhir/procedure-request-priority";
385      case ASAP:
386        return "http://hl7.org/fhir/procedure-request-priority";
387      case NULL:
388        return null;
389      default:
390        return "?";
391      }
392    }
393
394    public String getDefinition() {
395      switch (this) {
396      case ROUTINE:
397        return "The request has a normal priority.";
398      case URGENT:
399        return "The request should be done urgently.";
400      case STAT:
401        return "The request is time-critical.";
402      case ASAP:
403        return "The request should be acted on as soon as possible.";
404      case NULL:
405        return null;
406      default:
407        return "?";
408      }
409    }
410
411    public String getDisplay() {
412      switch (this) {
413      case ROUTINE:
414        return "Routine";
415      case URGENT:
416        return "Urgent";
417      case STAT:
418        return "Stat";
419      case ASAP:
420        return "ASAP";
421      case NULL:
422        return null;
423      default:
424        return "?";
425      }
426    }
427  }
428
429  public static class ProcedureRequestPriorityEnumFactory implements EnumFactory<ProcedureRequestPriority> {
430    public ProcedureRequestPriority fromCode(String codeString) throws IllegalArgumentException {
431      if (codeString == null || "".equals(codeString))
432        if (codeString == null || "".equals(codeString))
433          return null;
434      if ("routine".equals(codeString))
435        return ProcedureRequestPriority.ROUTINE;
436      if ("urgent".equals(codeString))
437        return ProcedureRequestPriority.URGENT;
438      if ("stat".equals(codeString))
439        return ProcedureRequestPriority.STAT;
440      if ("asap".equals(codeString))
441        return ProcedureRequestPriority.ASAP;
442      throw new IllegalArgumentException("Unknown ProcedureRequestPriority code '" + codeString + "'");
443    }
444
445    public Enumeration<ProcedureRequestPriority> fromType(Base code) throws FHIRException {
446      if (code == null || code.isEmpty())
447        return null;
448      String codeString = ((PrimitiveType) code).asStringValue();
449      if (codeString == null || "".equals(codeString))
450        return null;
451      if ("routine".equals(codeString))
452        return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.ROUTINE);
453      if ("urgent".equals(codeString))
454        return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.URGENT);
455      if ("stat".equals(codeString))
456        return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.STAT);
457      if ("asap".equals(codeString))
458        return new Enumeration<ProcedureRequestPriority>(this, ProcedureRequestPriority.ASAP);
459      throw new FHIRException("Unknown ProcedureRequestPriority code '" + codeString + "'");
460    }
461
462    public String toCode(ProcedureRequestPriority code) {
463      if (code == ProcedureRequestPriority.ROUTINE)
464        return "routine";
465      if (code == ProcedureRequestPriority.URGENT)
466        return "urgent";
467      if (code == ProcedureRequestPriority.STAT)
468        return "stat";
469      if (code == ProcedureRequestPriority.ASAP)
470        return "asap";
471      return "?";
472    }
473  }
474
475  /**
476   * Identifiers assigned to this order by the order or by the receiver.
477   */
478  @Child(name = "identifier", type = {
479      Identifier.class }, order = 0, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
480  @Description(shortDefinition = "Unique identifier for the request", formalDefinition = "Identifiers assigned to this order by the order or by the receiver.")
481  protected List<Identifier> identifier;
482
483  /**
484   * The person, animal or group that should receive the procedure.
485   */
486  @Child(name = "subject", type = { Patient.class,
487      Group.class }, order = 1, min = 1, max = 1, modifier = false, summary = true)
488  @Description(shortDefinition = "Who the procedure should be done to", formalDefinition = "The person, animal or group that should receive the procedure.")
489  protected Reference subject;
490
491  /**
492   * The actual object that is the target of the reference (The person, animal or
493   * group that should receive the procedure.)
494   */
495  protected Resource subjectTarget;
496
497  /**
498   * The specific procedure that is ordered. Use text if the exact nature of the
499   * procedure cannot be coded.
500   */
501  @Child(name = "code", type = { CodeableConcept.class }, order = 2, min = 1, max = 1, modifier = false, summary = true)
502  @Description(shortDefinition = "What procedure to perform", formalDefinition = "The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.")
503  protected CodeableConcept code;
504
505  /**
506   * Indicates the sites on the subject's body where the procedure should be
507   * performed (I.e. the target sites).
508   */
509  @Child(name = "bodySite", type = {
510      CodeableConcept.class }, order = 3, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
511  @Description(shortDefinition = "What part of body to perform on", formalDefinition = "Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).")
512  protected List<CodeableConcept> bodySite;
513
514  /**
515   * The reason why the procedure is being proposed or ordered. This procedure
516   * request may be motivated by a Condition for instance.
517   */
518  @Child(name = "reason", type = { CodeableConcept.class,
519      Condition.class }, order = 4, min = 0, max = 1, modifier = false, summary = true)
520  @Description(shortDefinition = "Why procedure should occur", formalDefinition = "The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.")
521  protected Type reason;
522
523  /**
524   * The timing schedule for the proposed or ordered procedure. The Schedule data
525   * type allows many different expressions. E.g. "Every 8 hours"; "Three times a
526   * day"; "1/2 an hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct
527   * 2013, 17 Oct 2013 and 1 Nov 2013".
528   */
529  @Child(name = "scheduled", type = { DateTimeType.class, Period.class,
530      Timing.class }, order = 5, min = 0, max = 1, modifier = false, summary = true)
531  @Description(shortDefinition = "When procedure should occur", formalDefinition = "The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. \"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\".")
532  protected Type scheduled;
533
534  /**
535   * The encounter within which the procedure proposal or request was created.
536   */
537  @Child(name = "encounter", type = { Encounter.class }, order = 6, min = 0, max = 1, modifier = false, summary = true)
538  @Description(shortDefinition = "Encounter request created during", formalDefinition = "The encounter within which the procedure proposal or request was created.")
539  protected Reference encounter;
540
541  /**
542   * The actual object that is the target of the reference (The encounter within
543   * which the procedure proposal or request was created.)
544   */
545  protected Encounter encounterTarget;
546
547  /**
548   * For example, the surgeon, anaethetist, endoscopist, etc.
549   */
550  @Child(name = "performer", type = { Practitioner.class, Organization.class, Patient.class,
551      RelatedPerson.class }, order = 7, min = 0, max = 1, modifier = false, summary = true)
552  @Description(shortDefinition = "Who should perform the procedure", formalDefinition = "For example, the surgeon, anaethetist, endoscopist, etc.")
553  protected Reference performer;
554
555  /**
556   * The actual object that is the target of the reference (For example, the
557   * surgeon, anaethetist, endoscopist, etc.)
558   */
559  protected Resource performerTarget;
560
561  /**
562   * The status of the order.
563   */
564  @Child(name = "status", type = { CodeType.class }, order = 8, min = 0, max = 1, modifier = true, summary = true)
565  @Description(shortDefinition = "proposed | draft | requested | received | accepted | in-progress | completed | suspended | rejected | aborted", formalDefinition = "The status of the order.")
566  protected Enumeration<ProcedureRequestStatus> status;
567
568  /**
569   * Any other notes associated with this proposal or order - e.g. provider
570   * instructions.
571   */
572  @Child(name = "notes", type = {
573      Annotation.class }, order = 9, min = 0, max = Child.MAX_UNLIMITED, modifier = false, summary = true)
574  @Description(shortDefinition = "Additional information about desired procedure", formalDefinition = "Any other notes associated with this proposal or order - e.g. provider instructions.")
575  protected List<Annotation> notes;
576
577  /**
578   * If a CodeableConcept is present, it indicates the pre-condition for
579   * performing the procedure.
580   */
581  @Child(name = "asNeeded", type = { BooleanType.class,
582      CodeableConcept.class }, order = 10, min = 0, max = 1, modifier = false, summary = true)
583  @Description(shortDefinition = "Preconditions for procedure", formalDefinition = "If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.")
584  protected Type asNeeded;
585
586  /**
587   * The time when the request was made.
588   */
589  @Child(name = "orderedOn", type = {
590      DateTimeType.class }, order = 11, min = 0, max = 1, modifier = false, summary = true)
591  @Description(shortDefinition = "When request was created", formalDefinition = "The time when the request was made.")
592  protected DateTimeType orderedOn;
593
594  /**
595   * The healthcare professional responsible for proposing or ordering the
596   * procedure.
597   */
598  @Child(name = "orderer", type = { Practitioner.class, Patient.class, RelatedPerson.class,
599      Device.class }, order = 12, min = 0, max = 1, modifier = false, summary = true)
600  @Description(shortDefinition = "Who made request", formalDefinition = "The healthcare professional responsible for proposing or ordering the procedure.")
601  protected Reference orderer;
602
603  /**
604   * The actual object that is the target of the reference (The healthcare
605   * professional responsible for proposing or ordering the procedure.)
606   */
607  protected Resource ordererTarget;
608
609  /**
610   * The clinical priority associated with this order.
611   */
612  @Child(name = "priority", type = { CodeType.class }, order = 13, min = 0, max = 1, modifier = false, summary = true)
613  @Description(shortDefinition = "routine | urgent | stat | asap", formalDefinition = "The clinical priority associated with this order.")
614  protected Enumeration<ProcedureRequestPriority> priority;
615
616  private static final long serialVersionUID = -916650578L;
617
618  /*
619   * Constructor
620   */
621  public ProcedureRequest() {
622    super();
623  }
624
625  /*
626   * Constructor
627   */
628  public ProcedureRequest(Reference subject, CodeableConcept code) {
629    super();
630    this.subject = subject;
631    this.code = code;
632  }
633
634  /**
635   * @return {@link #identifier} (Identifiers assigned to this order by the order
636   *         or by the receiver.)
637   */
638  public List<Identifier> getIdentifier() {
639    if (this.identifier == null)
640      this.identifier = new ArrayList<Identifier>();
641    return this.identifier;
642  }
643
644  public boolean hasIdentifier() {
645    if (this.identifier == null)
646      return false;
647    for (Identifier item : this.identifier)
648      if (!item.isEmpty())
649        return true;
650    return false;
651  }
652
653  /**
654   * @return {@link #identifier} (Identifiers assigned to this order by the order
655   *         or by the receiver.)
656   */
657  // syntactic sugar
658  public Identifier addIdentifier() { // 3
659    Identifier t = new Identifier();
660    if (this.identifier == null)
661      this.identifier = new ArrayList<Identifier>();
662    this.identifier.add(t);
663    return t;
664  }
665
666  // syntactic sugar
667  public ProcedureRequest addIdentifier(Identifier t) { // 3
668    if (t == null)
669      return this;
670    if (this.identifier == null)
671      this.identifier = new ArrayList<Identifier>();
672    this.identifier.add(t);
673    return this;
674  }
675
676  /**
677   * @return {@link #subject} (The person, animal or group that should receive the
678   *         procedure.)
679   */
680  public Reference getSubject() {
681    if (this.subject == null)
682      if (Configuration.errorOnAutoCreate())
683        throw new Error("Attempt to auto-create ProcedureRequest.subject");
684      else if (Configuration.doAutoCreate())
685        this.subject = new Reference(); // cc
686    return this.subject;
687  }
688
689  public boolean hasSubject() {
690    return this.subject != null && !this.subject.isEmpty();
691  }
692
693  /**
694   * @param value {@link #subject} (The person, animal or group that should
695   *              receive the procedure.)
696   */
697  public ProcedureRequest setSubject(Reference value) {
698    this.subject = value;
699    return this;
700  }
701
702  /**
703   * @return {@link #subject} The actual object that is the target of the
704   *         reference. The reference library doesn't populate this, but you can
705   *         use it to hold the resource if you resolve it. (The person, animal or
706   *         group that should receive the procedure.)
707   */
708  public Resource getSubjectTarget() {
709    return this.subjectTarget;
710  }
711
712  /**
713   * @param value {@link #subject} The actual object that is the target of the
714   *              reference. The reference library doesn't use these, but you can
715   *              use it to hold the resource if you resolve it. (The person,
716   *              animal or group that should receive the procedure.)
717   */
718  public ProcedureRequest setSubjectTarget(Resource value) {
719    this.subjectTarget = value;
720    return this;
721  }
722
723  /**
724   * @return {@link #code} (The specific procedure that is ordered. Use text if
725   *         the exact nature of the procedure cannot be coded.)
726   */
727  public CodeableConcept getCode() {
728    if (this.code == null)
729      if (Configuration.errorOnAutoCreate())
730        throw new Error("Attempt to auto-create ProcedureRequest.code");
731      else if (Configuration.doAutoCreate())
732        this.code = new CodeableConcept(); // cc
733    return this.code;
734  }
735
736  public boolean hasCode() {
737    return this.code != null && !this.code.isEmpty();
738  }
739
740  /**
741   * @param value {@link #code} (The specific procedure that is ordered. Use text
742   *              if the exact nature of the procedure cannot be coded.)
743   */
744  public ProcedureRequest setCode(CodeableConcept value) {
745    this.code = value;
746    return this;
747  }
748
749  /**
750   * @return {@link #bodySite} (Indicates the sites on the subject's body where
751   *         the procedure should be performed (I.e. the target sites).)
752   */
753  public List<CodeableConcept> getBodySite() {
754    if (this.bodySite == null)
755      this.bodySite = new ArrayList<CodeableConcept>();
756    return this.bodySite;
757  }
758
759  public boolean hasBodySite() {
760    if (this.bodySite == null)
761      return false;
762    for (CodeableConcept item : this.bodySite)
763      if (!item.isEmpty())
764        return true;
765    return false;
766  }
767
768  /**
769   * @return {@link #bodySite} (Indicates the sites on the subject's body where
770   *         the procedure should be performed (I.e. the target sites).)
771   */
772  // syntactic sugar
773  public CodeableConcept addBodySite() { // 3
774    CodeableConcept t = new CodeableConcept();
775    if (this.bodySite == null)
776      this.bodySite = new ArrayList<CodeableConcept>();
777    this.bodySite.add(t);
778    return t;
779  }
780
781  // syntactic sugar
782  public ProcedureRequest addBodySite(CodeableConcept t) { // 3
783    if (t == null)
784      return this;
785    if (this.bodySite == null)
786      this.bodySite = new ArrayList<CodeableConcept>();
787    this.bodySite.add(t);
788    return this;
789  }
790
791  /**
792   * @return {@link #reason} (The reason why the procedure is being proposed or
793   *         ordered. This procedure request may be motivated by a Condition for
794   *         instance.)
795   */
796  public Type getReason() {
797    return this.reason;
798  }
799
800  /**
801   * @return {@link #reason} (The reason why the procedure is being proposed or
802   *         ordered. This procedure request may be motivated by a Condition for
803   *         instance.)
804   */
805  public CodeableConcept getReasonCodeableConcept() throws FHIRException {
806    if (!(this.reason instanceof CodeableConcept))
807      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
808          + this.reason.getClass().getName() + " was encountered");
809    return (CodeableConcept) this.reason;
810  }
811
812  public boolean hasReasonCodeableConcept() {
813    return this.reason instanceof CodeableConcept;
814  }
815
816  /**
817   * @return {@link #reason} (The reason why the procedure is being proposed or
818   *         ordered. This procedure request may be motivated by a Condition for
819   *         instance.)
820   */
821  public Reference getReasonReference() throws FHIRException {
822    if (!(this.reason instanceof Reference))
823      throw new FHIRException("Type mismatch: the type Reference was expected, but " + this.reason.getClass().getName()
824          + " was encountered");
825    return (Reference) this.reason;
826  }
827
828  public boolean hasReasonReference() {
829    return this.reason instanceof Reference;
830  }
831
832  public boolean hasReason() {
833    return this.reason != null && !this.reason.isEmpty();
834  }
835
836  /**
837   * @param value {@link #reason} (The reason why the procedure is being proposed
838   *              or ordered. This procedure request may be motivated by a
839   *              Condition for instance.)
840   */
841  public ProcedureRequest setReason(Type value) {
842    this.reason = value;
843    return this;
844  }
845
846  /**
847   * @return {@link #scheduled} (The timing schedule for the proposed or ordered
848   *         procedure. The Schedule data type allows many different expressions.
849   *         E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before
850   *         breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013
851   *         and 1 Nov 2013".)
852   */
853  public Type getScheduled() {
854    return this.scheduled;
855  }
856
857  /**
858   * @return {@link #scheduled} (The timing schedule for the proposed or ordered
859   *         procedure. The Schedule data type allows many different expressions.
860   *         E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before
861   *         breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013
862   *         and 1 Nov 2013".)
863   */
864  public DateTimeType getScheduledDateTimeType() throws FHIRException {
865    if (!(this.scheduled instanceof DateTimeType))
866      throw new FHIRException("Type mismatch: the type DateTimeType was expected, but "
867          + this.scheduled.getClass().getName() + " was encountered");
868    return (DateTimeType) this.scheduled;
869  }
870
871  public boolean hasScheduledDateTimeType() {
872    return this.scheduled instanceof DateTimeType;
873  }
874
875  /**
876   * @return {@link #scheduled} (The timing schedule for the proposed or ordered
877   *         procedure. The Schedule data type allows many different expressions.
878   *         E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before
879   *         breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013
880   *         and 1 Nov 2013".)
881   */
882  public Period getScheduledPeriod() throws FHIRException {
883    if (!(this.scheduled instanceof Period))
884      throw new FHIRException("Type mismatch: the type Period was expected, but " + this.scheduled.getClass().getName()
885          + " was encountered");
886    return (Period) this.scheduled;
887  }
888
889  public boolean hasScheduledPeriod() {
890    return this.scheduled instanceof Period;
891  }
892
893  /**
894   * @return {@link #scheduled} (The timing schedule for the proposed or ordered
895   *         procedure. The Schedule data type allows many different expressions.
896   *         E.g. "Every 8 hours"; "Three times a day"; "1/2 an hour before
897   *         breakfast for 10 days from 23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013
898   *         and 1 Nov 2013".)
899   */
900  public Timing getScheduledTiming() throws FHIRException {
901    if (!(this.scheduled instanceof Timing))
902      throw new FHIRException("Type mismatch: the type Timing was expected, but " + this.scheduled.getClass().getName()
903          + " was encountered");
904    return (Timing) this.scheduled;
905  }
906
907  public boolean hasScheduledTiming() {
908    return this.scheduled instanceof Timing;
909  }
910
911  public boolean hasScheduled() {
912    return this.scheduled != null && !this.scheduled.isEmpty();
913  }
914
915  /**
916   * @param value {@link #scheduled} (The timing schedule for the proposed or
917   *              ordered procedure. The Schedule data type allows many different
918   *              expressions. E.g. "Every 8 hours"; "Three times a day"; "1/2 an
919   *              hour before breakfast for 10 days from 23-Dec 2011:"; "15 Oct
920   *              2013, 17 Oct 2013 and 1 Nov 2013".)
921   */
922  public ProcedureRequest setScheduled(Type value) {
923    this.scheduled = value;
924    return this;
925  }
926
927  /**
928   * @return {@link #encounter} (The encounter within which the procedure proposal
929   *         or request was created.)
930   */
931  public Reference getEncounter() {
932    if (this.encounter == null)
933      if (Configuration.errorOnAutoCreate())
934        throw new Error("Attempt to auto-create ProcedureRequest.encounter");
935      else if (Configuration.doAutoCreate())
936        this.encounter = new Reference(); // cc
937    return this.encounter;
938  }
939
940  public boolean hasEncounter() {
941    return this.encounter != null && !this.encounter.isEmpty();
942  }
943
944  /**
945   * @param value {@link #encounter} (The encounter within which the procedure
946   *              proposal or request was created.)
947   */
948  public ProcedureRequest setEncounter(Reference value) {
949    this.encounter = value;
950    return this;
951  }
952
953  /**
954   * @return {@link #encounter} The actual object that is the target of the
955   *         reference. The reference library doesn't populate this, but you can
956   *         use it to hold the resource if you resolve it. (The encounter within
957   *         which the procedure proposal or request was created.)
958   */
959  public Encounter getEncounterTarget() {
960    if (this.encounterTarget == null)
961      if (Configuration.errorOnAutoCreate())
962        throw new Error("Attempt to auto-create ProcedureRequest.encounter");
963      else if (Configuration.doAutoCreate())
964        this.encounterTarget = new Encounter(); // aa
965    return this.encounterTarget;
966  }
967
968  /**
969   * @param value {@link #encounter} The actual object that is the target of the
970   *              reference. The reference library doesn't use these, but you can
971   *              use it to hold the resource if you resolve it. (The encounter
972   *              within which the procedure proposal or request was created.)
973   */
974  public ProcedureRequest setEncounterTarget(Encounter value) {
975    this.encounterTarget = value;
976    return this;
977  }
978
979  /**
980   * @return {@link #performer} (For example, the surgeon, anaethetist,
981   *         endoscopist, etc.)
982   */
983  public Reference getPerformer() {
984    if (this.performer == null)
985      if (Configuration.errorOnAutoCreate())
986        throw new Error("Attempt to auto-create ProcedureRequest.performer");
987      else if (Configuration.doAutoCreate())
988        this.performer = new Reference(); // cc
989    return this.performer;
990  }
991
992  public boolean hasPerformer() {
993    return this.performer != null && !this.performer.isEmpty();
994  }
995
996  /**
997   * @param value {@link #performer} (For example, the surgeon, anaethetist,
998   *              endoscopist, etc.)
999   */
1000  public ProcedureRequest setPerformer(Reference value) {
1001    this.performer = value;
1002    return this;
1003  }
1004
1005  /**
1006   * @return {@link #performer} The actual object that is the target of the
1007   *         reference. The reference library doesn't populate this, but you can
1008   *         use it to hold the resource if you resolve it. (For example, the
1009   *         surgeon, anaethetist, endoscopist, etc.)
1010   */
1011  public Resource getPerformerTarget() {
1012    return this.performerTarget;
1013  }
1014
1015  /**
1016   * @param value {@link #performer} The actual object that is the target of the
1017   *              reference. The reference library doesn't use these, but you can
1018   *              use it to hold the resource if you resolve it. (For example, the
1019   *              surgeon, anaethetist, endoscopist, etc.)
1020   */
1021  public ProcedureRequest setPerformerTarget(Resource value) {
1022    this.performerTarget = value;
1023    return this;
1024  }
1025
1026  /**
1027   * @return {@link #status} (The status of the order.). This is the underlying
1028   *         object with id, value and extensions. The accessor "getStatus" gives
1029   *         direct access to the value
1030   */
1031  public Enumeration<ProcedureRequestStatus> getStatusElement() {
1032    if (this.status == null)
1033      if (Configuration.errorOnAutoCreate())
1034        throw new Error("Attempt to auto-create ProcedureRequest.status");
1035      else if (Configuration.doAutoCreate())
1036        this.status = new Enumeration<ProcedureRequestStatus>(new ProcedureRequestStatusEnumFactory()); // bb
1037    return this.status;
1038  }
1039
1040  public boolean hasStatusElement() {
1041    return this.status != null && !this.status.isEmpty();
1042  }
1043
1044  public boolean hasStatus() {
1045    return this.status != null && !this.status.isEmpty();
1046  }
1047
1048  /**
1049   * @param value {@link #status} (The status of the order.). This is the
1050   *              underlying object with id, value and extensions. The accessor
1051   *              "getStatus" gives direct access to the value
1052   */
1053  public ProcedureRequest setStatusElement(Enumeration<ProcedureRequestStatus> value) {
1054    this.status = value;
1055    return this;
1056  }
1057
1058  /**
1059   * @return The status of the order.
1060   */
1061  public ProcedureRequestStatus getStatus() {
1062    return this.status == null ? null : this.status.getValue();
1063  }
1064
1065  /**
1066   * @param value The status of the order.
1067   */
1068  public ProcedureRequest setStatus(ProcedureRequestStatus value) {
1069    if (value == null)
1070      this.status = null;
1071    else {
1072      if (this.status == null)
1073        this.status = new Enumeration<ProcedureRequestStatus>(new ProcedureRequestStatusEnumFactory());
1074      this.status.setValue(value);
1075    }
1076    return this;
1077  }
1078
1079  /**
1080   * @return {@link #notes} (Any other notes associated with this proposal or
1081   *         order - e.g. provider instructions.)
1082   */
1083  public List<Annotation> getNotes() {
1084    if (this.notes == null)
1085      this.notes = new ArrayList<Annotation>();
1086    return this.notes;
1087  }
1088
1089  public boolean hasNotes() {
1090    if (this.notes == null)
1091      return false;
1092    for (Annotation item : this.notes)
1093      if (!item.isEmpty())
1094        return true;
1095    return false;
1096  }
1097
1098  /**
1099   * @return {@link #notes} (Any other notes associated with this proposal or
1100   *         order - e.g. provider instructions.)
1101   */
1102  // syntactic sugar
1103  public Annotation addNotes() { // 3
1104    Annotation t = new Annotation();
1105    if (this.notes == null)
1106      this.notes = new ArrayList<Annotation>();
1107    this.notes.add(t);
1108    return t;
1109  }
1110
1111  // syntactic sugar
1112  public ProcedureRequest addNotes(Annotation t) { // 3
1113    if (t == null)
1114      return this;
1115    if (this.notes == null)
1116      this.notes = new ArrayList<Annotation>();
1117    this.notes.add(t);
1118    return this;
1119  }
1120
1121  /**
1122   * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the
1123   *         pre-condition for performing the procedure.)
1124   */
1125  public Type getAsNeeded() {
1126    return this.asNeeded;
1127  }
1128
1129  /**
1130   * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the
1131   *         pre-condition for performing the procedure.)
1132   */
1133  public BooleanType getAsNeededBooleanType() throws FHIRException {
1134    if (!(this.asNeeded instanceof BooleanType))
1135      throw new FHIRException("Type mismatch: the type BooleanType was expected, but "
1136          + this.asNeeded.getClass().getName() + " was encountered");
1137    return (BooleanType) this.asNeeded;
1138  }
1139
1140  public boolean hasAsNeededBooleanType() {
1141    return this.asNeeded instanceof BooleanType;
1142  }
1143
1144  /**
1145   * @return {@link #asNeeded} (If a CodeableConcept is present, it indicates the
1146   *         pre-condition for performing the procedure.)
1147   */
1148  public CodeableConcept getAsNeededCodeableConcept() throws FHIRException {
1149    if (!(this.asNeeded instanceof CodeableConcept))
1150      throw new FHIRException("Type mismatch: the type CodeableConcept was expected, but "
1151          + this.asNeeded.getClass().getName() + " was encountered");
1152    return (CodeableConcept) this.asNeeded;
1153  }
1154
1155  public boolean hasAsNeededCodeableConcept() {
1156    return this.asNeeded instanceof CodeableConcept;
1157  }
1158
1159  public boolean hasAsNeeded() {
1160    return this.asNeeded != null && !this.asNeeded.isEmpty();
1161  }
1162
1163  /**
1164   * @param value {@link #asNeeded} (If a CodeableConcept is present, it indicates
1165   *              the pre-condition for performing the procedure.)
1166   */
1167  public ProcedureRequest setAsNeeded(Type value) {
1168    this.asNeeded = value;
1169    return this;
1170  }
1171
1172  /**
1173   * @return {@link #orderedOn} (The time when the request was made.). This is the
1174   *         underlying object with id, value and extensions. The accessor
1175   *         "getOrderedOn" gives direct access to the value
1176   */
1177  public DateTimeType getOrderedOnElement() {
1178    if (this.orderedOn == null)
1179      if (Configuration.errorOnAutoCreate())
1180        throw new Error("Attempt to auto-create ProcedureRequest.orderedOn");
1181      else if (Configuration.doAutoCreate())
1182        this.orderedOn = new DateTimeType(); // bb
1183    return this.orderedOn;
1184  }
1185
1186  public boolean hasOrderedOnElement() {
1187    return this.orderedOn != null && !this.orderedOn.isEmpty();
1188  }
1189
1190  public boolean hasOrderedOn() {
1191    return this.orderedOn != null && !this.orderedOn.isEmpty();
1192  }
1193
1194  /**
1195   * @param value {@link #orderedOn} (The time when the request was made.). This
1196   *              is the underlying object with id, value and extensions. The
1197   *              accessor "getOrderedOn" gives direct access to the value
1198   */
1199  public ProcedureRequest setOrderedOnElement(DateTimeType value) {
1200    this.orderedOn = value;
1201    return this;
1202  }
1203
1204  /**
1205   * @return The time when the request was made.
1206   */
1207  public Date getOrderedOn() {
1208    return this.orderedOn == null ? null : this.orderedOn.getValue();
1209  }
1210
1211  /**
1212   * @param value The time when the request was made.
1213   */
1214  public ProcedureRequest setOrderedOn(Date value) {
1215    if (value == null)
1216      this.orderedOn = null;
1217    else {
1218      if (this.orderedOn == null)
1219        this.orderedOn = new DateTimeType();
1220      this.orderedOn.setValue(value);
1221    }
1222    return this;
1223  }
1224
1225  /**
1226   * @return {@link #orderer} (The healthcare professional responsible for
1227   *         proposing or ordering the procedure.)
1228   */
1229  public Reference getOrderer() {
1230    if (this.orderer == null)
1231      if (Configuration.errorOnAutoCreate())
1232        throw new Error("Attempt to auto-create ProcedureRequest.orderer");
1233      else if (Configuration.doAutoCreate())
1234        this.orderer = new Reference(); // cc
1235    return this.orderer;
1236  }
1237
1238  public boolean hasOrderer() {
1239    return this.orderer != null && !this.orderer.isEmpty();
1240  }
1241
1242  /**
1243   * @param value {@link #orderer} (The healthcare professional responsible for
1244   *              proposing or ordering the procedure.)
1245   */
1246  public ProcedureRequest setOrderer(Reference value) {
1247    this.orderer = value;
1248    return this;
1249  }
1250
1251  /**
1252   * @return {@link #orderer} The actual object that is the target of the
1253   *         reference. The reference library doesn't populate this, but you can
1254   *         use it to hold the resource if you resolve it. (The healthcare
1255   *         professional responsible for proposing or ordering the procedure.)
1256   */
1257  public Resource getOrdererTarget() {
1258    return this.ordererTarget;
1259  }
1260
1261  /**
1262   * @param value {@link #orderer} The actual object that is the target of the
1263   *              reference. The reference library doesn't use these, but you can
1264   *              use it to hold the resource if you resolve it. (The healthcare
1265   *              professional responsible for proposing or ordering the
1266   *              procedure.)
1267   */
1268  public ProcedureRequest setOrdererTarget(Resource value) {
1269    this.ordererTarget = value;
1270    return this;
1271  }
1272
1273  /**
1274   * @return {@link #priority} (The clinical priority associated with this
1275   *         order.). This is the underlying object with id, value and extensions.
1276   *         The accessor "getPriority" gives direct access to the value
1277   */
1278  public Enumeration<ProcedureRequestPriority> getPriorityElement() {
1279    if (this.priority == null)
1280      if (Configuration.errorOnAutoCreate())
1281        throw new Error("Attempt to auto-create ProcedureRequest.priority");
1282      else if (Configuration.doAutoCreate())
1283        this.priority = new Enumeration<ProcedureRequestPriority>(new ProcedureRequestPriorityEnumFactory()); // bb
1284    return this.priority;
1285  }
1286
1287  public boolean hasPriorityElement() {
1288    return this.priority != null && !this.priority.isEmpty();
1289  }
1290
1291  public boolean hasPriority() {
1292    return this.priority != null && !this.priority.isEmpty();
1293  }
1294
1295  /**
1296   * @param value {@link #priority} (The clinical priority associated with this
1297   *              order.). This is the underlying object with id, value and
1298   *              extensions. The accessor "getPriority" gives direct access to
1299   *              the value
1300   */
1301  public ProcedureRequest setPriorityElement(Enumeration<ProcedureRequestPriority> value) {
1302    this.priority = value;
1303    return this;
1304  }
1305
1306  /**
1307   * @return The clinical priority associated with this order.
1308   */
1309  public ProcedureRequestPriority getPriority() {
1310    return this.priority == null ? null : this.priority.getValue();
1311  }
1312
1313  /**
1314   * @param value The clinical priority associated with this order.
1315   */
1316  public ProcedureRequest setPriority(ProcedureRequestPriority value) {
1317    if (value == null)
1318      this.priority = null;
1319    else {
1320      if (this.priority == null)
1321        this.priority = new Enumeration<ProcedureRequestPriority>(new ProcedureRequestPriorityEnumFactory());
1322      this.priority.setValue(value);
1323    }
1324    return this;
1325  }
1326
1327  protected void listChildren(List<Property> childrenList) {
1328    super.listChildren(childrenList);
1329    childrenList.add(
1330        new Property("identifier", "Identifier", "Identifiers assigned to this order by the order or by the receiver.",
1331            0, java.lang.Integer.MAX_VALUE, identifier));
1332    childrenList.add(new Property("subject", "Reference(Patient|Group)",
1333        "The person, animal or group that should receive the procedure.", 0, java.lang.Integer.MAX_VALUE, subject));
1334    childrenList.add(new Property("code", "CodeableConcept",
1335        "The specific procedure that is ordered. Use text if the exact nature of the procedure cannot be coded.", 0,
1336        java.lang.Integer.MAX_VALUE, code));
1337    childrenList.add(new Property("bodySite", "CodeableConcept",
1338        "Indicates the sites on the subject's body where the procedure should be performed (I.e. the target sites).", 0,
1339        java.lang.Integer.MAX_VALUE, bodySite));
1340    childrenList.add(new Property("reason[x]", "CodeableConcept|Reference(Condition)",
1341        "The reason why the procedure is being proposed or ordered. This procedure request may be motivated by a Condition for instance.",
1342        0, java.lang.Integer.MAX_VALUE, reason));
1343    childrenList.add(new Property("scheduled[x]", "dateTime|Period|Timing",
1344        "The timing schedule for the proposed or ordered procedure. The Schedule data type allows many different expressions.  E.g. \"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\".",
1345        0, java.lang.Integer.MAX_VALUE, scheduled));
1346    childrenList.add(new Property("encounter", "Reference(Encounter)",
1347        "The encounter within which the procedure proposal or request was created.", 0, java.lang.Integer.MAX_VALUE,
1348        encounter));
1349    childrenList.add(new Property("performer", "Reference(Practitioner|Organization|Patient|RelatedPerson)",
1350        "For example, the surgeon, anaethetist, endoscopist, etc.", 0, java.lang.Integer.MAX_VALUE, performer));
1351    childrenList
1352        .add(new Property("status", "code", "The status of the order.", 0, java.lang.Integer.MAX_VALUE, status));
1353    childrenList.add(new Property("notes", "Annotation",
1354        "Any other notes associated with this proposal or order - e.g. provider instructions.", 0,
1355        java.lang.Integer.MAX_VALUE, notes));
1356    childrenList.add(new Property("asNeeded[x]", "boolean|CodeableConcept",
1357        "If a CodeableConcept is present, it indicates the pre-condition for performing the procedure.", 0,
1358        java.lang.Integer.MAX_VALUE, asNeeded));
1359    childrenList.add(new Property("orderedOn", "dateTime", "The time when the request was made.", 0,
1360        java.lang.Integer.MAX_VALUE, orderedOn));
1361    childrenList.add(new Property("orderer", "Reference(Practitioner|Patient|RelatedPerson|Device)",
1362        "The healthcare professional responsible for proposing or ordering the procedure.", 0,
1363        java.lang.Integer.MAX_VALUE, orderer));
1364    childrenList.add(new Property("priority", "code", "The clinical priority associated with this order.", 0,
1365        java.lang.Integer.MAX_VALUE, priority));
1366  }
1367
1368  @Override
1369  public void setProperty(String name, Base value) throws FHIRException {
1370    if (name.equals("identifier"))
1371      this.getIdentifier().add(castToIdentifier(value));
1372    else if (name.equals("subject"))
1373      this.subject = castToReference(value); // Reference
1374    else if (name.equals("code"))
1375      this.code = castToCodeableConcept(value); // CodeableConcept
1376    else if (name.equals("bodySite"))
1377      this.getBodySite().add(castToCodeableConcept(value));
1378    else if (name.equals("reason[x]"))
1379      this.reason = (Type) value; // Type
1380    else if (name.equals("scheduled[x]"))
1381      this.scheduled = (Type) value; // Type
1382    else if (name.equals("encounter"))
1383      this.encounter = castToReference(value); // Reference
1384    else if (name.equals("performer"))
1385      this.performer = castToReference(value); // Reference
1386    else if (name.equals("status"))
1387      this.status = new ProcedureRequestStatusEnumFactory().fromType(value); // Enumeration<ProcedureRequestStatus>
1388    else if (name.equals("notes"))
1389      this.getNotes().add(castToAnnotation(value));
1390    else if (name.equals("asNeeded[x]"))
1391      this.asNeeded = (Type) value; // Type
1392    else if (name.equals("orderedOn"))
1393      this.orderedOn = castToDateTime(value); // DateTimeType
1394    else if (name.equals("orderer"))
1395      this.orderer = castToReference(value); // Reference
1396    else if (name.equals("priority"))
1397      this.priority = new ProcedureRequestPriorityEnumFactory().fromType(value); // Enumeration<ProcedureRequestPriority>
1398    else
1399      super.setProperty(name, value);
1400  }
1401
1402  @Override
1403  public Base addChild(String name) throws FHIRException {
1404    if (name.equals("identifier")) {
1405      return addIdentifier();
1406    } else if (name.equals("subject")) {
1407      this.subject = new Reference();
1408      return this.subject;
1409    } else if (name.equals("code")) {
1410      this.code = new CodeableConcept();
1411      return this.code;
1412    } else if (name.equals("bodySite")) {
1413      return addBodySite();
1414    } else if (name.equals("reasonCodeableConcept")) {
1415      this.reason = new CodeableConcept();
1416      return this.reason;
1417    } else if (name.equals("reasonReference")) {
1418      this.reason = new Reference();
1419      return this.reason;
1420    } else if (name.equals("scheduledDateTime")) {
1421      this.scheduled = new DateTimeType();
1422      return this.scheduled;
1423    } else if (name.equals("scheduledPeriod")) {
1424      this.scheduled = new Period();
1425      return this.scheduled;
1426    } else if (name.equals("scheduledTiming")) {
1427      this.scheduled = new Timing();
1428      return this.scheduled;
1429    } else if (name.equals("encounter")) {
1430      this.encounter = new Reference();
1431      return this.encounter;
1432    } else if (name.equals("performer")) {
1433      this.performer = new Reference();
1434      return this.performer;
1435    } else if (name.equals("status")) {
1436      throw new FHIRException("Cannot call addChild on a singleton property ProcedureRequest.status");
1437    } else if (name.equals("notes")) {
1438      return addNotes();
1439    } else if (name.equals("asNeededBoolean")) {
1440      this.asNeeded = new BooleanType();
1441      return this.asNeeded;
1442    } else if (name.equals("asNeededCodeableConcept")) {
1443      this.asNeeded = new CodeableConcept();
1444      return this.asNeeded;
1445    } else if (name.equals("orderedOn")) {
1446      throw new FHIRException("Cannot call addChild on a singleton property ProcedureRequest.orderedOn");
1447    } else if (name.equals("orderer")) {
1448      this.orderer = new Reference();
1449      return this.orderer;
1450    } else if (name.equals("priority")) {
1451      throw new FHIRException("Cannot call addChild on a singleton property ProcedureRequest.priority");
1452    } else
1453      return super.addChild(name);
1454  }
1455
1456  public String fhirType() {
1457    return "ProcedureRequest";
1458
1459  }
1460
1461  public ProcedureRequest copy() {
1462    ProcedureRequest dst = new ProcedureRequest();
1463    copyValues(dst);
1464    if (identifier != null) {
1465      dst.identifier = new ArrayList<Identifier>();
1466      for (Identifier i : identifier)
1467        dst.identifier.add(i.copy());
1468    }
1469    ;
1470    dst.subject = subject == null ? null : subject.copy();
1471    dst.code = code == null ? null : code.copy();
1472    if (bodySite != null) {
1473      dst.bodySite = new ArrayList<CodeableConcept>();
1474      for (CodeableConcept i : bodySite)
1475        dst.bodySite.add(i.copy());
1476    }
1477    ;
1478    dst.reason = reason == null ? null : reason.copy();
1479    dst.scheduled = scheduled == null ? null : scheduled.copy();
1480    dst.encounter = encounter == null ? null : encounter.copy();
1481    dst.performer = performer == null ? null : performer.copy();
1482    dst.status = status == null ? null : status.copy();
1483    if (notes != null) {
1484      dst.notes = new ArrayList<Annotation>();
1485      for (Annotation i : notes)
1486        dst.notes.add(i.copy());
1487    }
1488    ;
1489    dst.asNeeded = asNeeded == null ? null : asNeeded.copy();
1490    dst.orderedOn = orderedOn == null ? null : orderedOn.copy();
1491    dst.orderer = orderer == null ? null : orderer.copy();
1492    dst.priority = priority == null ? null : priority.copy();
1493    return dst;
1494  }
1495
1496  protected ProcedureRequest typedCopy() {
1497    return copy();
1498  }
1499
1500  @Override
1501  public boolean equalsDeep(Base other) {
1502    if (!super.equalsDeep(other))
1503      return false;
1504    if (!(other instanceof ProcedureRequest))
1505      return false;
1506    ProcedureRequest o = (ProcedureRequest) other;
1507    return compareDeep(identifier, o.identifier, true) && compareDeep(subject, o.subject, true)
1508        && compareDeep(code, o.code, true) && compareDeep(bodySite, o.bodySite, true)
1509        && compareDeep(reason, o.reason, true) && compareDeep(scheduled, o.scheduled, true)
1510        && compareDeep(encounter, o.encounter, true) && compareDeep(performer, o.performer, true)
1511        && compareDeep(status, o.status, true) && compareDeep(notes, o.notes, true)
1512        && compareDeep(asNeeded, o.asNeeded, true) && compareDeep(orderedOn, o.orderedOn, true)
1513        && compareDeep(orderer, o.orderer, true) && compareDeep(priority, o.priority, true);
1514  }
1515
1516  @Override
1517  public boolean equalsShallow(Base other) {
1518    if (!super.equalsShallow(other))
1519      return false;
1520    if (!(other instanceof ProcedureRequest))
1521      return false;
1522    ProcedureRequest o = (ProcedureRequest) other;
1523    return compareValues(status, o.status, true) && compareValues(orderedOn, o.orderedOn, true)
1524        && compareValues(priority, o.priority, true);
1525  }
1526
1527  public boolean isEmpty() {
1528    return super.isEmpty() && (identifier == null || identifier.isEmpty()) && (subject == null || subject.isEmpty())
1529        && (code == null || code.isEmpty()) && (bodySite == null || bodySite.isEmpty())
1530        && (reason == null || reason.isEmpty()) && (scheduled == null || scheduled.isEmpty())
1531        && (encounter == null || encounter.isEmpty()) && (performer == null || performer.isEmpty())
1532        && (status == null || status.isEmpty()) && (notes == null || notes.isEmpty())
1533        && (asNeeded == null || asNeeded.isEmpty()) && (orderedOn == null || orderedOn.isEmpty())
1534        && (orderer == null || orderer.isEmpty()) && (priority == null || priority.isEmpty());
1535  }
1536
1537  @Override
1538  public ResourceType getResourceType() {
1539    return ResourceType.ProcedureRequest;
1540  }
1541
1542  @SearchParamDefinition(name = "identifier", path = "ProcedureRequest.identifier", description = "A unique identifier of the Procedure Request", type = "token")
1543  public static final String SP_IDENTIFIER = "identifier";
1544  @SearchParamDefinition(name = "performer", path = "ProcedureRequest.performer", description = "Who should perform the procedure", type = "reference")
1545  public static final String SP_PERFORMER = "performer";
1546  @SearchParamDefinition(name = "subject", path = "ProcedureRequest.subject", description = "Search by subject", type = "reference")
1547  public static final String SP_SUBJECT = "subject";
1548  @SearchParamDefinition(name = "patient", path = "ProcedureRequest.subject", description = "Search by subject - a patient", type = "reference")
1549  public static final String SP_PATIENT = "patient";
1550  @SearchParamDefinition(name = "orderer", path = "ProcedureRequest.orderer", description = "Who made request", type = "reference")
1551  public static final String SP_ORDERER = "orderer";
1552  @SearchParamDefinition(name = "encounter", path = "ProcedureRequest.encounter", description = "Encounter request created during", type = "reference")
1553  public static final String SP_ENCOUNTER = "encounter";
1554
1555}