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