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