
001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_40; 004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Address30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Coding30_40; 008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.ContactPoint30_40; 009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40; 010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Decimal30_40; 011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40; 012import org.hl7.fhir.exceptions.FHIRException; 013import org.hl7.fhir.r4.model.Enumeration; 014import org.hl7.fhir.r4.model.Location; 015 016public class Location30_40 { 017 018 public static org.hl7.fhir.r4.model.Location convertLocation(org.hl7.fhir.dstu3.model.Location src) throws FHIRException { 019 if (src == null) 020 return null; 021 org.hl7.fhir.r4.model.Location tgt = new org.hl7.fhir.r4.model.Location(); 022 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 023 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 024 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 025 if (src.hasStatus()) 026 tgt.setStatusElement(convertLocationStatus(src.getStatusElement())); 027 if (src.hasOperationalStatus()) 028 tgt.setOperationalStatus(Coding30_40.convertCoding(src.getOperationalStatus())); 029 if (src.hasName()) 030 tgt.setNameElement(String30_40.convertString(src.getNameElement())); 031 for (org.hl7.fhir.dstu3.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); 032 if (src.hasDescription()) 033 tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement())); 034 if (src.hasMode()) 035 tgt.setModeElement(convertLocationMode(src.getModeElement())); 036 if (src.hasType()) 037 tgt.addType(CodeableConcept30_40.convertCodeableConcept(src.getType())); 038 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) 039 tgt.addTelecom(ContactPoint30_40.convertContactPoint(t)); 040 if (src.hasAddress()) 041 tgt.setAddress(Address30_40.convertAddress(src.getAddress())); 042 if (src.hasPhysicalType()) 043 tgt.setPhysicalType(CodeableConcept30_40.convertCodeableConcept(src.getPhysicalType())); 044 if (src.hasPosition()) 045 tgt.setPosition(convertLocationPositionComponent(src.getPosition())); 046 if (src.hasManagingOrganization()) 047 tgt.setManagingOrganization(Reference30_40.convertReference(src.getManagingOrganization())); 048 if (src.hasPartOf()) 049 tgt.setPartOf(Reference30_40.convertReference(src.getPartOf())); 050 for (org.hl7.fhir.dstu3.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference30_40.convertReference(t)); 051 return tgt; 052 } 053 054 public static org.hl7.fhir.dstu3.model.Location convertLocation(org.hl7.fhir.r4.model.Location src) throws FHIRException { 055 if (src == null) 056 return null; 057 org.hl7.fhir.dstu3.model.Location tgt = new org.hl7.fhir.dstu3.model.Location(); 058 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 059 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 060 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 061 if (src.hasStatus()) 062 tgt.setStatusElement(convertLocationStatus(src.getStatusElement())); 063 if (src.hasOperationalStatus()) 064 tgt.setOperationalStatus(Coding30_40.convertCoding(src.getOperationalStatus())); 065 if (src.hasName()) 066 tgt.setNameElement(String30_40.convertString(src.getNameElement())); 067 for (org.hl7.fhir.r4.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue()); 068 if (src.hasDescription()) 069 tgt.setDescriptionElement(String30_40.convertString(src.getDescriptionElement())); 070 if (src.hasMode()) 071 tgt.setModeElement(convertLocationMode(src.getModeElement())); 072 if (src.hasType()) 073 tgt.setType(CodeableConcept30_40.convertCodeableConcept(src.getTypeFirstRep())); 074 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 075 tgt.addTelecom(ContactPoint30_40.convertContactPoint(t)); 076 if (src.hasAddress()) 077 tgt.setAddress(Address30_40.convertAddress(src.getAddress())); 078 if (src.hasPhysicalType()) 079 tgt.setPhysicalType(CodeableConcept30_40.convertCodeableConcept(src.getPhysicalType())); 080 if (src.hasPosition()) 081 tgt.setPosition(convertLocationPositionComponent(src.getPosition())); 082 if (src.hasManagingOrganization()) 083 tgt.setManagingOrganization(Reference30_40.convertReference(src.getManagingOrganization())); 084 if (src.hasPartOf()) 085 tgt.setPartOf(Reference30_40.convertReference(src.getPartOf())); 086 for (org.hl7.fhir.r4.model.Reference t : src.getEndpoint()) tgt.addEndpoint(Reference30_40.convertReference(t)); 087 return tgt; 088 } 089 090 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationMode> convertLocationMode(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationMode> src) throws FHIRException { 091 if (src == null || src.isEmpty()) 092 return null; 093 Enumeration<Location.LocationMode> tgt = new Enumeration<>(new Location.LocationModeEnumFactory()); 094 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 095 if (src.getValue() == null) { 096 tgt.setValue(null); 097 } else { 098 switch (src.getValue()) { 099 case INSTANCE: 100 tgt.setValue(Location.LocationMode.INSTANCE); 101 break; 102 case KIND: 103 tgt.setValue(Location.LocationMode.KIND); 104 break; 105 default: 106 tgt.setValue(Location.LocationMode.NULL); 107 break; 108 } 109 } 110 return tgt; 111 } 112 113 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationMode> convertLocationMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationMode> src) throws FHIRException { 114 if (src == null || src.isEmpty()) 115 return null; 116 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()); 117 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 118 if (src.getValue() == null) { 119 tgt.setValue(null); 120 } else { 121 switch (src.getValue()) { 122 case INSTANCE: 123 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationMode.INSTANCE); 124 break; 125 case KIND: 126 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationMode.KIND); 127 break; 128 default: 129 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationMode.NULL); 130 break; 131 } 132 } 133 return tgt; 134 } 135 136 public static org.hl7.fhir.r4.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.dstu3.model.Location.LocationPositionComponent src) throws FHIRException { 137 if (src == null) 138 return null; 139 org.hl7.fhir.r4.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.r4.model.Location.LocationPositionComponent(); 140 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 141 if (src.hasLongitude()) 142 tgt.setLongitudeElement(Decimal30_40.convertDecimal(src.getLongitudeElement())); 143 if (src.hasLatitude()) 144 tgt.setLatitudeElement(Decimal30_40.convertDecimal(src.getLatitudeElement())); 145 if (src.hasAltitude()) 146 tgt.setAltitudeElement(Decimal30_40.convertDecimal(src.getAltitudeElement())); 147 return tgt; 148 } 149 150 public static org.hl7.fhir.dstu3.model.Location.LocationPositionComponent convertLocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent src) throws FHIRException { 151 if (src == null) 152 return null; 153 org.hl7.fhir.dstu3.model.Location.LocationPositionComponent tgt = new org.hl7.fhir.dstu3.model.Location.LocationPositionComponent(); 154 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt); 155 if (src.hasLongitude()) 156 tgt.setLongitudeElement(Decimal30_40.convertDecimal(src.getLongitudeElement())); 157 if (src.hasLatitude()) 158 tgt.setLatitudeElement(Decimal30_40.convertDecimal(src.getLatitudeElement())); 159 if (src.hasAltitude()) 160 tgt.setAltitudeElement(Decimal30_40.convertDecimal(src.getAltitudeElement())); 161 return tgt; 162 } 163 164 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationStatus> convertLocationStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationStatus> src) throws FHIRException { 165 if (src == null || src.isEmpty()) 166 return null; 167 Enumeration<Location.LocationStatus> tgt = new Enumeration<>(new Location.LocationStatusEnumFactory()); 168 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 169 if (src.getValue() == null) { 170 tgt.setValue(null); 171 } else { 172 switch (src.getValue()) { 173 case ACTIVE: 174 tgt.setValue(Location.LocationStatus.ACTIVE); 175 break; 176 case SUSPENDED: 177 tgt.setValue(Location.LocationStatus.SUSPENDED); 178 break; 179 case INACTIVE: 180 tgt.setValue(Location.LocationStatus.INACTIVE); 181 break; 182 default: 183 tgt.setValue(Location.LocationStatus.NULL); 184 break; 185 } 186 } 187 return tgt; 188 } 189 190 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Location.LocationStatus> convertLocationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Location.LocationStatus> src) throws FHIRException { 191 if (src == null || src.isEmpty()) 192 return null; 193 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()); 194 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 195 if (src.getValue() == null) { 196 tgt.setValue(null); 197 } else { 198 switch (src.getValue()) { 199 case ACTIVE: 200 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.ACTIVE); 201 break; 202 case SUSPENDED: 203 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.SUSPENDED); 204 break; 205 case INACTIVE: 206 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.INACTIVE); 207 break; 208 default: 209 tgt.setValue(org.hl7.fhir.dstu3.model.Location.LocationStatus.NULL); 210 break; 211 } 212 } 213 return tgt; 214 } 215}