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