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