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        /**
220         * Parameter for the $import operation
221         */
222        public static final String PARAM_IMPORT_POLL_STATUS_JOB_ID = "_jobId";
223        /**
224         * Parameter for the $import operation
225         */
226        public static final String PARAM_IMPORT_JOB_DESCRIPTION = "_jobDescription";
227        /**
228         * Parameter for the $import operation
229         */
230        public static final String PARAM_IMPORT_PROCESSING_MODE = "_processingMode";
231        /**
232         * Parameter for the $import operation
233         */
234        public static final String PARAM_IMPORT_FILE_COUNT = "_fileCount";
235        /**
236         * Parameter for the $import operation
237         */
238        public static final String PARAM_IMPORT_BATCH_SIZE = "_batchSize";
239
240        /**
241         * The [id] of the group when $export is called on /Group/[id]/$export
242         */
243        public static final String PARAM_EXPORT_GROUP_ID = "_groupId";
244
245        /**
246         * Whether mdm should be performed on group export items to expand the group items to linked items before performing the export
247         */
248        public static final String PARAM_EXPORT_MDM = "_mdm";
249
250        /**
251         * Parameter for delete to indicate the deleted resources should also be expunged
252         */
253        public static final String PARAM_DELETE_EXPUNGE = "_expunge";
254
255        /**
256         * URL for extension on a SearchParameter indicating that text values should not be indexed
257         */
258        public static final String EXTENSION_EXT_SYSTEMDEFINED =
259                        JpaConstants.class.getName() + "_EXTENSION_EXT_SYSTEMDEFINED";
260
261        /**
262         * Deprecated.  Please use {@link HapiExtensions#EXT_SEARCHPARAM_PHONETIC_ENCODER} instead.
263         */
264        @Deprecated
265        public static final String EXT_SEARCHPARAM_PHONETIC_ENCODER = HapiExtensions.EXT_SEARCHPARAM_PHONETIC_ENCODER;
266
267        public static final String VALUESET_FILTER_DISPLAY = "display";
268
269        /**
270         * The name of the default partition
271         */
272        public static final String DEFAULT_PARTITION_NAME = ProviderConstants.DEFAULT_PARTITION_NAME;
273
274        /**
275         * The name of the collection of all partitions
276         */
277        public static final String ALL_PARTITIONS_NAME = "ALL_PARTITIONS";
278
279        /**
280         * Parameter for the $expand operation
281         */
282        public static final String OPERATION_EXPAND_PARAM_INCLUDE_HIERARCHY = "includeHierarchy";
283
284        public static final String OPERATION_EXPAND_PARAM_DISPLAY_LANGUAGE = "displayLanguage";
285        public static final String HEADER_UPSERT_EXISTENCE_CHECK = "X-Upsert-Extistence-Check";
286        public static final String HEADER_UPSERT_EXISTENCE_CHECK_DISABLED = "disabled";
287
288        /**
289         * Parameters for the rewrite history operation
290         */
291        public static final String HEADER_REWRITE_HISTORY = "X-Rewrite-History";
292
293        public static final String SKIP_REINDEX_ON_UPDATE = "SKIP-REINDEX-ON-UPDATE";
294        /**
295         * IPS Generation operation name
296         */
297        public static final String OPERATION_SUMMARY = "$summary";
298        /**
299         * IPS Generation operation URL
300         */
301        public static final String SUMMARY_OPERATION_URL = "http://hl7.org/fhir/uv/ips/OperationDefinition/summary";
302
303        public static final String BULK_META_EXTENSION_EXPORT_IDENTIFIER =
304                        "https://hapifhir.org/NamingSystem/bulk-export-identifier";
305        public static final String BULK_META_EXTENSION_JOB_ID = "https://hapifhir.org/NamingSystem/bulk-export-job-id";
306        public static final String BULK_META_EXTENSION_RESOURCE_TYPE =
307                        "https://hapifhir.org/NamingSystem/bulk-export-binary-resource-type";
308        public static final Set<String> UNDESIRED_RESOURCE_LINKAGES_FOR_EVERYTHING_ON_PATIENT_INSTANCE =
309                        Set.of("Provenance", "List", "Group");
310        public static final String HAPI_DATABASE_PARTITION_MODE = "hapi.database_partition_mode";
311        public static final String HAPI_DATABASE_PARTITION_MODE_DEFAULT = "false";
312        public static final String OPERATION_BULK_PATCH = "$hapi.fhir.bulk-patch";
313        public static final String OPERATION_BULK_PATCH_REWRITE = "$hapi.fhir.bulk-patch-rewrite-history";
314        public static final String OPERATION_BULK_PATCH_REWRITE_STATUS = "$hapi.fhir.bulk-patch-rewrite-history-status";
315        public static final String OPERATION_BULK_PATCH_PARAM_PATCH = "patch";
316        public static final String OPERATION_BULK_PATCH_STATUS = "$hapi.fhir.bulk-patch-status";
317        public static final String OPERATION_BULK_PATCH_STATUS_PARAM_JOB_ID = "_jobId";
318        public static final String OPERATION_BULK_PATCH_PARAM_URL = "url";
319
320        /**
321         * Numeric constant used for resource ID in {@link #NO_MORE}
322         */
323        public static final Long NO_MORE_PID = -1L;
324
325        /**
326         * Special PID value used as an internal constant indicating that no more results are available. PIDs should always
327         * be positive, so this value will never appear in real data.
328         */
329        public static final JpaPid NO_MORE = JpaPid.fromId(NO_MORE_PID);
330
331        /**
332         * A page request which only returns a single result (page index = 0, page size = 1)
333         *
334         * @since 8.6.0
335         */
336        public static final PageRequest SINGLE_RESULT = PageRequest.of(0, 1);
337
338        /**
339         * Non-instantiable
340         */
341        private JpaConstants() {
342                // nothing
343        }
344}