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