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