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