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.ContactPoint40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Id40_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; 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 MessageHeader40_50 { 043 044 public static org.hl7.fhir.r5.model.MessageHeader convertMessageHeader(org.hl7.fhir.r4.model.MessageHeader src) throws FHIRException { 045 if (src == null) 046 return null; 047 org.hl7.fhir.r5.model.MessageHeader tgt = new org.hl7.fhir.r5.model.MessageHeader(); 048 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 049 if (src.hasEvent()) 050 tgt.setEvent(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getEvent())); 051 for (org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) 052 tgt.addDestination(convertMessageDestinationComponent(t)); 053 if (src.hasSender()) 054 tgt.setSender(Reference40_50.convertReference(src.getSender())); 055 if (src.hasEnterer()) 056 tgt.setEnterer(Reference40_50.convertReference(src.getEnterer())); 057 if (src.hasAuthor()) 058 tgt.setAuthor(Reference40_50.convertReference(src.getAuthor())); 059 if (src.hasSource()) 060 tgt.setSource(convertMessageSourceComponent(src.getSource())); 061 if (src.hasResponsible()) 062 tgt.setResponsible(Reference40_50.convertReference(src.getResponsible())); 063 if (src.hasReason()) 064 tgt.setReason(CodeableConcept40_50.convertCodeableConcept(src.getReason())); 065 if (src.hasResponse()) 066 tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); 067 for (org.hl7.fhir.r4.model.Reference t : src.getFocus()) tgt.addFocus(Reference40_50.convertReference(t)); 068 if (src.hasDefinition()) 069 tgt.setDefinitionElement(Canonical40_50.convertCanonical(src.getDefinitionElement())); 070 return tgt; 071 } 072 073 public static org.hl7.fhir.r4.model.MessageHeader convertMessageHeader(org.hl7.fhir.r5.model.MessageHeader src) throws FHIRException { 074 if (src == null) 075 return null; 076 org.hl7.fhir.r4.model.MessageHeader tgt = new org.hl7.fhir.r4.model.MessageHeader(); 077 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 078 if (src.hasEvent()) 079 tgt.setEvent(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getEvent())); 080 for (org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent t : src.getDestination()) 081 tgt.addDestination(convertMessageDestinationComponent(t)); 082 if (src.hasSender()) 083 tgt.setSender(Reference40_50.convertReference(src.getSender())); 084 if (src.hasEnterer()) 085 tgt.setEnterer(Reference40_50.convertReference(src.getEnterer())); 086 if (src.hasAuthor()) 087 tgt.setAuthor(Reference40_50.convertReference(src.getAuthor())); 088 if (src.hasSource()) 089 tgt.setSource(convertMessageSourceComponent(src.getSource())); 090 if (src.hasResponsible()) 091 tgt.setResponsible(Reference40_50.convertReference(src.getResponsible())); 092 if (src.hasReason()) 093 tgt.setReason(CodeableConcept40_50.convertCodeableConcept(src.getReason())); 094 if (src.hasResponse()) 095 tgt.setResponse(convertMessageHeaderResponseComponent(src.getResponse())); 096 for (org.hl7.fhir.r5.model.Reference t : src.getFocus()) tgt.addFocus(Reference40_50.convertReference(t)); 097 if (src.hasDefinition()) 098 tgt.setDefinitionElement(Canonical40_50.convertCanonical(src.getDefinitionElement())); 099 return tgt; 100 } 101 102 public static org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { 103 if (src == null) 104 return null; 105 org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent(); 106 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 107 if (src.hasName()) 108 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 109 if (src.hasTarget()) 110 tgt.setTarget(Reference40_50.convertReference(src.getTarget())); 111 if (src.hasEndpoint()) 112 tgt.setEndpointElement(Url40_50.convertUrl(src.getEndpointElement())); 113 if (src.hasReceiver()) 114 tgt.setReceiver(Reference40_50.convertReference(src.getReceiver())); 115 return tgt; 116 } 117 118 public static org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent convertMessageDestinationComponent(org.hl7.fhir.r5.model.MessageHeader.MessageDestinationComponent src) throws FHIRException { 119 if (src == null) 120 return null; 121 org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent(); 122 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 123 if (src.hasName()) 124 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 125 if (src.hasTarget()) 126 tgt.setTarget(Reference40_50.convertReference(src.getTarget())); 127 if (src.hasEndpoint()) 128 tgt.setEndpointElement(Url40_50.convertUrl(src.getEndpointElement())); 129 if (src.hasReceiver()) 130 tgt.setReceiver(Reference40_50.convertReference(src.getReceiver())); 131 return tgt; 132 } 133 134 public static org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent src) throws FHIRException { 135 if (src == null) 136 return null; 137 org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent(); 138 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 139 if (src.hasName()) 140 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 141 if (src.hasSoftware()) 142 tgt.setSoftwareElement(String40_50.convertString(src.getSoftwareElement())); 143 if (src.hasVersion()) 144 tgt.setVersionElement(String40_50.convertString(src.getVersionElement())); 145 if (src.hasContact()) 146 tgt.setContact(ContactPoint40_50.convertContactPoint(src.getContact())); 147 if (src.hasEndpoint()) 148 tgt.setEndpointElement(Url40_50.convertUrl(src.getEndpointElement())); 149 return tgt; 150 } 151 152 public static org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent convertMessageSourceComponent(org.hl7.fhir.r5.model.MessageHeader.MessageSourceComponent src) throws FHIRException { 153 if (src == null) 154 return null; 155 org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent(); 156 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 157 if (src.hasName()) 158 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 159 if (src.hasSoftware()) 160 tgt.setSoftwareElement(String40_50.convertString(src.getSoftwareElement())); 161 if (src.hasVersion()) 162 tgt.setVersionElement(String40_50.convertString(src.getVersionElement())); 163 if (src.hasContact()) 164 tgt.setContact(ContactPoint40_50.convertContactPoint(src.getContact())); 165 if (src.hasEndpoint()) 166 tgt.setEndpointElement(Url40_50.convertUrl(src.getEndpointElement())); 167 return tgt; 168 } 169 170 public static org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { 171 if (src == null) 172 return null; 173 org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent(); 174 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 175 if (src.hasIdentifier()) 176 tgt.setIdentifierElement(Id40_50.convertId(src.getIdentifierElement())); 177 if (src.hasCode()) 178 tgt.setCodeElement(convertResponseType(src.getCodeElement())); 179 if (src.hasDetails()) 180 tgt.setDetails(Reference40_50.convertReference(src.getDetails())); 181 return tgt; 182 } 183 184 public static org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent convertMessageHeaderResponseComponent(org.hl7.fhir.r5.model.MessageHeader.MessageHeaderResponseComponent src) throws FHIRException { 185 if (src == null) 186 return null; 187 org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent tgt = new org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent(); 188 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 189 if (src.hasIdentifier()) 190 tgt.setIdentifierElement(Id40_50.convertId(src.getIdentifierElement())); 191 if (src.hasCode()) 192 tgt.setCodeElement(convertResponseType(src.getCodeElement())); 193 if (src.hasDetails()) 194 tgt.setDetails(Reference40_50.convertReference(src.getDetails())); 195 return tgt; 196 } 197 198 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 { 199 if (src == null || src.isEmpty()) 200 return null; 201 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageHeader.ResponseType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.MessageHeader.ResponseTypeEnumFactory()); 202 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 203 switch (src.getValue()) { 204 case OK: 205 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.OK); 206 break; 207 case TRANSIENTERROR: 208 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.TRANSIENTERROR); 209 break; 210 case FATALERROR: 211 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.FATALERROR); 212 break; 213 default: 214 tgt.setValue(org.hl7.fhir.r5.model.MessageHeader.ResponseType.NULL); 215 break; 216 } 217 return tgt; 218 } 219 220 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 { 221 if (src == null || src.isEmpty()) 222 return null; 223 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()); 224 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 225 switch (src.getValue()) { 226 case OK: 227 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.OK); 228 break; 229 case TRANSIENTERROR: 230 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.TRANSIENTERROR); 231 break; 232 case FATALERROR: 233 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.FATALERROR); 234 break; 235 default: 236 tgt.setValue(org.hl7.fhir.r4.model.MessageHeader.ResponseType.NULL); 237 break; 238 } 239 return tgt; 240 } 241}