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