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