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