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