View Javadoc
1   
2   package ca.uhn.fhir.rest.api;
3   
4   /*
5    * #%L
6    * HAPI FHIR - Core Library
7    * %%
8    * Copyright (C) 2014 - 2018 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  	
94  	/**
95  	 * Identifier for this Value Set:
96  	 * http://hl7.org/fhir/vs/search-param-type
97  	 */
98  	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/search-param-type";
99  
100 	/**
101 	 * Name for this Value Set:
102 	 * SearchParamType
103 	 */
104 	public static final String VALUESET_NAME = "SearchParamType";
105 
106 	private static Map<String, RestSearchParameterTypeEnum> CODE_TO_ENUM = new HashMap<String, RestSearchParameterTypeEnum>();
107 	private static Map<String, Map<String, RestSearchParameterTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestSearchParameterTypeEnum>>();
108 	
109 	private final String myCode;
110 	private final String mySystem;
111 	
112 	static {
113 		for (RestSearchParameterTypeEnum next : RestSearchParameterTypeEnum.values()) {
114 			if (next == HAS) {
115 				continue;
116 			}
117 			
118 			CODE_TO_ENUM.put(next.getCode(), next);
119 			
120 			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
121 				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestSearchParameterTypeEnum>());
122 			}
123 			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
124 		}
125 	}
126 	
127 	/**
128 	 * Returns the code associated with this enumerated value
129 	 */
130 	public String getCode() {
131 		return myCode;
132 	}
133 	
134 	/**
135 	 * Returns the code system associated with this enumerated value
136 	 */
137 	public String getSystem() {
138 		return mySystem;
139 	}
140 	
141 	/**
142 	 * Returns the enumerated value associated with this code
143 	 */
144 	public static RestSearchParameterTypeEnum forCode(String theCode) {
145 		RestSearchParameterTypeEnum retVal = CODE_TO_ENUM.get(theCode);
146 		return retVal;
147 	}
148 
149 	/**
150 	 * Converts codes to their respective enumerated values
151 	 */
152 	public static final IValueSetEnumBinder<RestSearchParameterTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestSearchParameterTypeEnum>() {
153 		private static final long serialVersionUID = 1L;
154 
155 		@Override
156 		public String toCodeString(RestSearchParameterTypeEnum theEnum) {
157 			return theEnum.getCode();
158 		}
159 
160 		@Override
161 		public String toSystemString(RestSearchParameterTypeEnum theEnum) {
162 			return theEnum.getSystem();
163 		}
164 		
165 		@Override
166 		public RestSearchParameterTypeEnum fromCodeString(String theCodeString) {
167 			return CODE_TO_ENUM.get(theCodeString);
168 		}
169 		
170 		@Override
171 		public RestSearchParameterTypeEnum fromCodeString(String theCodeString, String theSystemString) {
172 			Map<String, RestSearchParameterTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
173 			if (map == null) {
174 				return null;
175 			}
176 			return map.get(theCodeString);
177 		}
178 		
179 	};
180 	
181 	/** 
182 	 * Constructor
183 	 */
184 	RestSearchParameterTypeEnum(String theCode, String theSystem) {
185 		myCode = theCode;
186 		mySystem = theSystem;
187 	}
188 
189 	
190 }