001package ca.uhn.fhir.jpa.bulk.export.api;
002
003/*-
004 * #%L
005 * HAPI FHIR Storage api
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.jpa.bulk.export.model.BulkExportJobStatusEnum;
024import ca.uhn.fhir.rest.api.server.RequestDetails;
025import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions;
026import org.hl7.fhir.instance.model.api.IIdType;
027
028import javax.transaction.Transactional;
029import java.util.ArrayList;
030import java.util.Date;
031import java.util.List;
032import java.util.Set;
033
034public interface IBulkDataExportSvc {
035        /**
036         * Deprecated - Use {@link #submitJob(BulkDataExportOptions, Boolean, RequestDetails)} instead
037         */
038        @Deprecated
039        JobInfo submitJob(BulkDataExportOptions theBulkDataExportOptions);
040
041        JobInfo submitJob(BulkDataExportOptions theBulkDataExportOptions, Boolean useCache, RequestDetails theRequestDetails);
042
043        JobInfo getJobInfoOrThrowResourceNotFound(String theJobId);
044
045        /**
046         * Return a set of all resource types which contain search parameters which have Patient as a target.
047         */
048        Set<String> getPatientCompartmentResources();
049
050        class JobInfo {
051                private String myJobId;
052                private BulkExportJobStatusEnum myStatus;
053                private List<FileEntry> myFiles;
054                private String myRequest;
055                private Date myStatusTime;
056                private String myStatusMessage;
057
058                public String getRequest() {
059                        return myRequest;
060                }
061
062                public void setRequest(String theRequest) {
063                        myRequest = theRequest;
064                }
065
066                public Date getStatusTime() {
067                        return myStatusTime;
068                }
069
070                public JobInfo setStatusTime(Date theStatusTime) {
071                        myStatusTime = theStatusTime;
072                        return this;
073                }
074
075                public String getJobId() {
076                        return myJobId;
077                }
078
079                public JobInfo setJobId(String theJobId) {
080                        myJobId = theJobId;
081                        return this;
082                }
083
084                public List<FileEntry> getFiles() {
085                        if (myFiles == null) {
086                                myFiles = new ArrayList<>();
087                        }
088                        return myFiles;
089
090                }
091
092                public BulkExportJobStatusEnum getStatus() {
093                        return myStatus;
094                }
095
096                public JobInfo setStatus(BulkExportJobStatusEnum theStatus) {
097                        myStatus = theStatus;
098                        return this;
099                }
100
101                public String getStatusMessage() {
102                        return myStatusMessage;
103                }
104
105                public JobInfo setStatusMessage(String theStatusMessage) {
106                        myStatusMessage = theStatusMessage;
107                        return this;
108                }
109
110                public FileEntry addFile() {
111                        FileEntry retVal = new FileEntry();
112                        getFiles().add(retVal);
113                        return retVal;
114                }
115        }
116
117
118        class FileEntry {
119                private String myResourceType;
120                private IIdType myResourceId;
121
122                public String getResourceType() {
123                        return myResourceType;
124                }
125
126                public FileEntry setResourceType(String theResourceType) {
127                        myResourceType = theResourceType;
128                        return this;
129                }
130
131                public IIdType getResourceId() {
132                        return myResourceId;
133                }
134
135                public FileEntry setResourceId(IIdType theResourceId) {
136                        myResourceId = theResourceId;
137                        return this;
138                }
139        }
140
141
142
143}