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