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