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