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