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