001package org.hl7.fhir.convertors.conv10_40.resources10_40; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_40; 004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40; 005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Boolean10_40; 006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Code10_40; 007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.DateTime10_40; 008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40; 009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Uri10_40; 010import org.hl7.fhir.dstu2.utils.ToolingExtensions; 011import org.hl7.fhir.exceptions.FHIRException; 012 013public class SearchParameter10_40 { 014 015 public static org.hl7.fhir.dstu2.model.SearchParameter convertSearchParameter(org.hl7.fhir.r4.model.SearchParameter src) throws FHIRException { 016 if (src == null || src.isEmpty()) 017 return null; 018 org.hl7.fhir.dstu2.model.SearchParameter tgt = new org.hl7.fhir.dstu2.model.SearchParameter(); 019 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 020 if (src.hasUrlElement()) 021 tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement())); 022 if (src.hasNameElement()) 023 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 024 if (src.hasStatus()) 025 tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement())); 026 if (src.hasExperimental()) 027 tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement())); 028 if (src.hasDate()) 029 tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement())); 030 if (src.hasPublisherElement()) 031 tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement())); 032 for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) 033 tgt.addContact(convertSearchParameterContactComponent(t)); 034 if (src.hasPurpose()) 035 tgt.setRequirements(src.getPurpose()); 036 if (src.hasCodeElement()) 037 tgt.setCodeElement(Code10_40.convertCode(src.getCodeElement())); 038 for (org.hl7.fhir.r4.model.CodeType t : src.getBase()) tgt.setBase(t.asStringValue()); 039 if (src.hasType()) 040 tgt.setTypeElement(Enumerations10_40.convertSearchParamType(src.getTypeElement())); 041 if (src.hasDescription()) 042 tgt.setDescription(src.getDescription()); 043 org.hl7.fhir.dstu2.utils.ToolingExtensions.setStringExtension(tgt, ToolingExtensions.EXT_EXPRESSION, src.getExpression()); 044 if (src.hasXpathElement()) 045 tgt.setXpathElement(String10_40.convertString(src.getXpathElement())); 046 if (src.hasXpathUsage()) 047 tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement())); 048 for (org.hl7.fhir.r4.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue()); 049 return tgt; 050 } 051 052 public static org.hl7.fhir.r4.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu2.model.SearchParameter src) throws FHIRException { 053 if (src == null || src.isEmpty()) 054 return null; 055 org.hl7.fhir.r4.model.SearchParameter tgt = new org.hl7.fhir.r4.model.SearchParameter(); 056 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt); 057 if (src.hasUrlElement()) 058 tgt.setUrlElement(Uri10_40.convertUri(src.getUrlElement())); 059 if (src.hasNameElement()) 060 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 061 if (src.hasStatus()) 062 tgt.setStatusElement(Enumerations10_40.convertConformanceResourceStatus(src.getStatusElement())); 063 if (src.hasExperimental()) 064 tgt.setExperimentalElement(Boolean10_40.convertBoolean(src.getExperimentalElement())); 065 if (src.hasDate()) 066 tgt.setDateElement(DateTime10_40.convertDateTime(src.getDateElement())); 067 if (src.hasPublisherElement()) 068 tgt.setPublisherElement(String10_40.convertString(src.getPublisherElement())); 069 for (org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent t : src.getContact()) 070 tgt.addContact(convertSearchParameterContactComponent(t)); 071 if (src.hasRequirements()) 072 tgt.setPurpose(src.getRequirements()); 073 if (src.hasCodeElement()) 074 tgt.setCodeElement(Code10_40.convertCode(src.getCodeElement())); 075 tgt.addBase(src.getBase()); 076 if (src.hasType()) 077 tgt.setTypeElement(Enumerations10_40.convertSearchParamType(src.getTypeElement())); 078 if (src.hasDescription()) 079 tgt.setDescription(src.getDescription()); 080 tgt.setExpression(ToolingExtensions.readStringExtension(src, ToolingExtensions.EXT_EXPRESSION)); 081 if (src.hasXpathElement()) 082 tgt.setXpathElement(String10_40.convertString(src.getXpathElement())); 083 if (src.hasXpathUsage()) 084 tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement())); 085 for (org.hl7.fhir.dstu2.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue()); 086 return tgt; 087 } 088 089 public static org.hl7.fhir.r4.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException { 090 if (src == null || src.isEmpty()) 091 return null; 092 org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); 093 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 094 if (src.hasNameElement()) 095 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 096 for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom()) 097 tgt.addTelecom(ContactPoint10_40.convertContactPoint(t)); 098 return tgt; 099 } 100 101 public static org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { 102 if (src == null || src.isEmpty()) 103 return null; 104 org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.dstu2.model.SearchParameter.SearchParameterContactComponent(); 105 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 106 if (src.hasNameElement()) 107 tgt.setNameElement(String10_40.convertString(src.getNameElement())); 108 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 109 tgt.addTelecom(ContactPoint10_40.convertContactPoint(t)); 110 return tgt; 111 } 112 113 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType> src) throws FHIRException { 114 if (src == null || src.isEmpty()) 115 return null; 116 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.SearchParameter.XPathUsageTypeEnumFactory()); 117 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 118 tgt.setValue(convertXPathUsageType(src.getValue())); 119 return tgt; 120 } 121 122 static public org.hl7.fhir.r4.model.SearchParameter.XPathUsageType convertXPathUsageType(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType src) { 123 switch (src) { 124 case NORMAL: 125 return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NORMAL; 126 case PHONETIC: 127 return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.PHONETIC; 128 case NEARBY: 129 return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NEARBY; 130 case DISTANCE: 131 return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.DISTANCE; 132 case OTHER: 133 return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.OTHER; 134 default: 135 return org.hl7.fhir.r4.model.SearchParameter.XPathUsageType.NULL; 136 } 137 } 138 139 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.SearchParameter.XPathUsageType> src) throws FHIRException { 140 if (src == null || src.isEmpty()) 141 return null; 142 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageTypeEnumFactory()); 143 ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt); 144 switch (src.getValue()) { 145 case NORMAL: 146 tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NORMAL); 147 break; 148 case PHONETIC: 149 tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.PHONETIC); 150 break; 151 case NEARBY: 152 tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NEARBY); 153 break; 154 case DISTANCE: 155 tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.DISTANCE); 156 break; 157 case OTHER: 158 tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.OTHER); 159 break; 160 default: 161 tgt.setValue(org.hl7.fhir.dstu2.model.SearchParameter.XPathUsageType.NULL); 162 break; 163 } 164 return tgt; 165 } 166}