001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Address30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Attachment30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.ContactPoint30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.HumanName30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Date30_50;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class Person30_50 {
015
016  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Person.IdentityAssuranceLevel> convertIdentityAssuranceLevel(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.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    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().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.r5.model.Enumeration<org.hl7.fhir.r5.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.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());
045    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
046    switch (src.getValue()) {
047      case LEVEL1:
048        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL1);
049        break;
050      case LEVEL2:
051        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL2);
052        break;
053      case LEVEL3:
054        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL3);
055        break;
056      case LEVEL4:
057        tgt.setValue(org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel.LEVEL4);
058        break;
059      default:
060        tgt.setValue(org.hl7.fhir.r5.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.r5.model.Person src) throws FHIRException {
067    if (src == null)
068      return null;
069    org.hl7.fhir.dstu3.model.Person tgt = new org.hl7.fhir.dstu3.model.Person();
070    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
071    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
072      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
073    for (org.hl7.fhir.r5.model.HumanName t : src.getName()) tgt.addName(HumanName30_50.convertHumanName(t));
074    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
075      tgt.addTelecom(ContactPoint30_50.convertContactPoint(t));
076    if (src.hasGender())
077      tgt.setGenderElement(Enumerations30_50.convertAdministrativeGender(src.getGenderElement()));
078    if (src.hasBirthDate())
079      tgt.setBirthDateElement(Date30_50.convertDate(src.getBirthDateElement()));
080    for (org.hl7.fhir.r5.model.Address t : src.getAddress()) tgt.addAddress(Address30_50.convertAddress(t));
081    if (src.hasPhoto())
082      tgt.setPhoto(Attachment30_50.convertAttachment(src.getPhotoFirstRep()));
083    if (src.hasManagingOrganization())
084      tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization()));
085    if (src.hasActive())
086      tgt.setActiveElement(Boolean30_50.convertBoolean(src.getActiveElement()));
087    for (org.hl7.fhir.r5.model.Person.PersonLinkComponent t : src.getLink()) tgt.addLink(convertPersonLinkComponent(t));
088    return tgt;
089  }
090
091  public static org.hl7.fhir.r5.model.Person convertPerson(org.hl7.fhir.dstu3.model.Person src) throws FHIRException {
092    if (src == null)
093      return null;
094    org.hl7.fhir.r5.model.Person tgt = new org.hl7.fhir.r5.model.Person();
095    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
096    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
097      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
098    for (org.hl7.fhir.dstu3.model.HumanName t : src.getName()) tgt.addName(HumanName30_50.convertHumanName(t));
099    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
100      tgt.addTelecom(ContactPoint30_50.convertContactPoint(t));
101    if (src.hasGender())
102      tgt.setGenderElement(Enumerations30_50.convertAdministrativeGender(src.getGenderElement()));
103    if (src.hasBirthDate())
104      tgt.setBirthDateElement(Date30_50.convertDate(src.getBirthDateElement()));
105    for (org.hl7.fhir.dstu3.model.Address t : src.getAddress()) tgt.addAddress(Address30_50.convertAddress(t));
106    if (src.hasPhoto())
107      tgt.addPhoto(Attachment30_50.convertAttachment(src.getPhoto()));
108    if (src.hasManagingOrganization())
109      tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization()));
110    if (src.hasActive())
111      tgt.setActiveElement(Boolean30_50.convertBoolean(src.getActiveElement()));
112    for (org.hl7.fhir.dstu3.model.Person.PersonLinkComponent t : src.getLink())
113      tgt.addLink(convertPersonLinkComponent(t));
114    return tgt;
115  }
116
117  public static org.hl7.fhir.dstu3.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.r5.model.Person.PersonLinkComponent src) throws FHIRException {
118    if (src == null)
119      return null;
120    org.hl7.fhir.dstu3.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.dstu3.model.Person.PersonLinkComponent();
121    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
122    if (src.hasTarget())
123      tgt.setTarget(Reference30_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.dstu3.model.Person.PersonLinkComponent src) throws FHIRException {
130    if (src == null)
131      return null;
132    org.hl7.fhir.r5.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.r5.model.Person.PersonLinkComponent();
133    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
134    if (src.hasTarget())
135      tgt.setTarget(Reference30_50.convertReference(src.getTarget()));
136    if (src.hasAssurance())
137      tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement()));
138    return tgt;
139  }
140}