001package org.hl7.fhir.dstu2016may.model;
002
003
004
005
006/*
007  Copyright (c) 2011+, HL7, Inc.
008  All rights reserved.
009  
010  Redistribution and use in source and binary forms, with or without modification, 
011  are permitted provided that the following conditions are met:
012  
013   * Redistributions of source code must retain the above copyright notice, this 
014     list of conditions and the following disclaimer.
015   * Redistributions in binary form must reproduce the above copyright notice, 
016     this list of conditions and the following disclaimer in the documentation 
017     and/or other materials provided with the distribution.
018   * Neither the name of HL7 nor the names of its contributors may be used to 
019     endorse or promote products derived from this software without specific 
020     prior written permission.
021  
022  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
023  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
024  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
025  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
026  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
027  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
028  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
029  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
030  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
031  POSSIBILITY OF SUCH DAMAGE.
032  
033*/
034
035// Generated on Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
036import java.util.ArrayList;
037import java.util.List;
038
039import org.hl7.fhir.exceptions.FHIRException;
040
041import ca.uhn.fhir.model.api.annotation.Child;
042import ca.uhn.fhir.model.api.annotation.Description;
043import ca.uhn.fhir.model.api.annotation.ResourceDef;
044import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
045/**
046 * This resource allows for the definition of an order set as a sharable, consumable, and executable artifact in support of clinical decision support.
047 */
048@ResourceDef(name="OrderSet", profile="http://hl7.org/fhir/Profile/OrderSet")
049public class OrderSet extends DomainResource {
050
051    /**
052     * A reference to a ModuleMetadata resource containing metadata for the orderset.
053     */
054    @Child(name = "moduleMetadata", type = {ModuleMetadata.class}, order=0, min=0, max=1, modifier=false, summary=true)
055    @Description(shortDefinition="The metadata for the orderset", formalDefinition="A reference to a ModuleMetadata resource containing metadata for the orderset." )
056    protected ModuleMetadata moduleMetadata;
057
058    /**
059     * A reference to a Library resource containing any formal logic used by the orderset.
060     */
061    @Child(name = "library", type = {Library.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
062    @Description(shortDefinition="Logic used by the orderset", formalDefinition="A reference to a Library resource containing any formal logic used by the orderset." )
063    protected List<Reference> library;
064    /**
065     * The actual objects that are the target of the reference (A reference to a Library resource containing any formal logic used by the orderset.)
066     */
067    protected List<Library> libraryTarget;
068
069
070    /**
071     * The definition of the actions that make up the order set. Order set groups and sections are represented as actions which contain sub-actions.
072     */
073    @Child(name = "action", type = {ActionDefinition.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
074    @Description(shortDefinition="Groups, sections, and line items of the order set", formalDefinition="The definition of the actions that make up the order set. Order set groups and sections are represented as actions which contain sub-actions." )
075    protected List<ActionDefinition> action;
076
077    private static final long serialVersionUID = -728217200L;
078
079  /**
080   * Constructor
081   */
082    public OrderSet() {
083      super();
084    }
085
086    /**
087     * @return {@link #moduleMetadata} (A reference to a ModuleMetadata resource containing metadata for the orderset.)
088     */
089    public ModuleMetadata getModuleMetadata() { 
090      if (this.moduleMetadata == null)
091        if (Configuration.errorOnAutoCreate())
092          throw new Error("Attempt to auto-create OrderSet.moduleMetadata");
093        else if (Configuration.doAutoCreate())
094          this.moduleMetadata = new ModuleMetadata(); // cc
095      return this.moduleMetadata;
096    }
097
098    public boolean hasModuleMetadata() { 
099      return this.moduleMetadata != null && !this.moduleMetadata.isEmpty();
100    }
101
102    /**
103     * @param value {@link #moduleMetadata} (A reference to a ModuleMetadata resource containing metadata for the orderset.)
104     */
105    public OrderSet setModuleMetadata(ModuleMetadata value) { 
106      this.moduleMetadata = value;
107      return this;
108    }
109
110    /**
111     * @return {@link #library} (A reference to a Library resource containing any formal logic used by the orderset.)
112     */
113    public List<Reference> getLibrary() { 
114      if (this.library == null)
115        this.library = new ArrayList<Reference>();
116      return this.library;
117    }
118
119    public boolean hasLibrary() { 
120      if (this.library == null)
121        return false;
122      for (Reference item : this.library)
123        if (!item.isEmpty())
124          return true;
125      return false;
126    }
127
128    /**
129     * @return {@link #library} (A reference to a Library resource containing any formal logic used by the orderset.)
130     */
131    // syntactic sugar
132    public Reference addLibrary() { //3
133      Reference t = new Reference();
134      if (this.library == null)
135        this.library = new ArrayList<Reference>();
136      this.library.add(t);
137      return t;
138    }
139
140    // syntactic sugar
141    public OrderSet addLibrary(Reference t) { //3
142      if (t == null)
143        return this;
144      if (this.library == null)
145        this.library = new ArrayList<Reference>();
146      this.library.add(t);
147      return this;
148    }
149
150    /**
151     * @return {@link #library} (The actual objects that are the target of the reference. The reference library doesn't populate this, but you can use this to hold the resources if you resolvethemt. A reference to a Library resource containing any formal logic used by the orderset.)
152     */
153    public List<Library> getLibraryTarget() { 
154      if (this.libraryTarget == null)
155        this.libraryTarget = new ArrayList<Library>();
156      return this.libraryTarget;
157    }
158
159    // syntactic sugar
160    /**
161     * @return {@link #library} (Add an actual object that is the target of the reference. The reference library doesn't use these, but you can use this to hold the resources if you resolvethemt. A reference to a Library resource containing any formal logic used by the orderset.)
162     */
163    public Library addLibraryTarget() { 
164      Library r = new Library();
165      if (this.libraryTarget == null)
166        this.libraryTarget = new ArrayList<Library>();
167      this.libraryTarget.add(r);
168      return r;
169    }
170
171    /**
172     * @return {@link #action} (The definition of the actions that make up the order set. Order set groups and sections are represented as actions which contain sub-actions.)
173     */
174    public List<ActionDefinition> getAction() { 
175      if (this.action == null)
176        this.action = new ArrayList<ActionDefinition>();
177      return this.action;
178    }
179
180    public boolean hasAction() { 
181      if (this.action == null)
182        return false;
183      for (ActionDefinition item : this.action)
184        if (!item.isEmpty())
185          return true;
186      return false;
187    }
188
189    /**
190     * @return {@link #action} (The definition of the actions that make up the order set. Order set groups and sections are represented as actions which contain sub-actions.)
191     */
192    // syntactic sugar
193    public ActionDefinition addAction() { //3
194      ActionDefinition t = new ActionDefinition();
195      if (this.action == null)
196        this.action = new ArrayList<ActionDefinition>();
197      this.action.add(t);
198      return t;
199    }
200
201    // syntactic sugar
202    public OrderSet addAction(ActionDefinition t) { //3
203      if (t == null)
204        return this;
205      if (this.action == null)
206        this.action = new ArrayList<ActionDefinition>();
207      this.action.add(t);
208      return this;
209    }
210
211      protected void listChildren(List<Property> childrenList) {
212        super.listChildren(childrenList);
213        childrenList.add(new Property("moduleMetadata", "ModuleMetadata", "A reference to a ModuleMetadata resource containing metadata for the orderset.", 0, java.lang.Integer.MAX_VALUE, moduleMetadata));
214        childrenList.add(new Property("library", "Reference(Library)", "A reference to a Library resource containing any formal logic used by the orderset.", 0, java.lang.Integer.MAX_VALUE, library));
215        childrenList.add(new Property("action", "ActionDefinition", "The definition of the actions that make up the order set. Order set groups and sections are represented as actions which contain sub-actions.", 0, java.lang.Integer.MAX_VALUE, action));
216      }
217
218      @Override
219      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
220        switch (hash) {
221        case 455891387: /*moduleMetadata*/ return this.moduleMetadata == null ? new Base[0] : new Base[] {this.moduleMetadata}; // ModuleMetadata
222        case 166208699: /*library*/ return this.library == null ? new Base[0] : this.library.toArray(new Base[this.library.size()]); // Reference
223        case -1422950858: /*action*/ return this.action == null ? new Base[0] : this.action.toArray(new Base[this.action.size()]); // ActionDefinition
224        default: return super.getProperty(hash, name, checkValid);
225        }
226
227      }
228
229      @Override
230      public void setProperty(int hash, String name, Base value) throws FHIRException {
231        switch (hash) {
232        case 455891387: // moduleMetadata
233          this.moduleMetadata = castToModuleMetadata(value); // ModuleMetadata
234          break;
235        case 166208699: // library
236          this.getLibrary().add(castToReference(value)); // Reference
237          break;
238        case -1422950858: // action
239          this.getAction().add(castToActionDefinition(value)); // ActionDefinition
240          break;
241        default: super.setProperty(hash, name, value);
242        }
243
244      }
245
246      @Override
247      public void setProperty(String name, Base value) throws FHIRException {
248        if (name.equals("moduleMetadata"))
249          this.moduleMetadata = castToModuleMetadata(value); // ModuleMetadata
250        else if (name.equals("library"))
251          this.getLibrary().add(castToReference(value));
252        else if (name.equals("action"))
253          this.getAction().add(castToActionDefinition(value));
254        else
255          super.setProperty(name, value);
256      }
257
258      @Override
259      public Base makeProperty(int hash, String name) throws FHIRException {
260        switch (hash) {
261        case 455891387:  return getModuleMetadata(); // ModuleMetadata
262        case 166208699:  return addLibrary(); // Reference
263        case -1422950858:  return addAction(); // ActionDefinition
264        default: return super.makeProperty(hash, name);
265        }
266
267      }
268
269      @Override
270      public Base addChild(String name) throws FHIRException {
271        if (name.equals("moduleMetadata")) {
272          this.moduleMetadata = new ModuleMetadata();
273          return this.moduleMetadata;
274        }
275        else if (name.equals("library")) {
276          return addLibrary();
277        }
278        else if (name.equals("action")) {
279          return addAction();
280        }
281        else
282          return super.addChild(name);
283      }
284
285  public String fhirType() {
286    return "OrderSet";
287
288  }
289
290      public OrderSet copy() {
291        OrderSet dst = new OrderSet();
292        copyValues(dst);
293        dst.moduleMetadata = moduleMetadata == null ? null : moduleMetadata.copy();
294        if (library != null) {
295          dst.library = new ArrayList<Reference>();
296          for (Reference i : library)
297            dst.library.add(i.copy());
298        };
299        if (action != null) {
300          dst.action = new ArrayList<ActionDefinition>();
301          for (ActionDefinition i : action)
302            dst.action.add(i.copy());
303        };
304        return dst;
305      }
306
307      protected OrderSet typedCopy() {
308        return copy();
309      }
310
311      @Override
312      public boolean equalsDeep(Base other) {
313        if (!super.equalsDeep(other))
314          return false;
315        if (!(other instanceof OrderSet))
316          return false;
317        OrderSet o = (OrderSet) other;
318        return compareDeep(moduleMetadata, o.moduleMetadata, true) && compareDeep(library, o.library, true)
319           && compareDeep(action, o.action, true);
320      }
321
322      @Override
323      public boolean equalsShallow(Base other) {
324        if (!super.equalsShallow(other))
325          return false;
326        if (!(other instanceof OrderSet))
327          return false;
328        OrderSet o = (OrderSet) other;
329        return true;
330      }
331
332      public boolean isEmpty() {
333        return super.isEmpty() && (moduleMetadata == null || moduleMetadata.isEmpty()) && (library == null || library.isEmpty())
334           && (action == null || action.isEmpty());
335      }
336
337  @Override
338  public ResourceType getResourceType() {
339    return ResourceType.OrderSet;
340   }
341
342 /**
343   * Search parameter: <b>topic</b>
344   * <p>
345   * Description: <b>Topics associated with the module</b><br>
346   * Type: <b>token</b><br>
347   * Path: <b>OrderSet.moduleMetadata.topic</b><br>
348   * </p>
349   */
350  @SearchParamDefinition(name="topic", path="OrderSet.moduleMetadata.topic", description="Topics associated with the module", type="token" )
351  public static final String SP_TOPIC = "topic";
352 /**
353   * <b>Fluent Client</b> search parameter constant for <b>topic</b>
354   * <p>
355   * Description: <b>Topics associated with the module</b><br>
356   * Type: <b>token</b><br>
357   * Path: <b>OrderSet.moduleMetadata.topic</b><br>
358   * </p>
359   */
360  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TOPIC = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TOPIC);
361
362 /**
363   * Search parameter: <b>title</b>
364   * <p>
365   * Description: <b>Text search against the title</b><br>
366   * Type: <b>string</b><br>
367   * Path: <b>OrderSet.moduleMetadata.title</b><br>
368   * </p>
369   */
370  @SearchParamDefinition(name="title", path="OrderSet.moduleMetadata.title", description="Text search against the title", type="string" )
371  public static final String SP_TITLE = "title";
372 /**
373   * <b>Fluent Client</b> search parameter constant for <b>title</b>
374   * <p>
375   * Description: <b>Text search against the title</b><br>
376   * Type: <b>string</b><br>
377   * Path: <b>OrderSet.moduleMetadata.title</b><br>
378   * </p>
379   */
380  public static final ca.uhn.fhir.rest.gclient.StringClientParam TITLE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_TITLE);
381
382 /**
383   * Search parameter: <b>status</b>
384   * <p>
385   * Description: <b>Status of the module</b><br>
386   * Type: <b>token</b><br>
387   * Path: <b>OrderSet.moduleMetadata.status</b><br>
388   * </p>
389   */
390  @SearchParamDefinition(name="status", path="OrderSet.moduleMetadata.status", description="Status of the module", type="token" )
391  public static final String SP_STATUS = "status";
392 /**
393   * <b>Fluent Client</b> search parameter constant for <b>status</b>
394   * <p>
395   * Description: <b>Status of the module</b><br>
396   * Type: <b>token</b><br>
397   * Path: <b>OrderSet.moduleMetadata.status</b><br>
398   * </p>
399   */
400  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
401
402 /**
403   * Search parameter: <b>description</b>
404   * <p>
405   * Description: <b>Text search against the description</b><br>
406   * Type: <b>string</b><br>
407   * Path: <b>OrderSet.moduleMetadata.description</b><br>
408   * </p>
409   */
410  @SearchParamDefinition(name="description", path="OrderSet.moduleMetadata.description", description="Text search against the description", type="string" )
411  public static final String SP_DESCRIPTION = "description";
412 /**
413   * <b>Fluent Client</b> search parameter constant for <b>description</b>
414   * <p>
415   * Description: <b>Text search against the description</b><br>
416   * Type: <b>string</b><br>
417   * Path: <b>OrderSet.moduleMetadata.description</b><br>
418   * </p>
419   */
420  public static final ca.uhn.fhir.rest.gclient.StringClientParam DESCRIPTION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_DESCRIPTION);
421
422 /**
423   * Search parameter: <b>identifier</b>
424   * <p>
425   * Description: <b>Logical identifier for the module (e.g. CMS-143)</b><br>
426   * Type: <b>token</b><br>
427   * Path: <b>OrderSet.moduleMetadata.identifier</b><br>
428   * </p>
429   */
430  @SearchParamDefinition(name="identifier", path="OrderSet.moduleMetadata.identifier", description="Logical identifier for the module (e.g. CMS-143)", type="token" )
431  public static final String SP_IDENTIFIER = "identifier";
432 /**
433   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
434   * <p>
435   * Description: <b>Logical identifier for the module (e.g. CMS-143)</b><br>
436   * Type: <b>token</b><br>
437   * Path: <b>OrderSet.moduleMetadata.identifier</b><br>
438   * </p>
439   */
440  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
441
442 /**
443   * Search parameter: <b>version</b>
444   * <p>
445   * Description: <b>Version of the module (e.g. 1.0.0)</b><br>
446   * Type: <b>string</b><br>
447   * Path: <b>OrderSet.moduleMetadata.version</b><br>
448   * </p>
449   */
450  @SearchParamDefinition(name="version", path="OrderSet.moduleMetadata.version", description="Version of the module (e.g. 1.0.0)", type="string" )
451  public static final String SP_VERSION = "version";
452 /**
453   * <b>Fluent Client</b> search parameter constant for <b>version</b>
454   * <p>
455   * Description: <b>Version of the module (e.g. 1.0.0)</b><br>
456   * Type: <b>string</b><br>
457   * Path: <b>OrderSet.moduleMetadata.version</b><br>
458   * </p>
459   */
460  public static final ca.uhn.fhir.rest.gclient.StringClientParam VERSION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_VERSION);
461
462
463}