
001package org.hl7.fhir.convertors.conv40_50.resources40_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext40_50; 004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Coding40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.ContactPoint40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Url40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 011import org.hl7.fhir.exceptions.FHIRException; 012import org.hl7.fhir.r5.model.Enumeration; 013import org.hl7.fhir.r5.model.MessageHeader; 014 015/* 016 Copyright (c) 2011+, HL7, Inc. 017 All rights reserved. 018 019 Redistribution and use in source and binary forms, with or without modification, 020 are permitted provided that the following conditions are met: 021 022 * Redistributions of source code must retain the above copyright notice, this 023 list of conditions and the following disclaimer. 024 * Redistributions in binary form must reproduce the above copyright notice, 025 this list of conditions and the following disclaimer in the documentation 026 and/or other materials provided with the distribution. 027 * Neither the name of HL7 nor the names of its contributors may be used to 028 endorse or promote products derived from this software without specific 029 prior written permission. 030 031 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 032 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 033 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 034 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 035 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 036 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 037 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 038 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 039 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 040 POSSIBILITY OF SUCH DAMAGE. 041 042*/ 043// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 044public class MessageHeader40_50 { 045 046 public static org.hl7.fhir.r5.model.MessageHeader convertMessageHeader(org.hl7.fhir.r4.model.MessageHeader src) throws FHIRException { 047 if (src == null) 048 return null; 049 org.hl7.fhir.r5.model.MessageHeader tgt = new org.hl7.fhir.r5.model.MessageHeader(); 050 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 051 if (src.hasEventUriType()) 052 tgt.setEvent(Canonical40_50.convertUriToCanonical(src.getEventUriType())); 053 if (src.hasEventCoding()) 054 tgt.setEvent(Coding40_50.convertCoding(src.getEventCoding())); 055 056 for (org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) 057 tgt.addDestination(convertMessageDestinationComponent(t)); 058 if (src.hasSender()) 059 tgt.setSender(Reference40_50.convertReference(src.getSender())); 060// if (src.hasEnterer()) 061// tgt.setEnterer(Reference40_50.convertReference(src.getEnterer())); 062 if (src.hasAuthor()) 063 tgt.setAuthor(Reference40_50.convertReference(src.getAuthor())); 064 if (src.hasSource()) 065 tgt.setSource(convertMessageSourceComponent(src.getSource())); 066 if (src.hasResponsible()) 067 tgt.setResponsible(Reference40_50.convertReference(src.getResponsible())); 068 if (src.hasReason()) 069 tgt.setReason(CodeableConcept40_50.convertCodeableConcept(src.getReason())); 070 if (src.hasResponse()) 071 tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); 072 for (org.hl7.fhir.r4.model.Reference t : src.getFocus()) tgt.addFocus(Reference40_50.convertReference(t)); 073 if (src.hasDefinition()) 074 tgt.setDefinitionElement(Canonical40_50.convertCanonical(src.getDefinitionElement())); 075 return tgt; 076 } 077 078 public static org.hl7.fhir.r4.model.MessageHeader convertMessageHeader(org.hl7.fhir.r5.model.MessageHeader src) throws FHIRException { 079 if (src == null) 080 return null; 081 org.hl7.fhir.r4.model.MessageHeader tgt = new org.hl7.fhir.r4.model.MessageHeader(); 082 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 083 if (src.hasEventCanonicalType()) 084 tgt.setEvent(Canonical40_50.convertCanonicalToUri(src.getEventCanonicalType())); 085 if (src.hasEventCoding()) 086 tgt.setEvent(Coding40_50.convertCoding(src.getEventCoding())); 087 for (org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) 088 tgt.addDestination(convertMessageDestinationComponent(t)); 089 if (src.hasSender()) 090 tgt.setSender(Reference40_50.convertReference(src.getSender())); 091// if (src.hasEnterer()) 092// tgt.setEnterer(Reference40_50.convertReference(src.getEnterer())); 093 if (src.hasAuthor()) 094 tgt.setAuthor(Reference40_50.convertReference(src.getAuthor())); 095 if (src.hasSource()) 096 tgt.setSource(convertMessageSourceComponent(src.getSource())); 097 if (src.hasResponsible()) 098 tgt.setResponsible(Reference40_50.convertReference(src.getResponsible())); 099 if (src.hasReason()) 100 tgt.setReason(CodeableConcept40_50.convertCodeableConcept(src.getReason())); 101 if (src.hasResponse()) 102 tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); 103 for (org.hl7.fhir.r5.model.Reference t : src.getFocus()) tgt.addFocus(Reference40_50.convertReference(t)); 104 if (src.hasDefinition()) 105 tgt.setDefinitionElement(Canonical40_50.convertCanonical(src.getDefinitionElement())); 106 return tgt; 107 } 108 109 public static org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { 110 if (src == null) 111 return null; 112 org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent(); 113 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 114 if (src.hasName()) 115 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 116 if (src.hasTarget()) 117 tgt.setTarget(Reference40_50.convertReference(src.getTarget())); 118 if (src.hasEndpoint()) { 119 tgt.setEndpoint(Url40_50.convertUrl(src.getEndpointElement())); 120 } 121 if (src.hasReceiver()) 122 tgt.setReceiver(Reference40_50.convertReference(src.getReceiver())); 123 return tgt; 124 } 125 126 public static org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { 127 if (src == null) 128 return null; 129 org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent(); 130 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 131 if (src.hasName()) 132 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 133 if (src.hasTarget()) 134 tgt.setTarget(Reference40_50.convertReference(src.getTarget())); 135 if (src.hasEndpointUrlType()) { 136 tgt.setEndpointElement(Url40_50.convertUrl(src.getEndpointUrlType())); 137 } 138 if (src.hasReceiver()) 139 tgt.setReceiver(Reference40_50.convertReference(src.getReceiver())); 140 return tgt; 141 } 142 143 public static org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent src) throws FHIRException { 144 if (src == null) 145 return null; 146 org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent(); 147 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 148 if (src.hasName()) 149 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 150 if (src.hasSoftware()) 151 tgt.setSoftwareElement(String40_50.convertString(src.getSoftwareElement())); 152 if (src.hasVersion()) 153 tgt.setVersionElement(String40_50.convertString(src.getVersionElement())); 154 if (src.hasContact()) 155 tgt.setContact(ContactPoint40_50.convertContactPoint(src.getContact())); 156 if (src.hasEndpoint()) 157 tgt.setEndpoint(Url40_50.convertUrl(src.getEndpointElement())); 158 return tgt; 159 } 160 161 public static org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent src) throws FHIRException { 162 if (src == null) 163 return null; 164 org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent(); 165 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 166 if (src.hasName()) 167 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 168 if (src.hasSoftware()) 169 tgt.setSoftwareElement(String40_50.convertString(src.getSoftwareElement())); 170 if (src.hasVersion()) 171 tgt.setVersionElement(String40_50.convertString(src.getVersionElement())); 172 if (src.hasContact()) 173 tgt.setContact(ContactPoint40_50.convertContactPoint(src.getContact())); 174 if (src.hasEndpointUrlType()) 175 tgt.setEndpointElement(Url40_50.convertUrl(src.getEndpointUrlType())); 176 return tgt; 177 } 178 179 public static org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { 180 if (src == null) 181 return null; 182 org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent(); 183 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 184 if (src.hasIdentifier()) 185 tgt.setIdentifier(new org.hl7.fhir.r5.model.Identifier().setValue(src.getIdentifier())); 186 if (src.hasCode()) 187 tgt.setCodeElement(convertResponseType(src.getCodeElement())); 188 if (src.hasDetails()) 189 tgt.setDetails(Reference40_50.convertReference(src.getDetails())); 190 return tgt; 191 } 192 193 public static org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { 194 if (src == null) 195 return null; 196 org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent(); 197 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 198 if (src.hasIdentifier()) 199 tgt.setIdentifierElement(new org.hl7.fhir.r4.model.IdType(src.getIdentifier().getValue())); 200 if (src.hasCode()) 201 tgt.setCodeElement(convertResponseType(src.getCodeElement())); 202 if (src.hasDetails()) 203 tgt.setDetails(Reference40_50.convertReference(src.getDetails())); 204 return tgt; 205 } 206 207 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageHeader.ResponseType> convertResponseType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageHeader.ResponseType> src) throws FHIRException { 208 if (src == null || src.isEmpty()) 209 return null; 210 Enumeration<MessageHeader.ResponseType> tgt = new Enumeration<>(new MessageHeader.ResponseTypeEnumFactory()); 211 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 212 if (src.getValue() == null) { 213 tgt.setValue(null); 214 } else { 215 switch (src.getValue()) { 216 case OK: 217 tgt.setValue(MessageHeader.ResponseType.OK); 218 break; 219 case TRANSIENTERROR: 220 tgt.setValue(MessageHeader.ResponseType.TRANSIENTERROR); 221 break; 222 case FATALERROR: 223 tgt.setValue(MessageHeader.ResponseType.FATALERROR); 224 break; 225 default: 226 tgt.setValue(MessageHeader.ResponseType.NULL); 227 break; 228 } 229 } 230 return tgt; 231 } 232 233 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageHeader.ResponseType> convertResponseType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageHeader.ResponseType> src) throws FHIRException { 234 if (src == null || src.isEmpty()) 235 return null; 236 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageHeader.ResponseType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.MessageHeader.ResponseTypeEnumFactory()); 237 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 238 if (src.getValue() == null) { 239 tgt.setValue(null); 240 } else { 241 switch (src.getValue()) { 242 case OK: 243 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.OK); 244 break; 245 case TRANSIENTERROR: 246 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.TRANSIENTERROR); 247 break; 248 case FATALERROR: 249 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.FATALERROR); 250 break; 251 default: 252 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.NULL); 253 break; 254 } 255 } 256 return tgt; 257 } 258}