001/*-
002 * #%L
003 * HAPI FHIR - Server Framework
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.rest.api.server.bulk;
021
022import ca.uhn.fhir.interceptor.model.RequestPartitionId;
023import ca.uhn.fhir.model.api.BaseBatchJobParameters;
024import ca.uhn.fhir.rest.server.util.JsonDateDeserializer;
025import ca.uhn.fhir.rest.server.util.JsonDateSerializer;
026import com.fasterxml.jackson.annotation.JsonProperty;
027import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
028import com.fasterxml.jackson.databind.annotation.JsonSerialize;
029
030import java.util.ArrayList;
031import java.util.Collection;
032import java.util.Date;
033import java.util.List;
034
035public class BulkExportJobParameters extends BaseBatchJobParameters {
036
037        /**
038         * List of resource types to export.
039         */
040        @JsonProperty("resourceTypes")
041        private List<String> myResourceTypes;
042
043        /**
044         * The start date from when we should start doing the export.
045         */
046        @JsonSerialize(using = JsonDateSerializer.class)
047        @JsonDeserialize(using = JsonDateDeserializer.class)
048        @JsonProperty("since")
049        private Date mySince;
050
051        /**
052         * The end date to which we should stop doing the export.
053         */
054        @JsonSerialize(using = JsonDateSerializer.class)
055        @JsonDeserialize(using = JsonDateDeserializer.class)
056        @JsonProperty("until")
057        private Date myUntil;
058
059        @JsonProperty("exportId")
060        private String myExportId;
061
062        /**
063         * Filters are used to narrow down the resources to export.
064         * Eg:
065         * Patient/123?group=a
066         * "group=a" is a filter
067         */
068        @JsonProperty("filters")
069        private List<String> myFilters;
070
071        /**
072         * URLs to be applied by the inMemoryMatcher after the SQL select
073         */
074        @JsonProperty("postFetchFilterUrls")
075        private List<String> myPostFetchFilterUrls;
076
077        /**
078         * Output format.
079         * Currently unsupported (all outputs are ndjson)
080         */
081        @JsonProperty("outputFormat")
082        private String myOutputFormat;
083
084        /**
085         * Export style - Patient, Group or Everything
086         */
087        @JsonProperty("exportStyle")
088        private ExportStyle myExportStyle;
089
090        /**
091         * Patient id(s)
092         */
093        @JsonProperty("patientIds")
094        private List<String> myPatientIds = new ArrayList<>();
095
096        /**
097         * The request which originated the request.
098         */
099        @JsonProperty("originalRequestUrl")
100        private String myOriginalRequestUrl;
101
102        /**
103         * The group id
104         */
105        @JsonProperty("groupId")
106        private String myGroupId;
107
108        /**
109         * For group export;
110         * whether or not to expand mdm
111         */
112        @JsonProperty("expandMdm")
113        private boolean myExpandMdm;
114
115        /**
116         * The partition for the request if applicable.
117         */
118        @JsonProperty("partitionId")
119        private RequestPartitionId myPartitionId;
120
121        @JsonProperty("binarySecurityContextIdentifierSystem")
122        private String myBinarySecurityContextIdentifierSystem;
123
124        @JsonProperty("binarySecurityContextIdentifierValue")
125        private String myBinarySecurityContextIdentifierValue;
126
127        @JsonProperty("includeHistory")
128        private boolean myIncludeHistory;
129
130        public String getExportIdentifier() {
131                return myExportId;
132        }
133
134        public void setExportIdentifier(String theExportId) {
135                myExportId = theExportId;
136        }
137
138        public List<String> getResourceTypes() {
139                if (myResourceTypes == null) {
140                        myResourceTypes = new ArrayList<>();
141                }
142                return myResourceTypes;
143        }
144
145        public void setResourceTypes(Collection<String> theResourceTypes) {
146                getResourceTypes().clear();
147                if (theResourceTypes != null) {
148                        getResourceTypes().addAll(theResourceTypes);
149                }
150        }
151
152        public Date getSince() {
153                return mySince;
154        }
155
156        public void setSince(Date theSince) {
157                mySince = theSince;
158        }
159
160        public Date getUntil() {
161                return myUntil;
162        }
163
164        public void setUntil(Date theUntil) {
165                myUntil = theUntil;
166        }
167
168        public List<String> getFilters() {
169                if (myFilters == null) {
170                        myFilters = new ArrayList<>();
171                }
172                return myFilters;
173        }
174
175        public void setFilters(Collection<String> theFilters) {
176                getFilters().clear();
177                if (theFilters != null) {
178                        getFilters().addAll(theFilters);
179                }
180        }
181
182        public List<String> getPostFetchFilterUrls() {
183                if (myPostFetchFilterUrls == null) {
184                        myPostFetchFilterUrls = new ArrayList<>();
185                }
186                return myPostFetchFilterUrls;
187        }
188
189        public void setPostFetchFilterUrls(Collection<String> thePostFetchFilterUrls) {
190                getPostFetchFilterUrls().clear();
191                if (thePostFetchFilterUrls != null) {
192                        getPostFetchFilterUrls().addAll(thePostFetchFilterUrls);
193                }
194        }
195
196        public String getOutputFormat() {
197                return myOutputFormat;
198        }
199
200        public void setOutputFormat(String theOutputFormat) {
201                myOutputFormat = theOutputFormat;
202        }
203
204        public ExportStyle getExportStyle() {
205                return myExportStyle;
206        }
207
208        public void setExportStyle(ExportStyle theExportStyle) {
209                myExportStyle = theExportStyle;
210        }
211
212        public List<String> getPatientIds() {
213                if (myPatientIds == null) {
214                        myPatientIds = new ArrayList<>();
215                }
216                return myPatientIds;
217        }
218
219        public void setPatientIds(Collection<String> thePatientIds) {
220                getPatientIds().clear();
221                if (thePatientIds != null) {
222                        getPatientIds().addAll(thePatientIds);
223                }
224        }
225
226        public String getGroupId() {
227                return myGroupId;
228        }
229
230        public void setGroupId(String theGroupId) {
231                myGroupId = theGroupId;
232        }
233
234        public boolean isExpandMdm() {
235                return myExpandMdm;
236        }
237
238        public void setExpandMdm(boolean theExpandMdm) {
239                myExpandMdm = theExpandMdm;
240        }
241
242        public String getOriginalRequestUrl() {
243                return myOriginalRequestUrl;
244        }
245
246        public void setOriginalRequestUrl(String theOriginalRequestUrl) {
247                this.myOriginalRequestUrl = theOriginalRequestUrl;
248        }
249
250        public RequestPartitionId getPartitionId() {
251                return myPartitionId;
252        }
253
254        public boolean isIncludeHistory() {
255                return myIncludeHistory;
256        }
257
258        public void setPartitionId(RequestPartitionId thePartitionId) {
259                this.myPartitionId = thePartitionId;
260        }
261
262        /**
263         * Sets a value to place in the generated Binary resource's
264         * Binary.securityContext.identifier
265         */
266        public void setBinarySecurityContextIdentifierSystem(String theBinarySecurityContextIdentifierSystem) {
267                myBinarySecurityContextIdentifierSystem = theBinarySecurityContextIdentifierSystem;
268        }
269
270        /**
271         * Sets a value to place in the generated Binary resource's
272         * Binary.securityContext.identifier
273         */
274        public String getBinarySecurityContextIdentifierSystem() {
275                return myBinarySecurityContextIdentifierSystem;
276        }
277
278        /**
279         * Sets a value to place in the generated Binary resource's
280         * Binary.securityContext.identifier
281         */
282        public void setBinarySecurityContextIdentifierValue(String theBinarySecurityContextIdentifierValue) {
283                myBinarySecurityContextIdentifierValue = theBinarySecurityContextIdentifierValue;
284        }
285
286        /**
287         * Sets a value to place in the generated Binary resource's
288         * Binary.securityContext.identifier
289         */
290        public String getBinarySecurityContextIdentifierValue() {
291                return myBinarySecurityContextIdentifierValue;
292        }
293
294        /**
295         * Indicates if all history must be exported for exported resources
296         */
297        public void setIncludeHistory(boolean theIncludeHistory) {
298                myIncludeHistory = theIncludeHistory;
299        }
300
301        public enum ExportStyle {
302                PATIENT,
303                GROUP,
304                SYSTEM
305        }
306}