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