![](/hapi-fhir/images/logos/raccoon-forwards.png)
001package org.hl7.fhir.convertors.conv43_50.resources43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Annotation43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 010import org.hl7.fhir.exceptions.FHIRException; 011import org.hl7.fhir.r5.model.CodeableReference; 012 013/* 014 Copyright (c) 2011+, HL7, Inc. 015 All rights reserved. 016 017 Redistribution and use in source and binary forms, with or without modification, 018 are permitted provided that the following conditions are met: 019 020 * Redistributions of source code must retain the above copyright notice, this 021 list of conditions and the following disclaimer. 022 * Redistributions in binary form must reproduce the above copyright notice, 023 this list of conditions and the following disclaimer in the documentation 024 and/or other materials provided with the distribution. 025 * Neither the name of HL7 nor the names of its contributors may be used to 026 endorse or promote products derived from this software without specific 027 prior written permission. 028 029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 030 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 031 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 032 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 033 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 034 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 035 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 036 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 037 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 038 POSSIBILITY OF SUCH DAMAGE. 039 040*/ 041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 042public class CommunicationRequest43_50 { 043 044 public final static String EXT_PAYLOAD_CONTENT = "http://hl7.org/fhir/4.0/StructureDefinition/extension-CommunicationRequest.payload.content"; 045 046 public static org.hl7.fhir.r5.model.CommunicationRequest convertCommunicationRequest(org.hl7.fhir.r4b.model.CommunicationRequest src) throws FHIRException { 047 if (src == null) 048 return null; 049 org.hl7.fhir.r5.model.CommunicationRequest tgt = new org.hl7.fhir.r5.model.CommunicationRequest(); 050 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 051 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 052 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 053 for (org.hl7.fhir.r4b.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t)); 054 for (org.hl7.fhir.r4b.model.Reference t : src.getReplaces()) tgt.addReplaces(Reference43_50.convertReference(t)); 055 if (src.hasGroupIdentifier()) 056 tgt.setGroupIdentifier(Identifier43_50.convertIdentifier(src.getGroupIdentifier())); 057 if (src.hasStatus()) 058 tgt.setStatusElement(convertCommunicationRequestStatus(src.getStatusElement())); 059 if (src.hasStatusReason()) 060 tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason())); 061 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCategory()) 062 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t)); 063 if (src.hasPriority()) 064 tgt.setPriorityElement(convertCommunicationPriority(src.getPriorityElement())); 065 if (src.hasDoNotPerform()) 066 tgt.setDoNotPerformElement(Boolean43_50.convertBoolean(src.getDoNotPerformElement())); 067 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getMedium()) 068 tgt.addMedium(CodeableConcept43_50.convertCodeableConcept(t)); 069 if (src.hasSubject()) 070 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 071 for (org.hl7.fhir.r4b.model.Reference t : src.getAbout()) tgt.addAbout(Reference43_50.convertReference(t)); 072 if (src.hasEncounter()) 073 tgt.setEncounter(Reference43_50.convertReference(src.getEncounter())); 074 for (org.hl7.fhir.r4b.model.CommunicationRequest.CommunicationRequestPayloadComponent t : src.getPayload()) 075 tgt.addPayload(convertCommunicationRequestPayloadComponent(t)); 076 if (src.hasOccurrence()) 077 tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence())); 078 if (src.hasAuthoredOn()) 079 tgt.setAuthoredOnElement(DateTime43_50.convertDateTime(src.getAuthoredOnElement())); 080 if (src.hasRequester()) 081 tgt.setRequester(Reference43_50.convertReference(src.getRequester())); 082 for (org.hl7.fhir.r4b.model.Reference t : src.getRecipient()) tgt.addRecipient(Reference43_50.convertReference(t)); 083 if (src.hasSender()) 084 tgt.addInformationProvider(Reference43_50.convertReference(src.getSender())); 085 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getReasonCode()) 086 tgt.addReason(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t)); 087 for (org.hl7.fhir.r4b.model.Reference t : src.getReasonReference()) 088 tgt.addReason(Reference43_50.convertReferenceToCodeableReference(t)); 089 for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t)); 090 return tgt; 091 } 092 093 public static org.hl7.fhir.r4b.model.CommunicationRequest convertCommunicationRequest(org.hl7.fhir.r5.model.CommunicationRequest src) throws FHIRException { 094 if (src == null) 095 return null; 096 org.hl7.fhir.r4b.model.CommunicationRequest tgt = new org.hl7.fhir.r4b.model.CommunicationRequest(); 097 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 098 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 099 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 100 for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference43_50.convertReference(t)); 101 for (org.hl7.fhir.r5.model.Reference t : src.getReplaces()) tgt.addReplaces(Reference43_50.convertReference(t)); 102 if (src.hasGroupIdentifier()) 103 tgt.setGroupIdentifier(Identifier43_50.convertIdentifier(src.getGroupIdentifier())); 104 if (src.hasStatus()) 105 tgt.setStatusElement(convertCommunicationRequestStatus(src.getStatusElement())); 106 if (src.hasStatusReason()) 107 tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason())); 108 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 109 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t)); 110 if (src.hasPriority()) 111 tgt.setPriorityElement(convertCommunicationPriority(src.getPriorityElement())); 112 if (src.hasDoNotPerform()) 113 tgt.setDoNotPerformElement(Boolean43_50.convertBoolean(src.getDoNotPerformElement())); 114 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getMedium()) 115 tgt.addMedium(CodeableConcept43_50.convertCodeableConcept(t)); 116 if (src.hasSubject()) 117 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 118 for (org.hl7.fhir.r5.model.Reference t : src.getAbout()) tgt.addAbout(Reference43_50.convertReference(t)); 119 if (src.hasEncounter()) 120 tgt.setEncounter(Reference43_50.convertReference(src.getEncounter())); 121 for (org.hl7.fhir.r5.model.CommunicationRequest.CommunicationRequestPayloadComponent t : src.getPayload()) 122 tgt.addPayload(convertCommunicationRequestPayloadComponent(t)); 123 if (src.hasOccurrence()) 124 tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence())); 125 if (src.hasAuthoredOn()) 126 tgt.setAuthoredOnElement(DateTime43_50.convertDateTime(src.getAuthoredOnElement())); 127 if (src.hasRequester()) 128 tgt.setRequester(Reference43_50.convertReference(src.getRequester())); 129 for (org.hl7.fhir.r5.model.Reference t : src.getRecipient()) tgt.addRecipient(Reference43_50.convertReference(t)); 130 if (src.hasInformationProvider()) 131 tgt.setSender(Reference43_50.convertReference(src.getInformationProviderFirstRep())); 132 for (CodeableReference t : src.getReason()) 133 if (t.hasConcept()) 134 tgt.addReasonCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept())); 135 for (CodeableReference t : src.getReason()) 136 if (t.hasReference()) 137 tgt.addReasonReference(Reference43_50.convertReference(t.getReference())); 138 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t)); 139 return tgt; 140 } 141 142 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> convertCommunicationRequestStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.RequestStatus> src) throws FHIRException { 143 if (src == null || src.isEmpty()) 144 return null; 145 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestStatusEnumFactory()); 146 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 147 switch (src.getValue()) { 148 case DRAFT: 149 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.DRAFT); 150 break; 151 case ACTIVE: 152 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ACTIVE); 153 break; 154 case ONHOLD: 155 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ONHOLD); 156 break; 157 case REVOKED: 158 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.REVOKED); 159 break; 160 case COMPLETED: 161 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.COMPLETED); 162 break; 163 case ENTEREDINERROR: 164 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ENTEREDINERROR); 165 break; 166 case UNKNOWN: 167 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.UNKNOWN); 168 break; 169 default: 170 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.NULL); 171 break; 172 } 173 return tgt; 174 } 175 176 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.RequestStatus> convertCommunicationRequestStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> src) throws FHIRException { 177 if (src == null || src.isEmpty()) 178 return null; 179 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.RequestStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.RequestStatusEnumFactory()); 180 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 181 switch (src.getValue()) { 182 case DRAFT: 183 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.DRAFT); 184 break; 185 case ACTIVE: 186 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.ACTIVE); 187 break; 188 case ONHOLD: 189 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.ONHOLD); 190 break; 191 case REVOKED: 192 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.REVOKED); 193 break; 194 case COMPLETED: 195 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.COMPLETED); 196 break; 197 case ENTEREDINERROR: 198 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.ENTEREDINERROR); 199 break; 200 case UNKNOWN: 201 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.UNKNOWN); 202 break; 203 default: 204 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestStatus.NULL); 205 break; 206 } 207 return tgt; 208 } 209 210 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> convertCommunicationPriority(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.RequestPriority> src) throws FHIRException { 211 if (src == null || src.isEmpty()) 212 return null; 213 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestPriorityEnumFactory()); 214 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 215 switch (src.getValue()) { 216 case ROUTINE: 217 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ROUTINE); 218 break; 219 case URGENT: 220 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.URGENT); 221 break; 222 case ASAP: 223 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.ASAP); 224 break; 225 case STAT: 226 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.STAT); 227 break; 228 default: 229 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestPriority.NULL); 230 break; 231 } 232 return tgt; 233 } 234 235 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.RequestPriority> convertCommunicationPriority(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestPriority> src) throws FHIRException { 236 if (src == null || src.isEmpty()) 237 return null; 238 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.RequestPriority> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.RequestPriorityEnumFactory()); 239 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 240 switch (src.getValue()) { 241 case ROUTINE: 242 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestPriority.ROUTINE); 243 break; 244 case URGENT: 245 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestPriority.URGENT); 246 break; 247 case ASAP: 248 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestPriority.ASAP); 249 break; 250 case STAT: 251 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestPriority.STAT); 252 break; 253 default: 254 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.RequestPriority.NULL); 255 break; 256 } 257 return tgt; 258 } 259 260 public static org.hl7.fhir.r5.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.r4b.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException { 261 if (src == null) 262 return null; 263 org.hl7.fhir.r5.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.r5.model.CommunicationRequest.CommunicationRequestPayloadComponent(); 264 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 265 if (org.hl7.fhir.r4b.utils.ToolingExtensions.hasExtension(src, EXT_PAYLOAD_CONTENT)) { 266 org.hl7.fhir.r4b.model.Extension e = org.hl7.fhir.r4b.utils.ToolingExtensions.getExtension(src, EXT_PAYLOAD_CONTENT); 267 tgt.setContent(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(e.getValue())); 268 org.hl7.fhir.r5.utils.ToolingExtensions.removeExtension(tgt, EXT_PAYLOAD_CONTENT); 269 } else if (src.hasContent()) { 270 org.hl7.fhir.r4b.model.DataType content = src.getContent(); 271 if (content instanceof org.hl7.fhir.r4b.model.StringType) { 272 org.hl7.fhir.r4b.model.StringType string = (org.hl7.fhir.r4b.model.StringType) content; 273 org.hl7.fhir.r5.model.CodeableConcept code = new org.hl7.fhir.r5.model.CodeableConcept(); 274 code.setTextElement((org.hl7.fhir.r5.model.StringType) ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(string)); 275 tgt.setContent(code); 276 } else 277 tgt.setContent(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(content)); 278 } 279 return tgt; 280 } 281 282 public static org.hl7.fhir.r4b.model.CommunicationRequest.CommunicationRequestPayloadComponent convertCommunicationRequestPayloadComponent(org.hl7.fhir.r5.model.CommunicationRequest.CommunicationRequestPayloadComponent src) throws FHIRException { 283 if (src == null) 284 return null; 285 org.hl7.fhir.r4b.model.CommunicationRequest.CommunicationRequestPayloadComponent tgt = new org.hl7.fhir.r4b.model.CommunicationRequest.CommunicationRequestPayloadComponent(); 286 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 287 if (src.hasContent()) { 288 org.hl7.fhir.r5.model.DataType content = src.getContent(); 289 if (content instanceof org.hl7.fhir.r5.model.CodeableConcept) { 290 org.hl7.fhir.r5.model.CodeableConcept code = (org.hl7.fhir.r5.model.CodeableConcept) content; 291 if (code.hasText()) 292 tgt.setContent(new org.hl7.fhir.r4b.model.StringType(code.getText())); 293 if (code.hasCoding() || code.hasExtension()) { 294 org.hl7.fhir.r4b.model.Extension e = new org.hl7.fhir.r4b.model.Extension(EXT_PAYLOAD_CONTENT); 295 e.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(code)); 296 tgt.addExtension(e); 297 } 298 } else 299 tgt.setContent(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(content)); 300 } 301 return tgt; 302 } 303}