001/*-
002 * #%L
003 * HAPI FHIR Storage api
004 * %%
005 * Copyright (C) 2014 - 2024 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         * List of filters to be applied to the search.
046         * Eg:
047         * Patient/123?group=1
048         * "group=1" would be the filter
049         */
050        private List<String> myFilters;
051
052        /**
053         * The ID of the BatchJob.
054         * (Batch jobs are stored in Persistence, to keep track
055         * of results/status).
056         */
057        private String myInstanceId;
058
059        private String myChunkId;
060        /**
061         * The export style
062         */
063        private BulkExportJobParameters.ExportStyle myExportStyle;
064        /**
065         * the group id
066         */
067        private String myGroupId;
068        /**
069         * For group export - whether or not to expand mdm
070         */
071        private boolean myExpandMdm;
072        /**
073         * The patient id
074         */
075        private List<String> myPatientIds;
076        /**
077         * The partition id
078         */
079        private RequestPartitionId myPartitionId;
080
081        /**
082         * The list of resource types to recurse on.
083         * This should always have at least one resource in it (the resource being requested)!
084         */
085        private List<String> myRequestedResourceTypes;
086
087        public String getChunkId() {
088                return myChunkId;
089        }
090
091        public void setChunkId(String theChunkId) {
092                myChunkId = theChunkId;
093        }
094
095        public String getResourceType() {
096                return myResourceType;
097        }
098
099        public void setResourceType(String theResourceType) {
100                myResourceType = theResourceType;
101        }
102
103        public Date getStartDate() {
104                return myStartDate;
105        }
106
107        public void setStartDate(Date theStartDate) {
108                myStartDate = theStartDate;
109        }
110
111        public List<String> getFilters() {
112                return myFilters;
113        }
114
115        public void setFilters(List<String> theFilters) {
116                myFilters = theFilters;
117        }
118
119        public String getInstanceId() {
120                return myInstanceId;
121        }
122
123        public void setInstanceId(String theInstanceId) {
124                myInstanceId = theInstanceId;
125        }
126
127        public BulkExportJobParameters.ExportStyle getExportStyle() {
128                return myExportStyle;
129        }
130
131        public void setExportStyle(BulkExportJobParameters.ExportStyle theExportStyle) {
132                myExportStyle = theExportStyle;
133        }
134
135        public String getGroupId() {
136                return myGroupId;
137        }
138
139        public void setGroupId(String theGroupId) {
140                myGroupId = theGroupId;
141        }
142
143        public boolean isExpandMdm() {
144                return myExpandMdm;
145        }
146
147        public void setExpandMdm(boolean theExpandMdm) {
148                myExpandMdm = theExpandMdm;
149        }
150
151        public List<String> getPatientIds() {
152                return myPatientIds;
153        }
154
155        public void setPatientIds(List<String> thePatientIds) {
156                myPatientIds = thePatientIds;
157        }
158
159        public RequestPartitionId getPartitionIdOrAllPartitions() {
160                if (myPartitionId != null) {
161                        return myPartitionId;
162                } else {
163                        return RequestPartitionId.allPartitions();
164                }
165        }
166
167        public void setPartitionId(RequestPartitionId thePartitionId) {
168                myPartitionId = thePartitionId;
169        }
170
171        public List<String> getRequestedResourceTypes() {
172                if (myRequestedResourceTypes == null) {
173                        myRequestedResourceTypes = new ArrayList<>();
174                        if (!isBlank(myResourceType)) {
175                                myRequestedResourceTypes.add(myResourceType);
176                        }
177                }
178                return myRequestedResourceTypes;
179        }
180
181        public void setRequestedResourceTypes(List<String> theRequestedResourceTypes) {
182                myRequestedResourceTypes = theRequestedResourceTypes;
183        }
184
185        @Override
186        public String toString() {
187                return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
188        }
189}