
001package org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_30; 004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 005import org.hl7.fhir.dstu3.model.HumanName; 006import org.hl7.fhir.exceptions.FHIRException; 007 008public class HumanName10_30 { 009 public static org.hl7.fhir.dstu3.model.HumanName convertHumanName(org.hl7.fhir.dstu2.model.HumanName src) throws FHIRException { 010 if (src == null || src.isEmpty()) return null; 011 org.hl7.fhir.dstu3.model.HumanName tgt = new org.hl7.fhir.dstu3.model.HumanName(); 012 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 013 if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); 014 if (src.hasTextElement()) tgt.setTextElement(String10_30.convertString(src.getTextElement())); 015 for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamilyElement(String10_30.convertString(t)); 016 for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_30.convertString(t)); 017 for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_30.convertString(t)); 018 for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_30.convertString(t)); 019 if (src.hasPeriod()) tgt.setPeriod(Period10_30.convertPeriod(src.getPeriod())); 020 return tgt; 021 } 022 023 public static org.hl7.fhir.dstu2.model.HumanName convertHumanName(org.hl7.fhir.dstu3.model.HumanName src) throws FHIRException { 024 if (src == null || src.isEmpty()) return null; 025 org.hl7.fhir.dstu2.model.HumanName tgt = new org.hl7.fhir.dstu2.model.HumanName(); 026 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 027 if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement())); 028 if (src.hasTextElement()) tgt.setTextElement(String10_30.convertString(src.getTextElement())); 029 if (src.hasFamily()) tgt.getFamily().add(String10_30.convertString(src.getFamilyElement())); 030 for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_30.convertString(t)); 031 for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_30.convertString(t)); 032 for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_30.convertString(t)); 033 if (src.hasPeriod()) tgt.setPeriod(Period10_30.convertPeriod(src.getPeriod())); 034 return tgt; 035 } 036 037 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.HumanName.NameUse> convertNameUse(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.HumanName.NameUse> src) throws FHIRException { 038 if (src == null || src.isEmpty()) return null; 039 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.HumanName.NameUse> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.HumanName.NameUseEnumFactory()); 040 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 041 if (src.getValue() == null) { 042 tgt.setValue(null); 043} else { 044 switch(src.getValue()) { 045 case USUAL: 046 tgt.setValue(HumanName.NameUse.USUAL); 047 break; 048 case OFFICIAL: 049 tgt.setValue(HumanName.NameUse.OFFICIAL); 050 break; 051 case TEMP: 052 tgt.setValue(HumanName.NameUse.TEMP); 053 break; 054 case NICKNAME: 055 tgt.setValue(HumanName.NameUse.NICKNAME); 056 break; 057 case ANONYMOUS: 058 tgt.setValue(HumanName.NameUse.ANONYMOUS); 059 break; 060 case OLD: 061 tgt.setValue(HumanName.NameUse.OLD); 062 break; 063 case MAIDEN: 064 tgt.setValue(HumanName.NameUse.MAIDEN); 065 break; 066 default: 067 tgt.setValue(HumanName.NameUse.NULL); 068 break; 069 } 070} 071 return tgt; 072 } 073 074 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.HumanName.NameUse> convertNameUse(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.HumanName.NameUse> src) throws FHIRException { 075 if (src == null || src.isEmpty()) return null; 076 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.HumanName.NameUse> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.HumanName.NameUseEnumFactory()); 077 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 078 if (src.getValue() == null) { 079 tgt.setValue(null); 080} else { 081 switch(src.getValue()) { 082 case USUAL: 083 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.USUAL); 084 break; 085 case OFFICIAL: 086 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OFFICIAL); 087 break; 088 case TEMP: 089 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.TEMP); 090 break; 091 case NICKNAME: 092 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NICKNAME); 093 break; 094 case ANONYMOUS: 095 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.ANONYMOUS); 096 break; 097 case OLD: 098 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.OLD); 099 break; 100 case MAIDEN: 101 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.MAIDEN); 102 break; 103 default: 104 tgt.setValue(org.hl7.fhir.dstu2.model.HumanName.NameUse.NULL); 105 break; 106 } 107} 108 return tgt; 109 } 110}