001/*-
002 * #%L
003 * HAPI FHIR Storage api
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.bulk.export.model;
021
022import ca.uhn.fhir.interceptor.model.RequestPartitionId;
023import ca.uhn.fhir.rest.api.server.bulk.BulkExportJobParameters;
024import org.apache.commons.lang3.builder.ToStringBuilder;
025import org.apache.commons.lang3.builder.ToStringStyle;
026
027import java.util.ArrayList;
028import java.util.Date;
029import java.util.List;
030
031import static org.apache.commons.lang3.StringUtils.isBlank;
032
033public class ExportPIDIteratorParameters {
034        /**
035         * The primary resource type of interest
036         */
037        private String myResourceType;
038
039        /**
040         * The earliest date from which to retrieve records
041         */
042        private Date myStartDate;
043
044        /**
045         * The latest date to which to retrieve records
046         */
047        private Date myEndDate;
048
049        /**
050         * List of filters to be applied to the search.
051         * Eg:
052         * Patient/123?group=1
053         * "group=1" would be the filter
054         */
055        private List<String> myFilters;
056
057        /**
058         * The ID of the BatchJob.
059         * (Batch jobs are stored in Persistence, to keep track
060         * of results/status).
061         */
062        private String myInstanceId;
063
064        private String myChunkId;
065        /**
066         * The export style
067         */
068        private BulkExportJobParameters.ExportStyle myExportStyle;
069        /**
070         * the group id
071         */
072        private String myGroupId;
073        /**
074         * For group export - whether or not to expand mdm
075         */
076        private boolean myExpandMdm;
077        /**
078         * The patient id
079         */
080        private List<String> myPatientIds;
081        /**
082         * The partition id
083         */
084        private RequestPartitionId myPartitionId;
085
086        /**
087         * The list of resource types to recurse on.
088         * This should always have at least one resource in it (the resource being requested)!
089         */
090        private List<String> myRequestedResourceTypes;
091
092        public String getChunkId() {
093                return myChunkId;
094        }
095
096        public void setChunkId(String theChunkId) {
097                myChunkId = theChunkId;
098        }
099
100        public String getResourceType() {
101                return myResourceType;
102        }
103
104        public void setResourceType(String theResourceType) {
105                myResourceType = theResourceType;
106        }
107
108        public Date getStartDate() {
109                return myStartDate;
110        }
111
112        public void setStartDate(Date theStartDate) {
113                myStartDate = theStartDate;
114        }
115
116        public Date getEndDate() {
117                return myEndDate;
118        }
119
120        public void setEndDate(Date theEndDate) {
121                myEndDate = theEndDate;
122        }
123
124        public List<String> getFilters() {
125                return myFilters;
126        }
127
128        public void setFilters(List<String> theFilters) {
129                myFilters = theFilters;
130        }
131
132        public String getInstanceId() {
133                return myInstanceId;
134        }
135
136        public void setInstanceId(String theInstanceId) {
137                myInstanceId = theInstanceId;
138        }
139
140        public BulkExportJobParameters.ExportStyle getExportStyle() {
141                return myExportStyle;
142        }
143
144        public void setExportStyle(BulkExportJobParameters.ExportStyle theExportStyle) {
145                myExportStyle = theExportStyle;
146        }
147
148        public String getGroupId() {
149                return myGroupId;
150        }
151
152        public void setGroupId(String theGroupId) {
153                myGroupId = theGroupId;
154        }
155
156        public boolean isExpandMdm() {
157                return myExpandMdm;
158        }
159
160        public void setExpandMdm(boolean theExpandMdm) {
161                myExpandMdm = theExpandMdm;
162        }
163
164        public List<String> getPatientIds() {
165                return myPatientIds;
166        }
167
168        public void setPatientIds(List<String> thePatientIds) {
169                myPatientIds = thePatientIds;
170        }
171
172        public RequestPartitionId getPartitionIdOrAllPartitions() {
173                if (myPartitionId != null) {
174                        return myPartitionId;
175                } else {
176                        return RequestPartitionId.allPartitions();
177                }
178        }
179
180        public void setPartitionId(RequestPartitionId thePartitionId) {
181                myPartitionId = thePartitionId;
182        }
183
184        public List<String> getRequestedResourceTypes() {
185                if (myRequestedResourceTypes == null) {
186                        myRequestedResourceTypes = new ArrayList<>();
187                        if (!isBlank(myResourceType)) {
188                                myRequestedResourceTypes.add(myResourceType);
189                        }
190                }
191                return myRequestedResourceTypes;
192        }
193
194        public void setRequestedResourceTypes(List<String> theRequestedResourceTypes) {
195                myRequestedResourceTypes = theRequestedResourceTypes;
196        }
197
198        @Override
199        public String toString() {
200                return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
201        }
202}