001package org.hl7.fhir.convertors.conv10_30.resources10_30;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_30;
004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30;
005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Address10_30;
006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.CodeableConcept10_30;
007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.ContactPoint10_30;
008import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.Identifier10_30;
009import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Decimal10_30;
010import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30;
011import org.hl7.fhir.exceptions.FHIRException;
012
013public class Location10_30 {
014
015  public static org.hl7.fhir.dstu2.model.Location convertLocation(org.hl7.fhir.dstu3.model.Location src) throws FHIRException {
016    if (src == null || src.isEmpty())
017      return null;
018    org.hl7.fhir.dstu2.model.Location tgt = new org.hl7.fhir.dstu2.model.Location();
019    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
020    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
021      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
022    if (src.hasStatus())
023      tgt.setStatusElement(convertLocationStatus(src.getStatusElement()));
024    if (src.hasNameElement())
025      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
026    if (src.hasDescriptionElement())
027      tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement()));
028    if (src.hasMode())
029      tgt.setModeElement(convertLocationMode(src.getModeElement()));
030    if (src.hasType())
031      tgt.setType(CodeableConcept10_30.convertCodeableConcept(src.getType()));
032    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
033      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
034    if (src.hasAddress())
035      tgt.setAddress(Address10_30.convertAddress(src.getAddress()));
036    if (src.hasPhysicalType())
037      tgt.setPhysicalType(CodeableConcept10_30.convertCodeableConcept(src.getPhysicalType()));
038    if (src.hasPosition())
039      tgt.setPosition(convertLocationPositionComponent(src.getPosition()));
040    if (src.hasManagingOrganization())
041      tgt.setManagingOrganization(Reference10_30.convertReference(src.getManagingOrganization()));
042    if (src.hasPartOf())
043      tgt.setPartOf(Reference10_30.convertReference(src.getPartOf()));
044    return tgt;
045  }
046
047  public static org.hl7.fhir.dstu3.model.Location convertLocation(org.hl7.fhir.dstu2.model.Location src) throws FHIRException {
048    if (src == null || src.isEmpty())
049      return null;
050    org.hl7.fhir.dstu3.model.Location tgt = new org.hl7.fhir.dstu3.model.Location();
051    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
052    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
053      tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
054    if (src.hasStatus())
055      tgt.setStatusElement(convertLocationStatus(src.getStatusElement()));
056    if (src.hasNameElement())
057      tgt.setNameElement(String10_30.convertString(src.getNameElement()));
058    if (src.hasDescriptionElement())
059      tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement()));
060    if (src.hasMode())
061      tgt.setModeElement(convertLocationMode(src.getModeElement()));
062    if (src.hasType())
063      tgt.setType(CodeableConcept10_30.convertCodeableConcept(src.getType()));
064    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
065      tgt.addTelecom(ContactPoint10_30.convertContactPoint(t));
066    if (src.hasAddress())
067      tgt.setAddress(Address10_30.convertAddress(src.getAddress()));
068    if (src.hasPhysicalType())
069      tgt.setPhysicalType(CodeableConcept10_30.convertCodeableConcept(src.getPhysicalType()));
070    if (src.hasPosition())
071      tgt.setPosition(convertLocationPositionComponent(src.getPosition()));
072    if (src.hasManagingOrganization())
073      tgt.setManagingOrganization(Reference10_30.convertReference(src.getManagingOrganization()));
074    if (src.hasPartOf())
075      tgt.setPartOf(Reference10_30.convertReference(src.getPartOf()));
076    return tgt;
077  }
078
079  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Location.LocationMode> convertLocationMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationMode> src) throws FHIRException {
080    if (src == null || src.isEmpty())
081      return null;
082    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Location.LocationMode> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Location.LocationModeEnumFactory());
083    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
084    switch (src.getValue()) {
085      case INSTANCE:
086        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationMode.INSTANCE);
087        break;
088      case KIND:
089        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationMode.KIND);
090        break;
091      default:
092        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationMode.NULL);
093        break;
094    }
095    return tgt;
096  }
097
098  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationMode> convertLocationMode(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Location.LocationMode> src) throws FHIRException {
099    if (src == null || src.isEmpty())
100      return null;
101    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationMode> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Location.LocationModeEnumFactory());
102    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
103    switch (src.getValue()) {
104      case INSTANCE:
105        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationMode.INSTANCE);
106        break;
107      case KIND:
108        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationMode.KIND);
109        break;
110      default:
111        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationMode.NULL);
112        break;
113    }
114    return tgt;
115  }
116
117  public static org.hl7.fhir.dstu3.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.dstu2.model.Location.LocationPositionComponent src) throws FHIRException {
118    if (src == null || src.isEmpty())
119      return null;
120    org.hl7.fhir.dstu3.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.dstu3.model.Location.LocationPositionComponent();
121    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt);
122    if (src.hasLongitudeElement())
123      tgt.setLongitudeElement(Decimal10_30.convertDecimal(src.getLongitudeElement()));
124    if (src.hasLatitudeElement())
125      tgt.setLatitudeElement(Decimal10_30.convertDecimal(src.getLatitudeElement()));
126    if (src.hasAltitudeElement())
127      tgt.setAltitudeElement(Decimal10_30.convertDecimal(src.getAltitudeElement()));
128    return tgt;
129  }
130
131  public static org.hl7.fhir.dstu2.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.dstu3.model.Location.LocationPositionComponent src) throws FHIRException {
132    if (src == null || src.isEmpty())
133      return null;
134    org.hl7.fhir.dstu2.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.dstu2.model.Location.LocationPositionComponent();
135    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyBackboneElement(src,tgt);
136    if (src.hasLongitudeElement())
137      tgt.setLongitudeElement(Decimal10_30.convertDecimal(src.getLongitudeElement()));
138    if (src.hasLatitudeElement())
139      tgt.setLatitudeElement(Decimal10_30.convertDecimal(src.getLatitudeElement()));
140    if (src.hasAltitudeElement())
141      tgt.setAltitudeElement(Decimal10_30.convertDecimal(src.getAltitudeElement()));
142    return tgt;
143  }
144
145  static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Location.LocationStatus> convertLocationStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationStatus> src) throws FHIRException {
146    if (src == null || src.isEmpty())
147      return null;
148    org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Location.LocationStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.Location.LocationStatusEnumFactory());
149    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
150    switch (src.getValue()) {
151      case ACTIVE:
152        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationStatus.ACTIVE);
153        break;
154      case SUSPENDED:
155        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationStatus.SUSPENDED);
156        break;
157      case INACTIVE:
158        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationStatus.INACTIVE);
159        break;
160      default:
161        tgt.setValue(org.hl7.fhir.dstu2.model.Location.LocationStatus.NULL);
162        break;
163    }
164    return tgt;
165  }
166
167  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationStatus> convertLocationStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Location.LocationStatus> src) throws FHIRException {
168    if (src == null || src.isEmpty())
169      return null;
170    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Location.LocationStatusEnumFactory());
171    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
172    switch (src.getValue()) {
173      case ACTIVE:
174        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.ACTIVE);
175        break;
176      case SUSPENDED:
177        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.SUSPENDED);
178        break;
179      case INACTIVE:
180        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.INACTIVE);
181        break;
182      default:
183        tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.NULL);
184        break;
185    }
186    return tgt;
187  }
188}