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.Address43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Attachment43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.ContactPoint43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.HumanName43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50; 011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50; 012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Date43_50; 013import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 014import org.hl7.fhir.exceptions.FHIRException; 015 016/* 017 Copyright (c) 2011+, HL7, Inc. 018 All rights reserved. 019 020 Redistribution and use in source and binary forms, with or without modification, 021 are permitted provided that the following conditions are met: 022 023 * Redistributions of source code must retain the above copyright notice, this 024 list of conditions and the following disclaimer. 025 * Redistributions in binary form must reproduce the above copyright notice, 026 this list of conditions and the following disclaimer in the documentation 027 and/or other materials provided with the distribution. 028 * Neither the name of HL7 nor the names of its contributors may be used to 029 endorse or promote products derived from this software without specific 030 prior written permission. 031 032 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 033 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 034 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 035 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 036 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 037 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 038 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 039 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 040 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 041 POSSIBILITY OF SUCH DAMAGE. 042 043*/ 044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 045public class Patient43_50 { 046 047 public static org.hl7.fhir.r5.model.Patient convertPatient(org.hl7.fhir.r4b.model.Patient src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r5.model.Patient tgt = new org.hl7.fhir.r5.model.Patient(); 051 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 052 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 053 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 054 if (src.hasActive()) 055 tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement())); 056 for (org.hl7.fhir.r4b.model.HumanName t : src.getName()) tgt.addName(HumanName43_50.convertHumanName(t)); 057 for (org.hl7.fhir.r4b.model.ContactPoint t : src.getTelecom()) 058 tgt.addTelecom(ContactPoint43_50.convertContactPoint(t)); 059 if (src.hasGender()) 060 tgt.setGenderElement(Enumerations43_50.convertAdministrativeGender(src.getGenderElement())); 061 if (src.hasBirthDate()) 062 tgt.setBirthDateElement(Date43_50.convertDate(src.getBirthDateElement())); 063 if (src.hasDeceased()) 064 tgt.setDeceased(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDeceased())); 065 for (org.hl7.fhir.r4b.model.Address t : src.getAddress()) tgt.addAddress(Address43_50.convertAddress(t)); 066 if (src.hasMaritalStatus()) 067 tgt.setMaritalStatus(CodeableConcept43_50.convertCodeableConcept(src.getMaritalStatus())); 068 if (src.hasMultipleBirth()) 069 tgt.setMultipleBirth(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getMultipleBirth())); 070 for (org.hl7.fhir.r4b.model.Attachment t : src.getPhoto()) tgt.addPhoto(Attachment43_50.convertAttachment(t)); 071 for (org.hl7.fhir.r4b.model.Patient.ContactComponent t : src.getContact()) 072 tgt.addContact(convertContactComponent(t)); 073 for (org.hl7.fhir.r4b.model.Patient.PatientCommunicationComponent t : src.getCommunication()) 074 tgt.addCommunication(convertPatientCommunicationComponent(t)); 075 for (org.hl7.fhir.r4b.model.Reference t : src.getGeneralPractitioner()) 076 tgt.addGeneralPractitioner(Reference43_50.convertReference(t)); 077 if (src.hasManagingOrganization()) 078 tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization())); 079 for (org.hl7.fhir.r4b.model.Patient.PatientLinkComponent t : src.getLink()) 080 tgt.addLink(convertPatientLinkComponent(t)); 081 return tgt; 082 } 083 084 public static org.hl7.fhir.r4b.model.Patient convertPatient(org.hl7.fhir.r5.model.Patient src) throws FHIRException { 085 if (src == null) 086 return null; 087 org.hl7.fhir.r4b.model.Patient tgt = new org.hl7.fhir.r4b.model.Patient(); 088 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 089 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 090 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 091 if (src.hasActive()) 092 tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement())); 093 for (org.hl7.fhir.r5.model.HumanName t : src.getName()) tgt.addName(HumanName43_50.convertHumanName(t)); 094 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 095 tgt.addTelecom(ContactPoint43_50.convertContactPoint(t)); 096 if (src.hasGender()) 097 tgt.setGenderElement(Enumerations43_50.convertAdministrativeGender(src.getGenderElement())); 098 if (src.hasBirthDate()) 099 tgt.setBirthDateElement(Date43_50.convertDate(src.getBirthDateElement())); 100 if (src.hasDeceased()) 101 tgt.setDeceased(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDeceased())); 102 for (org.hl7.fhir.r5.model.Address t : src.getAddress()) tgt.addAddress(Address43_50.convertAddress(t)); 103 if (src.hasMaritalStatus()) 104 tgt.setMaritalStatus(CodeableConcept43_50.convertCodeableConcept(src.getMaritalStatus())); 105 if (src.hasMultipleBirth()) 106 tgt.setMultipleBirth(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getMultipleBirth())); 107 for (org.hl7.fhir.r5.model.Attachment t : src.getPhoto()) tgt.addPhoto(Attachment43_50.convertAttachment(t)); 108 for (org.hl7.fhir.r5.model.Patient.ContactComponent t : src.getContact()) 109 tgt.addContact(convertContactComponent(t)); 110 for (org.hl7.fhir.r5.model.Patient.PatientCommunicationComponent t : src.getCommunication()) 111 tgt.addCommunication(convertPatientCommunicationComponent(t)); 112 for (org.hl7.fhir.r5.model.Reference t : src.getGeneralPractitioner()) 113 tgt.addGeneralPractitioner(Reference43_50.convertReference(t)); 114 if (src.hasManagingOrganization()) 115 tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization())); 116 for (org.hl7.fhir.r5.model.Patient.PatientLinkComponent t : src.getLink()) 117 tgt.addLink(convertPatientLinkComponent(t)); 118 return tgt; 119 } 120 121 public static org.hl7.fhir.r5.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.r4b.model.Patient.ContactComponent src) throws FHIRException { 122 if (src == null) 123 return null; 124 org.hl7.fhir.r5.model.Patient.ContactComponent tgt = new org.hl7.fhir.r5.model.Patient.ContactComponent(); 125 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 126 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getRelationship()) 127 tgt.addRelationship(CodeableConcept43_50.convertCodeableConcept(t)); 128 if (src.hasName()) 129 tgt.setName(HumanName43_50.convertHumanName(src.getName())); 130 for (org.hl7.fhir.r4b.model.ContactPoint t : src.getTelecom()) 131 tgt.addTelecom(ContactPoint43_50.convertContactPoint(t)); 132 if (src.hasAddress()) 133 tgt.setAddress(Address43_50.convertAddress(src.getAddress())); 134 if (src.hasGender()) 135 tgt.setGenderElement(Enumerations43_50.convertAdministrativeGender(src.getGenderElement())); 136 if (src.hasOrganization()) 137 tgt.setOrganization(Reference43_50.convertReference(src.getOrganization())); 138 if (src.hasPeriod()) 139 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 140 return tgt; 141 } 142 143 public static org.hl7.fhir.r4b.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.r5.model.Patient.ContactComponent src) throws FHIRException { 144 if (src == null) 145 return null; 146 org.hl7.fhir.r4b.model.Patient.ContactComponent tgt = new org.hl7.fhir.r4b.model.Patient.ContactComponent(); 147 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 148 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRelationship()) 149 tgt.addRelationship(CodeableConcept43_50.convertCodeableConcept(t)); 150 if (src.hasName()) 151 tgt.setName(HumanName43_50.convertHumanName(src.getName())); 152 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 153 tgt.addTelecom(ContactPoint43_50.convertContactPoint(t)); 154 if (src.hasAddress()) 155 tgt.setAddress(Address43_50.convertAddress(src.getAddress())); 156 if (src.hasGender()) 157 tgt.setGenderElement(Enumerations43_50.convertAdministrativeGender(src.getGenderElement())); 158 if (src.hasOrganization()) 159 tgt.setOrganization(Reference43_50.convertReference(src.getOrganization())); 160 if (src.hasPeriod()) 161 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 162 return tgt; 163 } 164 165 public static org.hl7.fhir.r5.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.r4b.model.Patient.PatientCommunicationComponent src) throws FHIRException { 166 if (src == null) 167 return null; 168 org.hl7.fhir.r5.model.Patient.PatientCommunicationComponent tgt = new org.hl7.fhir.r5.model.Patient.PatientCommunicationComponent(); 169 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 170 if (src.hasLanguage()) 171 tgt.setLanguage(CodeableConcept43_50.convertCodeableConcept(src.getLanguage())); 172 if (src.hasPreferred()) 173 tgt.setPreferredElement(Boolean43_50.convertBoolean(src.getPreferredElement())); 174 return tgt; 175 } 176 177 public static org.hl7.fhir.r4b.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.r5.model.Patient.PatientCommunicationComponent src) throws FHIRException { 178 if (src == null) 179 return null; 180 org.hl7.fhir.r4b.model.Patient.PatientCommunicationComponent tgt = new org.hl7.fhir.r4b.model.Patient.PatientCommunicationComponent(); 181 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 182 if (src.hasLanguage()) 183 tgt.setLanguage(CodeableConcept43_50.convertCodeableConcept(src.getLanguage())); 184 if (src.hasPreferred()) 185 tgt.setPreferredElement(Boolean43_50.convertBoolean(src.getPreferredElement())); 186 return tgt; 187 } 188 189 public static org.hl7.fhir.r5.model.Patient.PatientLinkComponent convertPatientLinkComponent(org.hl7.fhir.r4b.model.Patient.PatientLinkComponent src) throws FHIRException { 190 if (src == null) 191 return null; 192 org.hl7.fhir.r5.model.Patient.PatientLinkComponent tgt = new org.hl7.fhir.r5.model.Patient.PatientLinkComponent(); 193 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 194 if (src.hasOther()) 195 tgt.setOther(Reference43_50.convertReference(src.getOther())); 196 if (src.hasType()) 197 tgt.setTypeElement(convertLinkType(src.getTypeElement())); 198 return tgt; 199 } 200 201 public static org.hl7.fhir.r4b.model.Patient.PatientLinkComponent convertPatientLinkComponent(org.hl7.fhir.r5.model.Patient.PatientLinkComponent src) throws FHIRException { 202 if (src == null) 203 return null; 204 org.hl7.fhir.r4b.model.Patient.PatientLinkComponent tgt = new org.hl7.fhir.r4b.model.Patient.PatientLinkComponent(); 205 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 206 if (src.hasOther()) 207 tgt.setOther(Reference43_50.convertReference(src.getOther())); 208 if (src.hasType()) 209 tgt.setTypeElement(convertLinkType(src.getTypeElement())); 210 return tgt; 211 } 212 213 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Patient.LinkType> convertLinkType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Patient.LinkType> src) throws FHIRException { 214 if (src == null || src.isEmpty()) 215 return null; 216 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Patient.LinkType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Patient.LinkTypeEnumFactory()); 217 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 218 switch (src.getValue()) { 219 case REPLACEDBY: 220 tgt.setValue(org.hl7.fhir.r5.model.Patient.LinkType.REPLACEDBY); 221 break; 222 case REPLACES: 223 tgt.setValue(org.hl7.fhir.r5.model.Patient.LinkType.REPLACES); 224 break; 225 case REFER: 226 tgt.setValue(org.hl7.fhir.r5.model.Patient.LinkType.REFER); 227 break; 228 case SEEALSO: 229 tgt.setValue(org.hl7.fhir.r5.model.Patient.LinkType.SEEALSO); 230 break; 231 default: 232 tgt.setValue(org.hl7.fhir.r5.model.Patient.LinkType.NULL); 233 break; 234 } 235 return tgt; 236 } 237 238 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Patient.LinkType> convertLinkType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Patient.LinkType> src) throws FHIRException { 239 if (src == null || src.isEmpty()) 240 return null; 241 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Patient.LinkType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Patient.LinkTypeEnumFactory()); 242 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 243 switch (src.getValue()) { 244 case REPLACEDBY: 245 tgt.setValue(org.hl7.fhir.r4b.model.Patient.LinkType.REPLACEDBY); 246 break; 247 case REPLACES: 248 tgt.setValue(org.hl7.fhir.r4b.model.Patient.LinkType.REPLACES); 249 break; 250 case REFER: 251 tgt.setValue(org.hl7.fhir.r4b.model.Patient.LinkType.REFER); 252 break; 253 case SEEALSO: 254 tgt.setValue(org.hl7.fhir.r4b.model.Patient.LinkType.SEEALSO); 255 break; 256 default: 257 tgt.setValue(org.hl7.fhir.r4b.model.Patient.LinkType.NULL); 258 break; 259 } 260 return tgt; 261 } 262}