001package org.hl7.fhir.dstu2016may.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 Sun, May 8, 2016 03:05+1000 for FHIR v1.4.0
033import java.util.ArrayList;
034import java.util.List;
035
036import org.hl7.fhir.exceptions.FHIRException;
037
038import ca.uhn.fhir.model.api.annotation.Child;
039import ca.uhn.fhir.model.api.annotation.Description;
040import ca.uhn.fhir.model.api.annotation.ResourceDef;
041import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
042/**
043 * This resource allows for the definition of an order set as a sharable, consumable, and executable artifact in support of clinical decision support.
044 */
045@ResourceDef(name="OrderSet", profile="http://hl7.org/fhir/Profile/OrderSet")
046public class OrderSet extends DomainResource {
047
048    /**
049     * A reference to a ModuleMetadata resource containing metadata for the orderset.
050     */
051    @Child(name = "moduleMetadata", type = {ModuleMetadata.class}, order=0, min=0, max=1, modifier=false, summary=true)
052    @Description(shortDefinition="The metadata for the orderset", formalDefinition="A reference to a ModuleMetadata resource containing metadata for the orderset." )
053    protected ModuleMetadata moduleMetadata;
054
055    /**
056     * A reference to a Library resource containing any formal logic used by the orderset.
057     */
058    @Child(name = "library", type = {Library.class}, order=1, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
059    @Description(shortDefinition="Logic used by the orderset", formalDefinition="A reference to a Library resource containing any formal logic used by the orderset." )
060    protected List<Reference> library;
061    /**
062     * The actual objects that are the target of the reference (A reference to a Library resource containing any formal logic used by the orderset.)
063     */
064    protected List<Library> libraryTarget;
065
066
067    /**
068     * The definition of the actions that make up the order set. Order set groups and sections are represented as actions which contain sub-actions.
069     */
070    @Child(name = "action", type = {ActionDefinition.class}, order=2, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=true)
071    @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." )
072    protected List<ActionDefinition> action;
073
074    private static final long serialVersionUID = -728217200L;
075
076  /**
077   * Constructor
078   */
079    public OrderSet() {
080      super();
081    }
082
083    /**
084     * @return {@link #moduleMetadata} (A reference to a ModuleMetadata resource containing metadata for the orderset.)
085     */
086    public ModuleMetadata getModuleMetadata() { 
087      if (this.moduleMetadata == null)
088        if (Configuration.errorOnAutoCreate())
089          throw new Error("Attempt to auto-create OrderSet.moduleMetadata");
090        else if (Configuration.doAutoCreate())
091          this.moduleMetadata = new ModuleMetadata(); // cc
092      return this.moduleMetadata;
093    }
094
095    public boolean hasModuleMetadata() { 
096      return this.moduleMetadata != null && !this.moduleMetadata.isEmpty();
097    }
098
099    /**
100     * @param value {@link #moduleMetadata} (A reference to a ModuleMetadata resource containing metadata for the orderset.)
101     */
102    public OrderSet setModuleMetadata(ModuleMetadata value) { 
103      this.moduleMetadata = value;
104      return this;
105    }
106
107    /**
108     * @return {@link #library} (A reference to a Library resource containing any formal logic used by the orderset.)
109     */
110    public List<Reference> getLibrary() { 
111      if (this.library == null)
112        this.library = new ArrayList<Reference>();
113      return this.library;
114    }
115
116    public boolean hasLibrary() { 
117      if (this.library == null)
118        return false;
119      for (Reference item : this.library)
120        if (!item.isEmpty())
121          return true;
122      return false;
123    }
124
125    /**
126     * @return {@link #library} (A reference to a Library resource containing any formal logic used by the orderset.)
127     */
128    // syntactic sugar
129    public Reference addLibrary() { //3
130      Reference t = new Reference();
131      if (this.library == null)
132        this.library = new ArrayList<Reference>();
133      this.library.add(t);
134      return t;
135    }
136
137    // syntactic sugar
138    public OrderSet addLibrary(Reference t) { //3
139      if (t == null)
140        return this;
141      if (this.library == null)
142        this.library = new ArrayList<Reference>();
143      this.library.add(t);
144      return this;
145    }
146
147    /**
148     * @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.)
149     */
150    public List<Library> getLibraryTarget() { 
151      if (this.libraryTarget == null)
152        this.libraryTarget = new ArrayList<Library>();
153      return this.libraryTarget;
154    }
155
156    // syntactic sugar
157    /**
158     * @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.)
159     */
160    public Library addLibraryTarget() { 
161      Library r = new Library();
162      if (this.libraryTarget == null)
163        this.libraryTarget = new ArrayList<Library>();
164      this.libraryTarget.add(r);
165      return r;
166    }
167
168    /**
169     * @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.)
170     */
171    public List<ActionDefinition> getAction() { 
172      if (this.action == null)
173        this.action = new ArrayList<ActionDefinition>();
174      return this.action;
175    }
176
177    public boolean hasAction() { 
178      if (this.action == null)
179        return false;
180      for (ActionDefinition item : this.action)
181        if (!item.isEmpty())
182          return true;
183      return false;
184    }
185
186    /**
187     * @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.)
188     */
189    // syntactic sugar
190    public ActionDefinition addAction() { //3
191      ActionDefinition t = new ActionDefinition();
192      if (this.action == null)
193        this.action = new ArrayList<ActionDefinition>();
194      this.action.add(t);
195      return t;
196    }
197
198    // syntactic sugar
199    public OrderSet addAction(ActionDefinition t) { //3
200      if (t == null)
201        return this;
202      if (this.action == null)
203        this.action = new ArrayList<ActionDefinition>();
204      this.action.add(t);
205      return this;
206    }
207
208      protected void listChildren(List<Property> childrenList) {
209        super.listChildren(childrenList);
210        childrenList.add(new Property("moduleMetadata", "ModuleMetadata", "A reference to a ModuleMetadata resource containing metadata for the orderset.", 0, java.lang.Integer.MAX_VALUE, moduleMetadata));
211        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));
212        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));
213      }
214
215      @Override
216      public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
217        switch (hash) {
218        case 455891387: /*moduleMetadata*/ return this.moduleMetadata == null ? new Base[0] : new Base[] {this.moduleMetadata}; // ModuleMetadata
219        case 166208699: /*library*/ return this.library == null ? new Base[0] : this.library.toArray(new Base[this.library.size()]); // Reference
220        case -1422950858: /*action*/ return this.action == null ? new Base[0] : this.action.toArray(new Base[this.action.size()]); // ActionDefinition
221        default: return super.getProperty(hash, name, checkValid);
222        }
223
224      }
225
226      @Override
227      public void setProperty(int hash, String name, Base value) throws FHIRException {
228        switch (hash) {
229        case 455891387: // moduleMetadata
230          this.moduleMetadata = castToModuleMetadata(value); // ModuleMetadata
231          break;
232        case 166208699: // library
233          this.getLibrary().add(castToReference(value)); // Reference
234          break;
235        case -1422950858: // action
236          this.getAction().add(castToActionDefinition(value)); // ActionDefinition
237          break;
238        default: super.setProperty(hash, name, value);
239        }
240
241      }
242
243      @Override
244      public void setProperty(String name, Base value) throws FHIRException {
245        if (name.equals("moduleMetadata"))
246          this.moduleMetadata = castToModuleMetadata(value); // ModuleMetadata
247        else if (name.equals("library"))
248          this.getLibrary().add(castToReference(value));
249        else if (name.equals("action"))
250          this.getAction().add(castToActionDefinition(value));
251        else
252          super.setProperty(name, value);
253      }
254
255      @Override
256      public Base makeProperty(int hash, String name) throws FHIRException {
257        switch (hash) {
258        case 455891387:  return getModuleMetadata(); // ModuleMetadata
259        case 166208699:  return addLibrary(); // Reference
260        case -1422950858:  return addAction(); // ActionDefinition
261        default: return super.makeProperty(hash, name);
262        }
263
264      }
265
266      @Override
267      public Base addChild(String name) throws FHIRException {
268        if (name.equals("moduleMetadata")) {
269          this.moduleMetadata = new ModuleMetadata();
270          return this.moduleMetadata;
271        }
272        else if (name.equals("library")) {
273          return addLibrary();
274        }
275        else if (name.equals("action")) {
276          return addAction();
277        }
278        else
279          return super.addChild(name);
280      }
281
282  public String fhirType() {
283    return "OrderSet";
284
285  }
286
287      public OrderSet copy() {
288        OrderSet dst = new OrderSet();
289        copyValues(dst);
290        dst.moduleMetadata = moduleMetadata == null ? null : moduleMetadata.copy();
291        if (library != null) {
292          dst.library = new ArrayList<Reference>();
293          for (Reference i : library)
294            dst.library.add(i.copy());
295        };
296        if (action != null) {
297          dst.action = new ArrayList<ActionDefinition>();
298          for (ActionDefinition i : action)
299            dst.action.add(i.copy());
300        };
301        return dst;
302      }
303
304      protected OrderSet typedCopy() {
305        return copy();
306      }
307
308      @Override
309      public boolean equalsDeep(Base other) {
310        if (!super.equalsDeep(other))
311          return false;
312        if (!(other instanceof OrderSet))
313          return false;
314        OrderSet o = (OrderSet) other;
315        return compareDeep(moduleMetadata, o.moduleMetadata, true) && compareDeep(library, o.library, true)
316           && compareDeep(action, o.action, true);
317      }
318
319      @Override
320      public boolean equalsShallow(Base other) {
321        if (!super.equalsShallow(other))
322          return false;
323        if (!(other instanceof OrderSet))
324          return false;
325        OrderSet o = (OrderSet) other;
326        return true;
327      }
328
329      public boolean isEmpty() {
330        return super.isEmpty() && (moduleMetadata == null || moduleMetadata.isEmpty()) && (library == null || library.isEmpty())
331           && (action == null || action.isEmpty());
332      }
333
334  @Override
335  public ResourceType getResourceType() {
336    return ResourceType.OrderSet;
337   }
338
339 /**
340   * Search parameter: <b>topic</b>
341   * <p>
342   * Description: <b>Topics associated with the module</b><br>
343   * Type: <b>token</b><br>
344   * Path: <b>OrderSet.moduleMetadata.topic</b><br>
345   * </p>
346   */
347  @SearchParamDefinition(name="topic", path="OrderSet.moduleMetadata.topic", description="Topics associated with the module", type="token" )
348  public static final String SP_TOPIC = "topic";
349 /**
350   * <b>Fluent Client</b> search parameter constant for <b>topic</b>
351   * <p>
352   * Description: <b>Topics associated with the module</b><br>
353   * Type: <b>token</b><br>
354   * Path: <b>OrderSet.moduleMetadata.topic</b><br>
355   * </p>
356   */
357  public static final ca.uhn.fhir.rest.gclient.TokenClientParam TOPIC = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_TOPIC);
358
359 /**
360   * Search parameter: <b>title</b>
361   * <p>
362   * Description: <b>Text search against the title</b><br>
363   * Type: <b>string</b><br>
364   * Path: <b>OrderSet.moduleMetadata.title</b><br>
365   * </p>
366   */
367  @SearchParamDefinition(name="title", path="OrderSet.moduleMetadata.title", description="Text search against the title", type="string" )
368  public static final String SP_TITLE = "title";
369 /**
370   * <b>Fluent Client</b> search parameter constant for <b>title</b>
371   * <p>
372   * Description: <b>Text search against the title</b><br>
373   * Type: <b>string</b><br>
374   * Path: <b>OrderSet.moduleMetadata.title</b><br>
375   * </p>
376   */
377  public static final ca.uhn.fhir.rest.gclient.StringClientParam TITLE = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_TITLE);
378
379 /**
380   * Search parameter: <b>status</b>
381   * <p>
382   * Description: <b>Status of the module</b><br>
383   * Type: <b>token</b><br>
384   * Path: <b>OrderSet.moduleMetadata.status</b><br>
385   * </p>
386   */
387  @SearchParamDefinition(name="status", path="OrderSet.moduleMetadata.status", description="Status of the module", type="token" )
388  public static final String SP_STATUS = "status";
389 /**
390   * <b>Fluent Client</b> search parameter constant for <b>status</b>
391   * <p>
392   * Description: <b>Status of the module</b><br>
393   * Type: <b>token</b><br>
394   * Path: <b>OrderSet.moduleMetadata.status</b><br>
395   * </p>
396   */
397  public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);
398
399 /**
400   * Search parameter: <b>description</b>
401   * <p>
402   * Description: <b>Text search against the description</b><br>
403   * Type: <b>string</b><br>
404   * Path: <b>OrderSet.moduleMetadata.description</b><br>
405   * </p>
406   */
407  @SearchParamDefinition(name="description", path="OrderSet.moduleMetadata.description", description="Text search against the description", type="string" )
408  public static final String SP_DESCRIPTION = "description";
409 /**
410   * <b>Fluent Client</b> search parameter constant for <b>description</b>
411   * <p>
412   * Description: <b>Text search against the description</b><br>
413   * Type: <b>string</b><br>
414   * Path: <b>OrderSet.moduleMetadata.description</b><br>
415   * </p>
416   */
417  public static final ca.uhn.fhir.rest.gclient.StringClientParam DESCRIPTION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_DESCRIPTION);
418
419 /**
420   * Search parameter: <b>identifier</b>
421   * <p>
422   * Description: <b>Logical identifier for the module (e.g. CMS-143)</b><br>
423   * Type: <b>token</b><br>
424   * Path: <b>OrderSet.moduleMetadata.identifier</b><br>
425   * </p>
426   */
427  @SearchParamDefinition(name="identifier", path="OrderSet.moduleMetadata.identifier", description="Logical identifier for the module (e.g. CMS-143)", type="token" )
428  public static final String SP_IDENTIFIER = "identifier";
429 /**
430   * <b>Fluent Client</b> search parameter constant for <b>identifier</b>
431   * <p>
432   * Description: <b>Logical identifier for the module (e.g. CMS-143)</b><br>
433   * Type: <b>token</b><br>
434   * Path: <b>OrderSet.moduleMetadata.identifier</b><br>
435   * </p>
436   */
437  public static final ca.uhn.fhir.rest.gclient.TokenClientParam IDENTIFIER = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_IDENTIFIER);
438
439 /**
440   * Search parameter: <b>version</b>
441   * <p>
442   * Description: <b>Version of the module (e.g. 1.0.0)</b><br>
443   * Type: <b>string</b><br>
444   * Path: <b>OrderSet.moduleMetadata.version</b><br>
445   * </p>
446   */
447  @SearchParamDefinition(name="version", path="OrderSet.moduleMetadata.version", description="Version of the module (e.g. 1.0.0)", type="string" )
448  public static final String SP_VERSION = "version";
449 /**
450   * <b>Fluent Client</b> search parameter constant for <b>version</b>
451   * <p>
452   * Description: <b>Version of the module (e.g. 1.0.0)</b><br>
453   * Type: <b>string</b><br>
454   * Path: <b>OrderSet.moduleMetadata.version</b><br>
455   * </p>
456   */
457  public static final ca.uhn.fhir.rest.gclient.StringClientParam VERSION = new ca.uhn.fhir.rest.gclient.StringClientParam(SP_VERSION);
458
459
460}
461