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 Person10_30 {
011
012  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel> convertIdentityAssuranceLevel(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel> src) throws FHIRException {
013    if (src == null || src.isEmpty())
014      return null;
015    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevelEnumFactory());
016    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
017    switch (src.getValue()) {
018      case LEVEL1:
019        tgt.setValue(org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL1);
020        break;
021      case LEVEL2:
022        tgt.setValue(org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL2);
023        break;
024      case LEVEL3:
025        tgt.setValue(org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL3);
026        break;
027      case LEVEL4:
028        tgt.setValue(org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.LEVEL4);
029        break;
030      default:
031        tgt.setValue(org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel.NULL);
032        break;
033    }
034    return tgt;
035  }
036
037  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel> convertIdentityAssuranceLevel(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel> src) throws FHIRException {
038    if (src == null || src.isEmpty())
039      return null;
040    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevelEnumFactory());
041    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
042    switch (src.getValue()) {
043      case LEVEL1:
044        tgt.setValue(org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel.LEVEL1);
045        break;
046      case LEVEL2:
047        tgt.setValue(org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel.LEVEL2);
048        break;
049      case LEVEL3:
050        tgt.setValue(org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel.LEVEL3);
051        break;
052      case LEVEL4:
053        tgt.setValue(org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel.LEVEL4);
054        break;
055      default:
056        tgt.setValue(org.hl7.fhir.dstu2.model.Person.IdentityAssuranceLevel.NULL);
057        break;
058    }
059    return tgt;
060  }
061
062  public static org.hl7.fhir.dstu3.model.Person convertPerson(org.hl7.fhir.dstu2.model.Person src) throws FHIRException {
063    if (src == null || src.isEmpty())
064      return null;
065    org.hl7.fhir.dstu3.model.Person tgt = new org.hl7.fhir.dstu3.model.Person();
066    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
067    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
068      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
069    for (org.hl7.fhir.dstu2.model.HumanName t : src.getName()) tgt.addName(HumanName10_30.convertHumanName(t));
070    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
071      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
072    if (src.hasGender())
073      tgt.setGenderElement(Enumerations10_30.convertAdministrativeGender(src.getGenderElement()));
074    if (src.hasBirthDateElement())
075      tgt.setBirthDateElement(Date10_30.convertDate(src.getBirthDateElement()));
076    for (org.hl7.fhir.dstu2.model.Address t : src.getAddress()) tgt.addAddress(Address10_30.convertAddress(t));
077    if (src.hasPhoto())
078      tgt.setPhoto(Attachment10_30.convertAttachment(src.getPhoto()));
079    if (src.hasManagingOrganization())
080      tgt.setManagingOrganization(Reference10_30.convertReference(src.getManagingOrganization()));
081    if (src.hasActiveElement())
082      tgt.setActiveElement(Boolean10_30.convertBoolean(src.getActiveElement()));
083    for (org.hl7.fhir.dstu2.model.Person.PersonLinkComponent t : src.getLink())
084      tgt.addLink(convertPersonLinkComponent(t));
085    return tgt;
086  }
087
088  public static org.hl7.fhir.dstu2.model.Person convertPerson(org.hl7.fhir.dstu3.model.Person src) throws FHIRException {
089    if (src == null || src.isEmpty())
090      return null;
091    org.hl7.fhir.dstu2.model.Person tgt = new org.hl7.fhir.dstu2.model.Person();
092    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
093    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
094      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
095    for (org.hl7.fhir.dstu3.model.HumanName t : src.getName()) tgt.addName(HumanName10_30.convertHumanName(t));
096    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
097      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
098    if (src.hasGender())
099      tgt.setGenderElement(Enumerations10_30.convertAdministrativeGender(src.getGenderElement()));
100    if (src.hasBirthDateElement())
101      tgt.setBirthDateElement(Date10_30.convertDate(src.getBirthDateElement()));
102    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress()) tgt.addAddress(Address10_30.convertAddress(t));
103    if (src.hasPhoto())
104      tgt.setPhoto(Attachment10_30.convertAttachment(src.getPhoto()));
105    if (src.hasManagingOrganization())
106      tgt.setManagingOrganization(Reference10_30.convertReference(src.getManagingOrganization()));
107    if (src.hasActiveElement())
108      tgt.setActiveElement(Boolean10_30.convertBoolean(src.getActiveElement()));
109    for (org.hl7.fhir.dstu3.model.Person.PersonLinkComponent t : src.getLink())
110      tgt.addLink(convertPersonLinkComponent(t));
111    return tgt;
112  }
113
114  public static org.hl7.fhir.dstu3.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.dstu2.model.Person.PersonLinkComponent src) throws FHIRException {
115    if (src == null || src.isEmpty())
116      return null;
117    org.hl7.fhir.dstu3.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.dstu3.model.Person.PersonLinkComponent();
118    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
119    if (src.hasTarget())
120      tgt.setTarget(Reference10_30.convertReference(src.getTarget()));
121    if (src.hasAssurance())
122      tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement()));
123    return tgt;
124  }
125
126  public static org.hl7.fhir.dstu2.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.dstu3.model.Person.PersonLinkComponent src) throws FHIRException {
127    if (src == null || src.isEmpty())
128      return null;
129    org.hl7.fhir.dstu2.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.dstu2.model.Person.PersonLinkComponent();
130    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
131    if (src.hasTarget())
132      tgt.setTarget(Reference10_30.convertReference(src.getTarget()));
133    if (src.hasAssurance())
134      tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement()));
135    return tgt;
136  }
137}