
001package org.hl7.fhir.r5.openehr; 002 003 004/* 005 Copyright (c) 2011+, HL7, Inc. 006 All rights reserved. 007 008 Redistribution and use in source and binary forms, with or without modification, \ 009 are permitted provided that the following conditions are met: 010 011 * Redistributions of source code must retain the above copyright notice, this \ 012 list of conditions and the following disclaimer. 013 * Redistributions in binary form must reproduce the above copyright notice, \ 014 this list of conditions and the following disclaimer in the documentation \ 015 and/or other materials provided with the distribution. 016 * Neither the name of HL7 nor the names of its contributors may be used to 017 endorse or promote products derived from this software without specific 018 prior written permission. 019 020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND \ 021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \ 022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \ 023 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, \ 024 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT \ 025 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR \ 026 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \ 027 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \ 028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \ 029 POSSIBILITY OF SUCH DAMAGE. 030 */ 031 032// Generated on Thu, Mar 23, 2023 19:59+1100 for FHIR v5.0.0 033 034import java.util.ArrayList; 035import java.util.Date; 036import java.util.List; 037import org.hl7.fhir.r5.openehr.Enumerations.*; 038import org.hl7.fhir.exceptions.FHIRException; 039import org.hl7.fhir.r5.model.*; 040import org.hl7.fhir.instance.model.api.ICompositeType; 041import ca.uhn.fhir.model.api.annotation.Child; 042import ca.uhn.fhir.model.api.annotation.ChildOrder; 043import ca.uhn.fhir.model.api.annotation.DatatypeDef; 044import ca.uhn.fhir.model.api.annotation.Description; 045import ca.uhn.fhir.model.api.annotation.Block; 046 047/** 048 * Represents a heading in a heading structure, or section tree. Created according to archetyped structures for typical headings such as SOAP, physical examination, but also pathology result heading structures. Should not be used instead of ENTRY hierarchical structures. 049 */ 050@DatatypeDef(name="SECTION") 051public class SECTION extends CONTENT_ITEM implements ICompositeType { 052 053 /** 054 * Ordered list of content items under this section, which may include: more SECTIONs; ENTRYs. 055 */ 056 @Child(name = "items", type = {CONTENT_ITEM.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 057 @Description(shortDefinition="Ordered list of content items under this section, which may include more SECTIONs or ENTRYs", formalDefinition="Ordered list of content items under this section, which may include: more SECTIONs; ENTRYs." ) 058 protected List<CONTENT_ITEM> itemsList; 059 060 private static final long serialVersionUID = -150066367L; 061 062 /** 063 * Constructor 064 */ 065 public SECTION() { 066 super(); 067 } 068 069 /** 070 * @return {@link #items} (Ordered list of content items under this section, which may include: more SECTIONs; ENTRYs.) 071 */ 072 public List<CONTENT_ITEM> getItemsList() { 073 if (this.itemsList == null) 074 this.itemsList = new ArrayList<CONTENT_ITEM>(); 075 return this.itemsList; 076 } 077 078 /** 079 * @return Returns a reference to <code>this</code> for easy method chaining 080 */ 081 public SECTION setItemsList(List<CONTENT_ITEM> theItems) { 082 this.itemsList = theItems; 083 return this; 084 } 085 086 public boolean hasItems() { 087 if (this.itemsList == null) 088 return false; 089 for (CONTENT_ITEM item : this.itemsList) 090 if (!item.isEmpty()) 091 return true; 092 return false; 093 } 094 095 public SECTION addItems(CONTENT_ITEM t) { //3b 096 if (t == null) 097 return this; 098 if (this.itemsList == null) 099 this.itemsList = new ArrayList<CONTENT_ITEM>(); 100 this.itemsList.add(t); 101 return this; 102 } 103 104 protected void listChildren(List<Property> children) { 105 super.listChildren(children); 106 children.add(new Property("items", "http://openehr.org/fhir/StructureDefinition/CONTENT-ITEM", "Ordered list of content items under this section, which may include: more SECTIONs; ENTRYs.", 0, java.lang.Integer.MAX_VALUE, itemsList)); 107 } 108 109 @Override 110 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 111 switch (_hash) { 112 case 100526016: /*items*/ return new Property("items", "http://openehr.org/fhir/StructureDefinition/CONTENT-ITEM", "Ordered list of content items under this section, which may include: more SECTIONs; ENTRYs.", 0, java.lang.Integer.MAX_VALUE, itemsList); 113 default: return super.getNamedProperty(_hash, _name, _checkValid); 114 } 115 116 } 117 118 @Override 119 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 120 switch (hash) { 121 case 100526016: /*items*/ return this.itemsList == null ? new Base[0] : this.itemsList.toArray(new Base[this.itemsList.size()]); // CONTENT_ITEM 122 default: return super.getProperty(hash, name, checkValid); 123 } 124 125 } 126 127 @Override 128 public Base setProperty(int hash, String name, Base value) throws FHIRException { 129 switch (hash) { 130 case 100526016: // items 131 this.getItemsList().add((CONTENT_ITEM) value); // CONTENT_ITEM 132 return value; 133 default: return super.setProperty(hash, name, value); 134 } 135 136 } 137 138 @Override 139 public Base setProperty(String name, Base value) throws FHIRException { 140 if (name.equals("items")) { 141 this.getItemsList().add((CONTENT_ITEM) value); // CONTENT_ITEM 142 } else 143 return super.setProperty(name, value); 144 return value; 145 } 146 147 @Override 148 public Base makeProperty(int hash, String name) throws FHIRException { 149 switch (hash) { 150 case 100526016: /*div*/ 151 throw new Error("Unable to make an instance of the abstract property 'items'"); 152 default: return super.makeProperty(hash, name); 153 } 154 155 } 156 157 @Override 158 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 159 switch (hash) { 160 case 100526016: /*items*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/CONTENT-ITEM"}; 161 default: return super.getTypesForProperty(hash, name); 162 } 163 164 } 165 166 @Override 167 public Base addChild(String name) throws FHIRException { 168 if (name.equals("items")) { 169 throw new FHIRException("Cannot call addChild on an abstract type SECTION.items"); 170 } 171 else 172 return super.addChild(name); 173 } 174 175 public String fhirType() { 176 return "SECTION"; 177 178 } 179 180 public SECTION copy() { 181 SECTION dst = new SECTION(); 182 copyValues(dst); 183 return dst; 184 } 185 186 public void copyValues(SECTION dst) { 187 super.copyValues(dst); 188 if (itemsList != null) { 189 dst.itemsList = new ArrayList<CONTENT_ITEM>(); 190 for (CONTENT_ITEM i : itemsList) 191 dst.itemsList.add(i.copy()); 192 }; 193 } 194 195 protected SECTION typedCopy() { 196 return copy(); 197 } 198 199 @Override 200 public boolean equalsDeep(Base other_) { 201 if (!super.equalsDeep(other_)) 202 return false; 203 if (!(other_ instanceof SECTION)) 204 return false; 205 SECTION o = (SECTION) other_; 206 return compareDeep(itemsList, o.itemsList, true); 207 } 208 209 @Override 210 public boolean equalsShallow(Base other_) { 211 if (!super.equalsShallow(other_)) 212 return false; 213 if (!(other_ instanceof SECTION)) 214 return false; 215 SECTION o = (SECTION) other_; 216 return true; 217 } 218 219 public boolean isEmpty() { 220 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(itemsList); 221 } 222 223 224} 225