
001package org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40; 005import org.hl7.fhir.exceptions.FHIRException; 006import org.hl7.fhir.r4.model.Address; 007 008public class Address30_40 { 009 public static org.hl7.fhir.r4.model.Address convertAddress(org.hl7.fhir.dstu3.model.Address src) throws FHIRException { 010 if (src == null) return null; 011 org.hl7.fhir.r4.model.Address tgt = new org.hl7.fhir.r4.model.Address(); 012 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 013 if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); 014 if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); 015 if (src.hasText()) tgt.setTextElement(String30_40.convertString(src.getTextElement())); 016 for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.getLine().add(String30_40.convertString(t)); 017 if (src.hasCity()) tgt.setCityElement(String30_40.convertString(src.getCityElement())); 018 if (src.hasDistrict()) tgt.setDistrictElement(String30_40.convertString(src.getDistrictElement())); 019 if (src.hasState()) tgt.setStateElement(String30_40.convertString(src.getStateElement())); 020 if (src.hasPostalCode()) tgt.setPostalCodeElement(String30_40.convertString(src.getPostalCodeElement())); 021 if (src.hasCountry()) tgt.setCountryElement(String30_40.convertString(src.getCountryElement())); 022 if (src.hasPeriod()) tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod())); 023 return tgt; 024 } 025 026 public static org.hl7.fhir.dstu3.model.Address convertAddress(org.hl7.fhir.r4.model.Address src) throws FHIRException { 027 if (src == null) return null; 028 org.hl7.fhir.dstu3.model.Address tgt = new org.hl7.fhir.dstu3.model.Address(); 029 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 030 if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement())); 031 if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement())); 032 if (src.hasText()) tgt.setTextElement(String30_40.convertString(src.getTextElement())); 033 for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.getLine().add(String30_40.convertString(t)); 034 if (src.hasCity()) tgt.setCityElement(String30_40.convertString(src.getCityElement())); 035 if (src.hasDistrict()) tgt.setDistrictElement(String30_40.convertString(src.getDistrictElement())); 036 if (src.hasState()) tgt.setStateElement(String30_40.convertString(src.getStateElement())); 037 if (src.hasPostalCode()) tgt.setPostalCodeElement(String30_40.convertString(src.getPostalCodeElement())); 038 if (src.hasCountry()) tgt.setCountryElement(String30_40.convertString(src.getCountryElement())); 039 if (src.hasPeriod()) tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod())); 040 return tgt; 041 } 042 043 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Address.AddressUse> convertAddressUse(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Address.AddressUse> src) throws FHIRException { 044 if (src == null || src.isEmpty()) return null; 045 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Address.AddressUse> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressUseEnumFactory()); 046 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 047 if (src.getValue() == null) { 048 tgt.setValue(null); 049} else { 050 switch(src.getValue()) { 051 case HOME: 052 tgt.setValue(Address.AddressUse.HOME); 053 break; 054 case WORK: 055 tgt.setValue(Address.AddressUse.WORK); 056 break; 057 case TEMP: 058 tgt.setValue(Address.AddressUse.TEMP); 059 break; 060 case OLD: 061 tgt.setValue(Address.AddressUse.OLD); 062 break; 063 default: 064 tgt.setValue(Address.AddressUse.NULL); 065 break; 066 } 067} 068 return tgt; 069 } 070 071 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Address.AddressUse> convertAddressUse(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Address.AddressUse> src) throws FHIRException { 072 if (src == null || src.isEmpty()) return null; 073 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Address.AddressUse> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressUseEnumFactory()); 074 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 075 if (src.getValue() == null) { 076 tgt.setValue(null); 077} else { 078 switch(src.getValue()) { 079 case HOME: 080 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.HOME); 081 break; 082 case WORK: 083 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.WORK); 084 break; 085 case TEMP: 086 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.TEMP); 087 break; 088 case OLD: 089 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.OLD); 090 break; 091 default: 092 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressUse.NULL); 093 break; 094 } 095} 096 return tgt; 097 } 098 099 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Address.AddressType> convertAddressType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Address.AddressType> src) throws FHIRException { 100 if (src == null || src.isEmpty()) return null; 101 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Address.AddressType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Address.AddressTypeEnumFactory()); 102 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 103 if (src.getValue() == null) { 104 tgt.setValue(null); 105} else { 106 switch(src.getValue()) { 107 case POSTAL: 108 tgt.setValue(Address.AddressType.POSTAL); 109 break; 110 case PHYSICAL: 111 tgt.setValue(Address.AddressType.PHYSICAL); 112 break; 113 case BOTH: 114 tgt.setValue(Address.AddressType.BOTH); 115 break; 116 default: 117 tgt.setValue(Address.AddressType.NULL); 118 break; 119 } 120} 121 return tgt; 122 } 123 124 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Address.AddressType> convertAddressType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Address.AddressType> src) throws FHIRException { 125 if (src == null || src.isEmpty()) return null; 126 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Address.AddressType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Address.AddressTypeEnumFactory()); 127 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 128 if (src.getValue() == null) { 129 tgt.setValue(null); 130} else { 131 switch(src.getValue()) { 132 case POSTAL: 133 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.POSTAL); 134 break; 135 case PHYSICAL: 136 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.PHYSICAL); 137 break; 138 case BOTH: 139 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.BOTH); 140 break; 141 default: 142 tgt.setValue(org.hl7.fhir.dstu3.model.Address.AddressType.NULL); 143 break; 144 } 145} 146 return tgt; 147 } 148}