001/*-
002 * #%L
003 * HAPI FHIR JPA Model
004 * %%
005 * Copyright (C) 2014 - 2025 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.jpa.model.util;
021
022import ca.uhn.fhir.jpa.model.dao.JpaPid;
023import ca.uhn.fhir.rest.api.Constants;
024import ca.uhn.fhir.rest.server.provider.ProviderConstants;
025import ca.uhn.fhir.util.HapiExtensions;
026import org.springframework.data.domain.PageRequest;
027
028import java.util.Set;
029
030public class JpaConstants {
031
032        /**
033         * Userdata key for tracking the fact that a resource ID was assigned by the server
034         */
035        public static final String RESOURCE_ID_SERVER_ASSIGNED =
036                        JpaConstants.class.getName() + "_RESOURCE_ID_SERVER_ASSIGNED";
037        /**
038         * Operation name for the $apply-codesystem-delta-add operation
039         */
040        public static final String OPERATION_APPLY_CODESYSTEM_DELTA_ADD = "$apply-codesystem-delta-add";
041        /**
042         * Operation name for the $apply-codesystem-delta-remove operation
043         */
044        public static final String OPERATION_APPLY_CODESYSTEM_DELTA_REMOVE = "$apply-codesystem-delta-remove";
045        /**
046         * Operation name for the $expunge operation
047         *
048         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE}
049         */
050        @Deprecated
051        public static final String OPERATION_EXPUNGE = ProviderConstants.OPERATION_EXPUNGE;
052        /**
053         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE}
054         */
055        @Deprecated
056        public static final String OPERATION_NAME_EXPUNGE = ProviderConstants.OPERATION_EXPUNGE;
057        /**
058         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT}
059         */
060        @Deprecated
061        public static final String OPERATION_EXPUNGE_PARAM_LIMIT = ProviderConstants.OPERATION_EXPUNGE_PARAM_LIMIT;
062        /**
063         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT}
064         */
065        @Deprecated
066        public static final String OPERATION_EXPUNGE_PARAM_EXPUNGE_DELETED_RESOURCES =
067                        ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_DELETED_RESOURCES;
068        /**
069         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT}
070         */
071        @Deprecated
072        public static final String OPERATION_EXPUNGE_PARAM_EXPUNGE_PREVIOUS_VERSIONS =
073                        ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_PREVIOUS_VERSIONS;
074        /**
075         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT}
076         */
077        @Deprecated
078        public static final String OPERATION_EXPUNGE_PARAM_EXPUNGE_EVERYTHING =
079                        ProviderConstants.OPERATION_EXPUNGE_PARAM_EXPUNGE_EVERYTHING;
080        /**
081         * @deprecated Replace with {@link ProviderConstants#OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT}
082         */
083        @Deprecated
084        public static final String OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT =
085                        ProviderConstants.OPERATION_EXPUNGE_OUT_PARAM_EXPUNGE_COUNT;
086        /**
087         * Header name for the "X-Meta-Snapshot-Mode" header, which
088         * specifies that properties in meta (tags, profiles, security labels)
089         * should be treated as a snapshot, meaning that these things will
090         * be removed if they are not explicitly included in updates
091         */
092        public static final String HEADER_META_SNAPSHOT_MODE = "X-Meta-Snapshot-Mode";
093        /**
094         * Operation name for the $lookup operation
095         */
096        public static final String OPERATION_LOOKUP = "$lookup";
097        /**
098         * Operation name for the $expand operation
099         */
100        public static final String OPERATION_EXPAND = "$expand";
101        /**
102         * Operation name for the $validate-code operation
103         */
104        public static final String OPERATION_VALIDATE_CODE = "$validate-code";
105        /**
106         * Operation name for the $get-resource-counts operation
107         */
108        public static final String OPERATION_GET_RESOURCE_COUNTS = "$get-resource-counts";
109        /**
110         * Operation name for the $validate operation
111         */
112        // NB don't delete this, it's used in Smile as well, even though hapi-fhir-server uses the version from
113        // Constants.java
114        public static final String OPERATION_VALIDATE = Constants.EXTOP_VALIDATE;
115        /**
116         * Operation name for the $everything operation
117         */
118        public static final String OPERATION_EVERYTHING = "$everything";
119        /**
120         * Operation name for the $process-message operation
121         */
122        public static final String OPERATION_PROCESS_MESSAGE = "$process-message";
123        /**
124         * Operation name for the $meta-delete operation
125         */
126        public static final String OPERATION_META_DELETE = "$meta-delete";
127        /**
128         * Operation name for the $meta-add operation
129         */
130        public static final String OPERATION_META_ADD = "$meta-add";
131        /**
132         * Operation name for the $translate operation
133         */
134        public static final String OPERATION_TRANSLATE = "$translate";
135        /**
136         * Operation name for the $document operation
137         */
138        public static final String OPERATION_DOCUMENT = "$document";
139        /**
140         * Trigger a subscription manually for a given resource
141         */
142        public static final String OPERATION_TRIGGER_SUBSCRIPTION = "$trigger-subscription";
143        /**
144         * Operation name for the "$subsumes" operation
145         */
146        public static final String OPERATION_SUBSUMES = "$subsumes";
147        /**
148         * Operation name for the "$snapshot" operation
149         */
150        public static final String OPERATION_SNAPSHOT = "$snapshot";
151        /**
152         * Operation name for the "$binary-access" operation
153         */
154        public static final String OPERATION_BINARY_ACCESS_READ = "$binary-access-read";
155        /**
156         * Operation name for the "$binary-access" operation
157         */
158        public static final String OPERATION_BINARY_ACCESS_WRITE = "$binary-access-write";
159        /**
160         * Operation name for the "$upload-external-code-system" operation
161         */
162        public static final String OPERATION_UPLOAD_EXTERNAL_CODE_SYSTEM = "$upload-external-code-system";
163        /**
164         * Operation name for the "$import" operation
165         */
166        public static final String OPERATION_IMPORT = "$import";
167        /**
168         * Operation name for the "$import-poll-status" operation
169         */
170        public static final String OPERATION_IMPORT_POLL_STATUS = "$import-poll-status";
171        /**
172         * Operation name for the "$lastn" operation
173         */
174        public static final String OPERATION_LASTN = "$lastn";
175
176        /**
177         * Operation name for the $member-match operation
178         */
179        public static final String OPERATION_MEMBER_MATCH = "$member-match";
180
181        /**
182         * Parameter for the $export operation
183         */
184        public static final String PARAM_EXPORT_POLL_STATUS_JOB_ID = "_jobId";
185        /**
186         * Parameter for the $export operation
187         */
188        public static final String PARAM_EXPORT_OUTPUT_FORMAT = "_outputFormat";
189        /**
190         * Parameter for the $export operation
191         */
192        public static final String PARAM_EXPORT_TYPE = "_type";
193        /**
194         * Parameter for the $export operation
195         */
196        public static final String PARAM_EXPORT_SINCE = "_since";
197        /**
198         * Parameter for the $export operation
199         */
200        public static final String PARAM_EXPORT_UNTIL = "_until";
201        /**
202         * Parameter for the $export operation
203         */
204        public static final String PARAM_EXPORT_TYPE_FILTER = "_typeFilter";
205
206        /**
207         * Parameter for the $export operation to identify binaries with a given identifier.
208         */
209        public static final String PARAM_EXPORT_IDENTIFIER = "_exportId";
210        /**
211         * Parameter for the $export operation
212         */
213        public static final String PARAM_EXPORT_TYPE_POST_FETCH_FILTER_URL = "_typePostFetchFilterUrl";
214        /**
215         * Parameter for the $export operation
216         */
217        public static final String PARAM_EXPORT_PATIENT = "patient";
218        /**
219         * Parameter for the $export operation
220         */
221        public static final String PARAM_EXPORT_INCLUDE_HISTORY = "_includeHistory";
222
223        /**
224         * Parameter for the $import operation
225         */
226        public static final String PARAM_IMPORT_POLL_STATUS_JOB_ID = "_jobId";
227        /**
228         * Parameter for the $import operation
229         */
230        public static final String PARAM_IMPORT_JOB_DESCRIPTION = "_jobDescription";
231        /**
232         * Parameter for the $import operation
233         */
234        public static final String PARAM_IMPORT_PROCESSING_MODE = "_processingMode";
235        /**
236         * Parameter for the $import operation
237         */
238        public static final String PARAM_IMPORT_FILE_COUNT = "_fileCount";
239        /**
240         * Parameter for the $import operation
241         */
242        public static final String PARAM_IMPORT_BATCH_SIZE = "_batchSize";
243
244        /**
245         * The [id] of the group when $export is called on /Group/[id]/$export
246         */
247        public static final String PARAM_EXPORT_GROUP_ID = "_groupId";
248
249        /**
250         * Whether mdm should be performed on group export items to expand the group items to linked items before performing the export
251         */
252        public static final String PARAM_EXPORT_MDM = "_mdm";
253
254        /**
255         * Parameter for delete to indicate the deleted resources should also be expunged
256         */
257        public static final String PARAM_DELETE_EXPUNGE = "_expunge";
258
259        /**
260         * URL for extension on a SearchParameter indicating that text values should not be indexed
261         */
262        public static final String EXTENSION_EXT_SYSTEMDEFINED =
263                        JpaConstants.class.getName() + "_EXTENSION_EXT_SYSTEMDEFINED";
264
265        /**
266         * Deprecated.  Please use {@link HapiExtensions#EXT_SEARCHPARAM_PHONETIC_ENCODER} instead.
267         */
268        @Deprecated
269        public static final String EXT_SEARCHPARAM_PHONETIC_ENCODER = HapiExtensions.EXT_SEARCHPARAM_PHONETIC_ENCODER;
270
271        public static final String VALUESET_FILTER_DISPLAY = "display";
272
273        /**
274         * The name of the default partition
275         */
276        public static final String DEFAULT_PARTITION_NAME = ProviderConstants.DEFAULT_PARTITION_NAME;
277
278        /**
279         * The name of the collection of all partitions
280         */
281        public static final String ALL_PARTITIONS_NAME = "ALL_PARTITIONS";
282
283        /**
284         * Parameter for the $expand operation
285         */
286        public static final String OPERATION_EXPAND_PARAM_INCLUDE_HIERARCHY = "includeHierarchy";
287
288        public static final String OPERATION_EXPAND_PARAM_DISPLAY_LANGUAGE = "displayLanguage";
289        public static final String HEADER_UPSERT_EXISTENCE_CHECK = "X-Upsert-Extistence-Check";
290        public static final String HEADER_UPSERT_EXISTENCE_CHECK_DISABLED = "disabled";
291
292        /**
293         * Parameters for the rewrite history operation
294         */
295        public static final String HEADER_REWRITE_HISTORY = "X-Rewrite-History";
296
297        public static final String SKIP_REINDEX_ON_UPDATE = "SKIP-REINDEX-ON-UPDATE";
298        /**
299         * IPS Generation operation name
300         */
301        public static final String OPERATION_SUMMARY = "$summary";
302        /**
303         * IPS Generation operation URL
304         */
305        public static final String SUMMARY_OPERATION_URL = "http://hl7.org/fhir/uv/ips/OperationDefinition/summary";
306
307        public static final String BULK_META_EXTENSION_EXPORT_IDENTIFIER =
308                        "https://hapifhir.org/NamingSystem/bulk-export-identifier";
309        public static final String BULK_META_EXTENSION_JOB_ID = "https://hapifhir.org/NamingSystem/bulk-export-job-id";
310        public static final String BULK_META_EXTENSION_RESOURCE_TYPE =
311                        "https://hapifhir.org/NamingSystem/bulk-export-binary-resource-type";
312        public static final Set<String> UNDESIRED_RESOURCE_LINKAGES_FOR_EVERYTHING_ON_PATIENT_INSTANCE =
313                        Set.of("Provenance", "List", "Group");
314        public static final String HAPI_DATABASE_PARTITION_MODE = "hapi.database_partition_mode";
315        public static final String HAPI_DATABASE_PARTITION_MODE_DEFAULT = "false";
316        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING = "$hapi.fhir.add-mapping";
317        public static final String OPERATION_CONCEPTMAP_REMOVE_MAPPING = "$hapi.fhir.remove-mapping";
318        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_CONCEPTMAP_URL = "url";
319        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_SOURCE_SYSTEM = "system";
320        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_SOURCE_VERSION = "version";
321        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_SOURCE_CODE = "code";
322        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_SOURCE_DISPLAY = "display";
323        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_TARGET_SYSTEM = "targetSystem";
324        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_TARGET_VERSION = "targetVersion";
325        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_TARGET_CODE = "targetCode";
326        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_TARGET_DISPLAY = "targetDisplay";
327        public static final String OPERATION_CONCEPTMAP_ADD_MAPPING_EQUIVALENCE = "equivalence";
328        public static final String OPERATION_BULK_PATCH = "$hapi.fhir.bulk-patch";
329        public static final String OPERATION_BULK_PATCH_REWRITE = "$hapi.fhir.bulk-patch-rewrite-history";
330        public static final String OPERATION_BULK_PATCH_REWRITE_STATUS = "$hapi.fhir.bulk-patch-rewrite-history-status";
331        public static final String OPERATION_BULK_PATCH_PARAM_PATCH = "patch";
332        public static final String OPERATION_BULK_PATCH_PARAM_BATCH_SIZE = "batchSize";
333        public static final String OPERATION_BULK_PATCH_PARAM_DRY_RUN = "dryRun";
334        public static final String OPERATION_BULK_PATCH_PARAM_DRY_RUN_MODE = "dryRunMode";
335        public static final String OPERATION_BULK_PATCH_PARAM_DRY_RUN_MODE_COUNT = "count";
336        public static final String OPERATION_BULK_PATCH_PARAM_DRY_RUN_MODE_COLLECT_CHANGES = "collectChanges";
337        public static final String OPERATION_BULK_PATCH_PARAM_LIMIT_RESOURCE_COUNT = "limitResourceCount";
338        public static final String OPERATION_BULK_PATCH_PARAM_LIMIT_RESOURCE_VERSION_COUNT = "limitResourceVersionCount";
339        public static final String OPERATION_BULK_PATCH_STATUS = "$hapi.fhir.bulk-patch-status";
340        public static final String OPERATION_BULK_PATCH_STATUS_PARAM_JOB_ID = "_jobId";
341        public static final String OPERATION_BULK_PATCH_PARAM_URL = "url";
342        public static final String OPERATION_BULK_PATCH_STATUS_PARAM_RETURN = "_return";
343        public static final String OPERATION_BULK_PATCH_STATUS_PARAM_RETURN_VALUE_REPORT = "report";
344        public static final String OPERATION_BULK_PATCH_STATUS_PARAM_RETURN_VALUE_DRYRUN_CHANGES = "dryRunChanges";
345
346        /**
347         * Numeric constant used for resource ID in {@link #NO_MORE}
348         */
349        public static final Long NO_MORE_PID = -1L;
350
351        /**
352         * Special PID value used as an internal constant indicating that no more results are available. PIDs should always
353         * be positive, so this value will never appear in real data.
354         */
355        public static final JpaPid NO_MORE = JpaPid.fromId(NO_MORE_PID);
356
357        /**
358         * A page request which only returns a single result (page index = 0, page size = 1)
359         *
360         * @since 8.6.0
361         */
362        public static final PageRequest SINGLE_RESULT = PageRequest.of(0, 1);
363
364        /**
365         * Non-instantiable
366         */
367        private JpaConstants() {
368                // nothing
369        }
370}