
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 * DEPRECATED: use markdown formatted DV_TEXT instead. Original definition: A logical composite text value consisting of a series of DV_TEXTs, i.e. plain text (optionally coded) potentially with simple formatting, to form a larger tract of prose, which may be interpreted for display purposes as a paragraph. 049 */ 050@DatatypeDef(name="DV_PARAGRAPH") 051public class DV_PARAGRAPH extends DATA_VALUE implements ICompositeType { 052 053 /** 054 * Items making up the paragraph, each of which is a text item (which may have its own formatting, and/or have hyperlinks). 055 */ 056 @Child(name = "items", type = {DV_TEXT.class}, order=0, min=0, max=Child.MAX_UNLIMITED, modifier=false, summary=false) 057 @Description(shortDefinition="Items making up the paragraph", formalDefinition="Items making up the paragraph, each of which is a text item (which may have its own formatting, and/or have hyperlinks)." ) 058 protected List<DV_TEXT> itemsList; 059 060 private static final long serialVersionUID = 356597994L; 061 062 /** 063 * Constructor 064 */ 065 public DV_PARAGRAPH() { 066 super(); 067 } 068 069 /** 070 * @return {@link #items} (Items making up the paragraph, each of which is a text item (which may have its own formatting, and/or have hyperlinks).) 071 */ 072 public List<DV_TEXT> getItemsList() { 073 if (this.itemsList == null) 074 this.itemsList = new ArrayList<DV_TEXT>(); 075 return this.itemsList; 076 } 077 078 /** 079 * @return Returns a reference to <code>this</code> for easy method chaining 080 */ 081 public DV_PARAGRAPH setItemsList(List<DV_TEXT> theItems) { 082 this.itemsList = theItems; 083 return this; 084 } 085 086 public boolean hasItems() { 087 if (this.itemsList == null) 088 return false; 089 for (DV_TEXT item : this.itemsList) 090 if (!item.isEmpty()) 091 return true; 092 return false; 093 } 094 095 public DV_TEXT addItems() { //3a 096 DV_TEXT t = new DV_TEXT(); 097 if (this.itemsList == null) 098 this.itemsList = new ArrayList<DV_TEXT>(); 099 this.itemsList.add(t); 100 return t; 101 } 102 103 public DV_PARAGRAPH addItems(DV_TEXT t) { //3b 104 if (t == null) 105 return this; 106 if (this.itemsList == null) 107 this.itemsList = new ArrayList<DV_TEXT>(); 108 this.itemsList.add(t); 109 return this; 110 } 111 112 /** 113 * @return The first repetition of repeating field {@link #items}, creating it if it does not already exist {3} 114 */ 115 public DV_TEXT getItemsFirstRep() { 116 if (getItemsList().isEmpty()) { 117 addItems(); 118 } 119 return getItemsList().get(0); 120 } 121 122 protected void listChildren(List<Property> children) { 123 super.listChildren(children); 124 children.add(new Property("items", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Items making up the paragraph, each of which is a text item (which may have its own formatting, and/or have hyperlinks).", 0, java.lang.Integer.MAX_VALUE, itemsList)); 125 } 126 127 @Override 128 public Property getNamedProperty(int _hash, String _name, boolean _checkValid) throws FHIRException { 129 switch (_hash) { 130 case 100526016: /*items*/ return new Property("items", "http://openehr.org/fhir/StructureDefinition/DV-TEXT", "Items making up the paragraph, each of which is a text item (which may have its own formatting, and/or have hyperlinks).", 0, java.lang.Integer.MAX_VALUE, itemsList); 131 default: return super.getNamedProperty(_hash, _name, _checkValid); 132 } 133 134 } 135 136 @Override 137 public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException { 138 switch (hash) { 139 case 100526016: /*items*/ return this.itemsList == null ? new Base[0] : this.itemsList.toArray(new Base[this.itemsList.size()]); // DV_TEXT 140 default: return super.getProperty(hash, name, checkValid); 141 } 142 143 } 144 145 @Override 146 public Base setProperty(int hash, String name, Base value) throws FHIRException { 147 switch (hash) { 148 case 100526016: // items 149 this.getItemsList().add((DV_TEXT) value); // DV_TEXT 150 return value; 151 default: return super.setProperty(hash, name, value); 152 } 153 154 } 155 156 @Override 157 public Base setProperty(String name, Base value) throws FHIRException { 158 if (name.equals("items")) { 159 this.getItemsList().add((DV_TEXT) value); // DV_TEXT 160 } else 161 return super.setProperty(name, value); 162 return value; 163 } 164 165 @Override 166 public Base makeProperty(int hash, String name) throws FHIRException { 167 switch (hash) { 168 case 100526016: return addItems(); 169 default: return super.makeProperty(hash, name); 170 } 171 172 } 173 174 @Override 175 public String[] getTypesForProperty(int hash, String name) throws FHIRException { 176 switch (hash) { 177 case 100526016: /*items*/ return new String[] {"http://openehr.org/fhir/StructureDefinition/DV-TEXT"}; 178 default: return super.getTypesForProperty(hash, name); 179 } 180 181 } 182 183 @Override 184 public Base addChild(String name) throws FHIRException { 185 if (name.equals("items")) { 186 return addItems(); 187 } 188 else 189 return super.addChild(name); 190 } 191 192 public String fhirType() { 193 return "DV_PARAGRAPH"; 194 195 } 196 197 public DV_PARAGRAPH copy() { 198 DV_PARAGRAPH dst = new DV_PARAGRAPH(); 199 copyValues(dst); 200 return dst; 201 } 202 203 public void copyValues(DV_PARAGRAPH dst) { 204 super.copyValues(dst); 205 if (itemsList != null) { 206 dst.itemsList = new ArrayList<DV_TEXT>(); 207 for (DV_TEXT i : itemsList) 208 dst.itemsList.add(i.copy()); 209 }; 210 } 211 212 protected DV_PARAGRAPH typedCopy() { 213 return copy(); 214 } 215 216 @Override 217 public boolean equalsDeep(Base other_) { 218 if (!super.equalsDeep(other_)) 219 return false; 220 if (!(other_ instanceof DV_PARAGRAPH)) 221 return false; 222 DV_PARAGRAPH o = (DV_PARAGRAPH) other_; 223 return compareDeep(itemsList, o.itemsList, true); 224 } 225 226 @Override 227 public boolean equalsShallow(Base other_) { 228 if (!super.equalsShallow(other_)) 229 return false; 230 if (!(other_ instanceof DV_PARAGRAPH)) 231 return false; 232 DV_PARAGRAPH o = (DV_PARAGRAPH) other_; 233 return true; 234 } 235 236 public boolean isEmpty() { 237 return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(itemsList); 238 } 239 240 241} 242