
001/* 002 * #%L 003 * HAPI FHIR - Core Library 004 * %% 005 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.rest.param; 021 022import ca.uhn.fhir.i18n.Msg; 023import ca.uhn.fhir.model.api.ICompositeDatatype; 024import ca.uhn.fhir.model.api.IElement; 025import ca.uhn.fhir.model.api.IQueryParameterType; 026import ca.uhn.fhir.model.api.annotation.Child; 027import ca.uhn.fhir.model.api.annotation.Description; 028import ca.uhn.fhir.model.base.composite.BaseCodingDt; 029import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; 030import ca.uhn.fhir.model.primitive.BooleanDt; 031import ca.uhn.fhir.model.primitive.CodeDt; 032import ca.uhn.fhir.model.primitive.StringDt; 033import ca.uhn.fhir.model.primitive.UriDt; 034import ca.uhn.fhir.util.CoverageIgnore; 035 036import java.util.List; 037 038@CoverageIgnore 039public class InternalCodingDt extends BaseCodingDt implements ICompositeDatatype { 040 041 private static final long serialVersionUID = 993056016725918652L; 042 043 /** 044 * Constructor 045 */ 046 public InternalCodingDt() { 047 super(); 048 } 049 050 /** 051 * Creates a new Coding with the given system and code 052 */ 053 public InternalCodingDt(String theSystem, String theCode) { 054 setSystem(theSystem); 055 setCode(theCode); 056 } 057 058 @Child(name = "system", type = UriDt.class, order = 0, min = 0, max = 1) 059 @Description(shortDefinition = "Identity of the terminology system", formalDefinition = "The identification of the code system that defines the meaning of the symbol in the code.") 060 private UriDt mySystem; 061 062 @Child(name = "version", type = StringDt.class, order = 1, min = 0, max = 1) 063 @Description(shortDefinition = "Version of the system - if relevant", formalDefinition = "The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged") 064 private StringDt myVersion; 065 066 @Child(name = "code", type = CodeDt.class, order = 2, min = 0, max = 1) 067 @Description(shortDefinition = "Symbol in syntax defined by the system", formalDefinition = "A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination)") 068 private CodeDt myCode; 069 070 @Child(name = "display", type = StringDt.class, order = 3, min = 0, max = 1) 071 @Description(shortDefinition = "Representation defined by the system", formalDefinition = "A representation of the meaning of the code in the system, following the rules of the system.") 072 private StringDt myDisplay; 073 074 @Child(name = "primary", type = BooleanDt.class, order = 4, min = 0, max = 1) 075 @Description(shortDefinition = "If this code was chosen directly by the user", formalDefinition = "Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays)") 076 private BooleanDt myPrimary; 077 078 @Override 079 public boolean isEmpty() { 080 return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(mySystem, myVersion, myCode, myDisplay, myPrimary); 081 } 082 083 @Deprecated //override deprecated method 084 @Override 085 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) { 086 return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, mySystem, myVersion, myCode, myDisplay, myPrimary); 087 } 088 089 /** 090 * Gets the value(s) for <b>system</b> (Identity of the terminology system). creating it if it does not exist. Will not return <code>null</code>. 091 * 092 * <p> 093 * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code. 094 * </p> 095 */ 096 @Override 097 public UriDt getSystemElement() { 098 if (mySystem == null) { 099 mySystem = new UriDt(); 100 } 101 return mySystem; 102 } 103 104 /** 105 * Sets the value(s) for <b>system</b> (Identity of the terminology system) 106 * 107 * <p> 108 * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code. 109 * </p> 110 */ 111 public InternalCodingDt setSystem(UriDt theValue) { 112 mySystem = theValue; 113 return this; 114 } 115 116 /** 117 * Sets the value for <b>system</b> (Identity of the terminology system) 118 * 119 * <p> 120 * <b>Definition:</b> The identification of the code system that defines the meaning of the symbol in the code. 121 * </p> 122 */ 123 @Override 124 public InternalCodingDt setSystem(String theUri) { 125 mySystem = new UriDt(theUri); 126 return this; 127 } 128 129 /** 130 * Gets the value(s) for <b>version</b> (Version of the system - if relevant). creating it if it does not exist. Will not return <code>null</code>. 131 * 132 * <p> 133 * <b>Definition:</b> The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes 134 * is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged 135 * </p> 136 */ 137 public StringDt getVersion() { 138 if (myVersion == null) { 139 myVersion = new StringDt(); 140 } 141 return myVersion; 142 } 143 144 /** 145 * Sets the value(s) for <b>version</b> (Version of the system - if relevant) 146 * 147 * <p> 148 * <b>Definition:</b> The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes 149 * is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged 150 * </p> 151 */ 152 public InternalCodingDt setVersion(StringDt theValue) { 153 myVersion = theValue; 154 return this; 155 } 156 157 /** 158 * Sets the value for <b>version</b> (Version of the system - if relevant) 159 * 160 * <p> 161 * <b>Definition:</b> The version of the code system which was used when choosing this code. Note that a well-maintained code system does not need the version reported, because the meaning of codes 162 * is consistent across versions. However this cannot consistently be assured. and When the meaning is not guaranteed to be consistent, the version SHOULD be exchanged 163 * </p> 164 */ 165 public InternalCodingDt setVersion(String theString) { 166 myVersion = new StringDt(theString); 167 return this; 168 } 169 170 /** 171 * Gets the value(s) for <b>code</b> (Symbol in syntax defined by the system). creating it if it does not exist. Will not return <code>null</code>. 172 * 173 * <p> 174 * <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination) 175 * </p> 176 */ 177 @Override 178 public CodeDt getCodeElement() { 179 if (myCode == null) { 180 myCode = new CodeDt(); 181 } 182 return myCode; 183 } 184 185 /** 186 * Sets the value(s) for <b>code</b> (Symbol in syntax defined by the system) 187 * 188 * <p> 189 * <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination) 190 * </p> 191 */ 192 public InternalCodingDt setCode(CodeDt theValue) { 193 myCode = theValue; 194 return this; 195 } 196 197 /** 198 * Sets the value for <b>code</b> (Symbol in syntax defined by the system) 199 * 200 * <p> 201 * <b>Definition:</b> A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post-coordination) 202 * </p> 203 */ 204 @Override 205 public InternalCodingDt setCode(String theCode) { 206 myCode = new CodeDt(theCode); 207 return this; 208 } 209 210 /** 211 * Gets the value(s) for <b>display</b> (Representation defined by the system). creating it if it does not exist. Will not return <code>null</code>. 212 * 213 * <p> 214 * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system. 215 * </p> 216 */ 217 public StringDt getDisplay() { 218 if (myDisplay == null) { 219 myDisplay = new StringDt(); 220 } 221 return myDisplay; 222 } 223 224 /** 225 * Sets the value(s) for <b>display</b> (Representation defined by the system) 226 * 227 * <p> 228 * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system. 229 * </p> 230 */ 231 public InternalCodingDt setDisplay(StringDt theValue) { 232 myDisplay = theValue; 233 return this; 234 } 235 236 /** 237 * Sets the value for <b>display</b> (Representation defined by the system) 238 * 239 * <p> 240 * <b>Definition:</b> A representation of the meaning of the code in the system, following the rules of the system. 241 * </p> 242 */ 243 @Override 244 public InternalCodingDt setDisplay(String theString) { 245 myDisplay = new StringDt(theString); 246 return this; 247 } 248 249 /** 250 * Gets the value(s) for <b>primary</b> (If this code was chosen directly by the user). creating it if it does not exist. Will not return <code>null</code>. 251 * 252 * <p> 253 * <b>Definition:</b> Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays) 254 * </p> 255 */ 256 public BooleanDt getPrimary() { 257 if (myPrimary == null) { 258 myPrimary = new BooleanDt(); 259 } 260 return myPrimary; 261 } 262 263 /** 264 * Sets the value(s) for <b>primary</b> (If this code was chosen directly by the user) 265 * 266 * <p> 267 * <b>Definition:</b> Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays) 268 * </p> 269 */ 270 public InternalCodingDt setPrimary(BooleanDt theValue) { 271 myPrimary = theValue; 272 return this; 273 } 274 275 /** 276 * Sets the value for <b>primary</b> (If this code was chosen directly by the user) 277 * 278 * <p> 279 * <b>Definition:</b> Indicates that this code was chosen by a user directly - i.e. off a pick list of available items (codes or displays) 280 * </p> 281 */ 282 public InternalCodingDt setPrimary(boolean theBoolean) { 283 myPrimary = new BooleanDt(theBoolean); 284 return this; 285 } 286 287 /** 288 * Gets the value(s) for <b>valueSet</b> (Set this coding was chosen from). creating it if it does not exist. Will not return <code>null</code>. 289 * 290 * <p> 291 * <b>Definition:</b> The set of possible coded values this coding was chosen from or constrained by 292 * </p> 293 */ 294 public BaseResourceReferenceDt getValueSet() { 295 throw new UnsupportedOperationException(Msg.code(1949)); 296 } 297 298 @Override 299 public StringDt getDisplayElement() { 300 return getDisplay(); 301 } 302 303 @Deprecated //override deprecated method 304 @Override 305 public Boolean getMissing() { 306 throw new UnsupportedOperationException(Msg.code(1950)); 307 } 308 309 @Deprecated //override deprecated method 310 @Override 311 public IQueryParameterType setMissing(Boolean theMissing) { 312 throw new UnsupportedOperationException(Msg.code(1951)); 313 } 314 315}