001package org.hl7.fhir.convertors.conv10_50.resources10_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_50;
004import org.hl7.fhir.convertors.conv10_50.datatypes10_50.Reference10_50;
005import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Address10_50;
006import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Attachment10_50;
007import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.ContactPoint10_50;
008import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.HumanName10_50;
009import org.hl7.fhir.convertors.conv10_50.datatypes10_50.complextypes10_50.Identifier10_50;
010import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Boolean10_50;
011import org.hl7.fhir.convertors.conv10_50.datatypes10_50.primitivetypes10_50.Date10_50;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class Person10_50 {
015
016  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.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.r5.model.Enumeration<org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Person.IdentityAssuranceLevelEnumFactory());
020    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
021    switch (src.getValue()) {
022      case LEVEL1:
023        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL1);
024        break;
025      case LEVEL2:
026        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL2);
027        break;
028      case LEVEL3:
029        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL3);
030        break;
031      case LEVEL4:
032        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL4);
033        break;
034      default:
035        tgt.setValue(org.hl7.fhir.r5.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.r5.model.Enumeration<org.hl7.fhir.r5.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_50.INSTANCE.getVersionConvertor_10_50().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.r5.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.r5.model.Person tgt = new org.hl7.fhir.r5.model.Person();
070    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
071    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
072      tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
073    for (org.hl7.fhir.dstu2.model.HumanName t : src.getName()) tgt.addName(HumanName10_50.convertHumanName(t));
074    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
075      tgt.addTelecom(ContactPoint10_50.convertContactPoint(t));
076    if (src.hasGender())
077      tgt.setGenderElement(Enumerations10_50.convertAdministrativeGender(src.getGenderElement()));
078    if (src.hasBirthDateElement())
079      tgt.setBirthDateElement(Date10_50.convertDate(src.getBirthDateElement()));
080    for (org.hl7.fhir.dstu2.model.Address t : src.getAddress()) tgt.addAddress(Address10_50.convertAddress(t));
081    if (src.hasPhoto())
082      tgt.addPhoto(Attachment10_50.convertAttachment(src.getPhoto()));
083    if (src.hasManagingOrganization())
084      tgt.setManagingOrganization(Reference10_50.convertReference(src.getManagingOrganization()));
085    if (src.hasActiveElement())
086      tgt.setActiveElement(Boolean10_50.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.r5.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_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
097    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
098      tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
099    for (org.hl7.fhir.r5.model.HumanName t : src.getName()) tgt.addName(HumanName10_50.convertHumanName(t));
100    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
101      tgt.addTelecom(ContactPoint10_50.convertContactPoint(t));
102    if (src.hasGender())
103      tgt.setGenderElement(Enumerations10_50.convertAdministrativeGender(src.getGenderElement()));
104    if (src.hasBirthDateElement())
105      tgt.setBirthDateElement(Date10_50.convertDate(src.getBirthDateElement()));
106    for (org.hl7.fhir.r5.model.Address t : src.getAddress()) tgt.addAddress(Address10_50.convertAddress(t));
107    if (src.hasPhoto())
108      tgt.setPhoto(Attachment10_50.convertAttachment(src.getPhotoFirstRep()));
109    if (src.hasManagingOrganization())
110      tgt.setManagingOrganization(Reference10_50.convertReference(src.getManagingOrganization()));
111    if (src.hasActiveElement())
112      tgt.setActiveElement(Boolean10_50.convertBoolean(src.getActiveElement()));
113    for (org.hl7.fhir.r5.model.Person.PersonLinkComponent t : src.getLink()) tgt.addLink(convertPersonLinkComponent(t));
114    return tgt;
115  }
116
117  public static org.hl7.fhir.dstu2.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.r5.model.Person.PersonLinkComponent src) throws FHIRException {
118    if (src == null || src.isEmpty())
119      return null;
120    org.hl7.fhir.dstu2.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.dstu2.model.Person.PersonLinkComponent();
121    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt);
122    if (src.hasTarget())
123      tgt.setTarget(Reference10_50.convertReference(src.getTarget()));
124    if (src.hasAssurance())
125      tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement()));
126    return tgt;
127  }
128
129  public static org.hl7.fhir.r5.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.dstu2.model.Person.PersonLinkComponent src) throws FHIRException {
130    if (src == null || src.isEmpty())
131      return null;
132    org.hl7.fhir.r5.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.r5.model.Person.PersonLinkComponent();
133    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyBackboneElement(src,tgt);
134    if (src.hasTarget())
135      tgt.setTarget(Reference10_50.convertReference(src.getTarget()));
136    if (src.hasAssurance())
137      tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement()));
138    return tgt;
139  }
140}