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