001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Address30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Attachment30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40; 008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.ContactPoint30_40; 009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.HumanName30_40; 010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40; 011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Period30_40; 012import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Boolean30_40; 013import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Date30_40; 014import org.hl7.fhir.exceptions.FHIRException; 015 016public class Patient30_40 { 017 018 public static org.hl7.fhir.dstu3.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.r4.model.Extension src) throws FHIRException { 019 if (src == null || src.isEmpty()) 020 return null; 021 org.hl7.fhir.dstu3.model.Patient.AnimalComponent tgt = new org.hl7.fhir.dstu3.model.Patient.AnimalComponent(); 022 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 023 if (src.hasExtension("species")) 024 tgt.setSpecies(CodeableConcept30_40.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("species").getValue())); 025 if (src.hasExtension("breed")) 026 tgt.setBreed(CodeableConcept30_40.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("breed").getValue())); 027 if (src.hasExtension("genderStatus")) 028 tgt.setGenderStatus(CodeableConcept30_40.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("genderStatus").getValue())); 029 return tgt; 030 } 031 032 public static org.hl7.fhir.r4.model.Extension convertAnimalComponent(org.hl7.fhir.dstu3.model.Patient.AnimalComponent src) throws FHIRException { 033 if (src == null) 034 return null; 035 org.hl7.fhir.r4.model.Extension tgt = new org.hl7.fhir.r4.model.Extension(); 036 tgt.setUrl("http://hl7.org/fhir/StructureDefinition/patient-animal"); 037 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 038 if (src.hasSpecies()) 039 tgt.addExtension("species", CodeableConcept30_40.convertCodeableConcept(src.getSpecies())); 040 if (src.hasBreed()) 041 tgt.addExtension("breed", CodeableConcept30_40.convertCodeableConcept(src.getBreed())); 042 if (src.hasGenderStatus()) 043 tgt.addExtension("genderStatus", CodeableConcept30_40.convertCodeableConcept(src.getGenderStatus())); 044 return tgt; 045 } 046 047 public static org.hl7.fhir.r4.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r4.model.Patient.ContactComponent tgt = new org.hl7.fhir.r4.model.Patient.ContactComponent(); 051 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 052 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getRelationship()) 053 tgt.addRelationship(CodeableConcept30_40.convertCodeableConcept(t)); 054 if (src.hasName()) 055 tgt.setName(HumanName30_40.convertHumanName(src.getName())); 056 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) 057 tgt.addTelecom(ContactPoint30_40.convertContactPoint(t)); 058 if (src.hasAddress()) 059 tgt.setAddress(Address30_40.convertAddress(src.getAddress())); 060 if (src.hasGender()) 061 tgt.setGenderElement(Enumerations30_40.convertAdministrativeGender(src.getGenderElement())); 062 if (src.hasOrganization()) 063 tgt.setOrganization(Reference30_40.convertReference(src.getOrganization())); 064 if (src.hasPeriod()) 065 tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod())); 066 return tgt; 067 } 068 069 public static org.hl7.fhir.dstu3.model.Patient.ContactComponent convertContactComponent(org.hl7.fhir.r4.model.Patient.ContactComponent src) throws FHIRException { 070 if (src == null) 071 return null; 072 org.hl7.fhir.dstu3.model.Patient.ContactComponent tgt = new org.hl7.fhir.dstu3.model.Patient.ContactComponent(); 073 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 074 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRelationship()) 075 tgt.addRelationship(CodeableConcept30_40.convertCodeableConcept(t)); 076 if (src.hasName()) 077 tgt.setName(HumanName30_40.convertHumanName(src.getName())); 078 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 079 tgt.addTelecom(ContactPoint30_40.convertContactPoint(t)); 080 if (src.hasAddress()) 081 tgt.setAddress(Address30_40.convertAddress(src.getAddress())); 082 if (src.hasGender()) 083 tgt.setGenderElement(Enumerations30_40.convertAdministrativeGender(src.getGenderElement())); 084 if (src.hasOrganization()) 085 tgt.setOrganization(Reference30_40.convertReference(src.getOrganization())); 086 if (src.hasPeriod()) 087 tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod())); 088 return tgt; 089 } 090 091 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Patient.LinkType> convertLinkType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Patient.LinkType> src) throws FHIRException { 092 if (src == null || src.isEmpty()) 093 return null; 094 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Patient.LinkType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Patient.LinkTypeEnumFactory()); 095 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 096 switch (src.getValue()) { 097 case REPLACEDBY: 098 tgt.setValue(org.hl7.fhir.dstu3.model.Patient.LinkType.REPLACEDBY); 099 break; 100 case REPLACES: 101 tgt.setValue(org.hl7.fhir.dstu3.model.Patient.LinkType.REPLACES); 102 break; 103 case REFER: 104 tgt.setValue(org.hl7.fhir.dstu3.model.Patient.LinkType.REFER); 105 break; 106 case SEEALSO: 107 tgt.setValue(org.hl7.fhir.dstu3.model.Patient.LinkType.SEEALSO); 108 break; 109 default: 110 tgt.setValue(org.hl7.fhir.dstu3.model.Patient.LinkType.NULL); 111 break; 112 } 113 return tgt; 114 } 115 116 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Patient.LinkType> convertLinkType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Patient.LinkType> src) throws FHIRException { 117 if (src == null || src.isEmpty()) 118 return null; 119 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Patient.LinkType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Patient.LinkTypeEnumFactory()); 120 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 121 switch (src.getValue()) { 122 case REPLACEDBY: 123 tgt.setValue(org.hl7.fhir.r4.model.Patient.LinkType.REPLACEDBY); 124 break; 125 case REPLACES: 126 tgt.setValue(org.hl7.fhir.r4.model.Patient.LinkType.REPLACES); 127 break; 128 case REFER: 129 tgt.setValue(org.hl7.fhir.r4.model.Patient.LinkType.REFER); 130 break; 131 case SEEALSO: 132 tgt.setValue(org.hl7.fhir.r4.model.Patient.LinkType.SEEALSO); 133 break; 134 default: 135 tgt.setValue(org.hl7.fhir.r4.model.Patient.LinkType.NULL); 136 break; 137 } 138 return tgt; 139 } 140 141 public static org.hl7.fhir.dstu3.model.Patient convertPatient(org.hl7.fhir.r4.model.Patient src) throws FHIRException { 142 if (src == null) 143 return null; 144 org.hl7.fhir.dstu3.model.Patient tgt = new org.hl7.fhir.dstu3.model.Patient(); 145 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 146 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 147 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 148 if (src.hasActive()) 149 tgt.setActiveElement(Boolean30_40.convertBoolean(src.getActiveElement())); 150 for (org.hl7.fhir.r4.model.HumanName t : src.getName()) tgt.addName(HumanName30_40.convertHumanName(t)); 151 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 152 tgt.addTelecom(ContactPoint30_40.convertContactPoint(t)); 153 if (src.hasGender()) 154 tgt.setGenderElement(Enumerations30_40.convertAdministrativeGender(src.getGenderElement())); 155 if (src.hasBirthDate()) 156 tgt.setBirthDateElement(Date30_40.convertDate(src.getBirthDateElement())); 157 if (src.hasDeceased()) 158 tgt.setDeceased(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getDeceased())); 159 for (org.hl7.fhir.r4.model.Address t : src.getAddress()) tgt.addAddress(Address30_40.convertAddress(t)); 160 if (src.hasMaritalStatus()) 161 tgt.setMaritalStatus(CodeableConcept30_40.convertCodeableConcept(src.getMaritalStatus())); 162 if (src.hasMultipleBirth()) 163 tgt.setMultipleBirth(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getMultipleBirth())); 164 for (org.hl7.fhir.r4.model.Attachment t : src.getPhoto()) tgt.addPhoto(Attachment30_40.convertAttachment(t)); 165 for (org.hl7.fhir.r4.model.Patient.ContactComponent t : src.getContact()) 166 tgt.addContact(convertContactComponent(t)); 167 if (src.hasExtension("http://hl7.org/fhir/StructureDefinition/patient-animal")) 168 tgt.setAnimal(convertAnimalComponent(src.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/patient-animal"))); 169 for (org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent t : src.getCommunication()) 170 tgt.addCommunication(convertPatientCommunicationComponent(t)); 171 for (org.hl7.fhir.r4.model.Reference t : src.getGeneralPractitioner()) 172 tgt.addGeneralPractitioner(Reference30_40.convertReference(t)); 173 if (src.hasManagingOrganization()) 174 tgt.setManagingOrganization(Reference30_40.convertReference(src.getManagingOrganization())); 175 for (org.hl7.fhir.r4.model.Patient.PatientLinkComponent t : src.getLink()) 176 tgt.addLink(convertPatientLinkComponent(t)); 177 return tgt; 178 } 179 180 public static org.hl7.fhir.r4.model.Patient convertPatient(org.hl7.fhir.dstu3.model.Patient src) throws FHIRException { 181 if (src == null) 182 return null; 183 org.hl7.fhir.r4.model.Patient tgt = new org.hl7.fhir.r4.model.Patient(); 184 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 185 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 186 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 187 if (src.hasActive()) 188 tgt.setActiveElement(Boolean30_40.convertBoolean(src.getActiveElement())); 189 for (org.hl7.fhir.dstu3.model.HumanName t : src.getName()) tgt.addName(HumanName30_40.convertHumanName(t)); 190 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) 191 tgt.addTelecom(ContactPoint30_40.convertContactPoint(t)); 192 if (src.hasGender()) 193 tgt.setGenderElement(Enumerations30_40.convertAdministrativeGender(src.getGenderElement())); 194 if (src.hasBirthDate()) 195 tgt.setBirthDateElement(Date30_40.convertDate(src.getBirthDateElement())); 196 if (src.hasDeceased()) 197 tgt.setDeceased(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getDeceased())); 198 for (org.hl7.fhir.dstu3.model.Address t : src.getAddress()) tgt.addAddress(Address30_40.convertAddress(t)); 199 if (src.hasMaritalStatus()) 200 tgt.setMaritalStatus(CodeableConcept30_40.convertCodeableConcept(src.getMaritalStatus())); 201 if (src.hasMultipleBirth()) 202 tgt.setMultipleBirth(ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getMultipleBirth())); 203 for (org.hl7.fhir.dstu3.model.Attachment t : src.getPhoto()) tgt.addPhoto(Attachment30_40.convertAttachment(t)); 204 for (org.hl7.fhir.dstu3.model.Patient.ContactComponent t : src.getContact()) 205 tgt.addContact(convertContactComponent(t)); 206 if (src.hasAnimal()) 207 tgt.addExtension(convertAnimalComponent(src.getAnimal())); 208 for (org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent t : src.getCommunication()) 209 tgt.addCommunication(convertPatientCommunicationComponent(t)); 210 for (org.hl7.fhir.dstu3.model.Reference t : src.getGeneralPractitioner()) 211 tgt.addGeneralPractitioner(Reference30_40.convertReference(t)); 212 if (src.hasManagingOrganization()) 213 tgt.setManagingOrganization(Reference30_40.convertReference(src.getManagingOrganization())); 214 for (org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent t : src.getLink()) 215 tgt.addLink(convertPatientLinkComponent(t)); 216 return tgt; 217 } 218 219 public static org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent src) throws FHIRException { 220 if (src == null) 221 return null; 222 org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent tgt = new org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent(); 223 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 224 if (src.hasLanguage()) 225 tgt.setLanguage(CodeableConcept30_40.convertCodeableConcept(src.getLanguage())); 226 if (src.hasPreferred()) 227 tgt.setPreferredElement(Boolean30_40.convertBoolean(src.getPreferredElement())); 228 return tgt; 229 } 230 231 public static org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent convertPatientCommunicationComponent(org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent src) throws FHIRException { 232 if (src == null) 233 return null; 234 org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent tgt = new org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent(); 235 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 236 if (src.hasLanguage()) 237 tgt.setLanguage(CodeableConcept30_40.convertCodeableConcept(src.getLanguage())); 238 if (src.hasPreferred()) 239 tgt.setPreferredElement(Boolean30_40.convertBoolean(src.getPreferredElement())); 240 return tgt; 241 } 242 243 public static org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent convertPatientLinkComponent(org.hl7.fhir.r4.model.Patient.PatientLinkComponent src) throws FHIRException { 244 if (src == null) 245 return null; 246 org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent tgt = new org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent(); 247 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 248 if (src.hasOther()) 249 tgt.setOther(Reference30_40.convertReference(src.getOther())); 250 if (src.hasType()) 251 tgt.setTypeElement(convertLinkType(src.getTypeElement())); 252 return tgt; 253 } 254 255 public static org.hl7.fhir.r4.model.Patient.PatientLinkComponent convertPatientLinkComponent(org.hl7.fhir.dstu3.model.Patient.PatientLinkComponent src) throws FHIRException { 256 if (src == null) 257 return null; 258 org.hl7.fhir.r4.model.Patient.PatientLinkComponent tgt = new org.hl7.fhir.r4.model.Patient.PatientLinkComponent(); 259 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 260 if (src.hasOther()) 261 tgt.setOther(Reference30_40.convertReference(src.getOther())); 262 if (src.hasType()) 263 tgt.setTypeElement(convertLinkType(src.getTypeElement())); 264 return tgt; 265 } 266}