View Javadoc
1   
2   package ca.uhn.fhir.rest.api;
3   
4   /*
5    * #%L
6    * HAPI FHIR - Core Library
7    * %%
8    * Copyright (C) 2014 - 2019 University Health Network
9    * %%
10   * Licensed under the Apache License, Version 2.0 (the "License");
11   * you may not use this file except in compliance with the License.
12   * You may obtain a copy of the License at
13   * 
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   * 
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   * #L%
22   */
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import ca.uhn.fhir.model.api.IValueSetEnumBinder;
28  
29  public enum RestSearchParameterTypeEnum {
30  
31  	/**
32  	 * Code Value: <b>number</b>
33  	 *
34  	 * Search parameter SHALL be a number (a whole number, or a decimal).
35  	 */
36  	NUMBER("number", "http://hl7.org/fhir/search-param-type"),
37  	
38  	/**
39  	 * Code Value: <b>date</b>
40  	 *
41  	 * Search parameter is on a date/time. The date format is the standard XML format, though other formats may be supported.
42  	 */
43  	DATE("date", "http://hl7.org/fhir/search-param-type"),
44  	
45  	/**
46  	 * Code Value: <b>string</b>
47  	 *
48  	 * Search parameter is a simple string, like a name part. Search is case-insensitive and accent-insensitive. May match just the start of a string. String parameters may contain spaces.
49  	 */
50  	STRING("string", "http://hl7.org/fhir/search-param-type"),
51  	
52  	/**
53  	 * Code Value: <b>token</b>
54  	 *
55  	 * Search parameter on a coded element or identifier. May be used to search through the text, displayname, code and code/codesystem (for codes) and label, system and key (for identifier). Its value is either a string or a pair of namespace and value, separated by a "|", depending on the modifier used.
56  	 */
57  	TOKEN("token", "http://hl7.org/fhir/search-param-type"),
58  	
59  	/**
60  	 * Code Value: <b>reference</b>
61  	 *
62  	 * A reference to another resource.
63  	 */
64  	REFERENCE("reference", "http://hl7.org/fhir/search-param-type"),
65  	
66  	/**
67  	 * Code Value: <b>composite</b>
68  	 *
69  	 * A composite search parameter that combines a search on two values together.
70  	 */
71  	COMPOSITE("composite", "http://hl7.org/fhir/search-param-type"),
72  	
73  	/**
74  	 * Code Value: <b>quantity</b>
75  	 *
76  	 * A search parameter that searches on a quantity.
77  	 */
78  	QUANTITY("quantity", "http://hl7.org/fhir/search-param-type"),
79  	
80  	/**
81  	 * Code Value: <b>quantity</b>
82  	 *
83  	 * A search parameter that searches on a quantity.
84  	 */
85  	URI("uri", "http://hl7.org/fhir/search-param-type"), 
86  	
87  	/**
88  	 * _has parameter
89  	 */
90  	HAS("string", "http://hl7.org/fhir/search-param-type"),
91  
92  	/**
93  	 * Code Value: <b>number</b>
94  	 *
95  	 * Search parameter SHALL be a number (a whole number, or a decimal).
96  	 */
97  	SPECIAL("special", "http://hl7.org/fhir/search-param-type"),
98  
99  	;
100 
101 	
102 	/**
103 	 * Identifier for this Value Set:
104 	 * http://hl7.org/fhir/vs/search-param-type
105 	 */
106 	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/search-param-type";
107 
108 	/**
109 	 * Name for this Value Set:
110 	 * SearchParamType
111 	 */
112 	public static final String VALUESET_NAME = "SearchParamType";
113 
114 	private static Map<String, RestSearchParameterTypeEnum> CODE_TO_ENUM = new HashMap<String, RestSearchParameterTypeEnum>();
115 	private static Map<String, Map<String, RestSearchParameterTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestSearchParameterTypeEnum>>();
116 	
117 	private final String myCode;
118 	private final String mySystem;
119 	
120 	static {
121 		for (RestSearchParameterTypeEnum next : RestSearchParameterTypeEnum.values()) {
122 			if (next == HAS) {
123 				continue;
124 			}
125 			
126 			CODE_TO_ENUM.put(next.getCode(), next);
127 			
128 			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
129 				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestSearchParameterTypeEnum>());
130 			}
131 			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
132 		}
133 	}
134 	
135 	/**
136 	 * Returns the code associated with this enumerated value
137 	 */
138 	public String getCode() {
139 		return myCode;
140 	}
141 	
142 	/**
143 	 * Returns the code system associated with this enumerated value
144 	 */
145 	public String getSystem() {
146 		return mySystem;
147 	}
148 	
149 	/**
150 	 * Returns the enumerated value associated with this code
151 	 */
152 	public static RestSearchParameterTypeEnum forCode(String theCode) {
153 		RestSearchParameterTypeEnum retVal = CODE_TO_ENUM.get(theCode);
154 		return retVal;
155 	}
156 
157 	/**
158 	 * Converts codes to their respective enumerated values
159 	 */
160 	public static final IValueSetEnumBinder<RestSearchParameterTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestSearchParameterTypeEnum>() {
161 		private static final long serialVersionUID = 1L;
162 
163 		@Override
164 		public String toCodeString(RestSearchParameterTypeEnum theEnum) {
165 			return theEnum.getCode();
166 		}
167 
168 		@Override
169 		public String toSystemString(RestSearchParameterTypeEnum theEnum) {
170 			return theEnum.getSystem();
171 		}
172 		
173 		@Override
174 		public RestSearchParameterTypeEnum fromCodeString(String theCodeString) {
175 			return CODE_TO_ENUM.get(theCodeString);
176 		}
177 		
178 		@Override
179 		public RestSearchParameterTypeEnum fromCodeString(String theCodeString, String theSystemString) {
180 			Map<String, RestSearchParameterTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
181 			if (map == null) {
182 				return null;
183 			}
184 			return map.get(theCodeString);
185 		}
186 		
187 	};
188 	
189 	/** 
190 	 * Constructor
191 	 */
192 	RestSearchParameterTypeEnum(String theCode, String theSystem) {
193 		myCode = theCode;
194 		mySystem = theSystem;
195 	}
196 
197 	
198 }