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