View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core;
17  
18  import org.openehealth.ipf.commons.ihe.ws.utils.LargeDataSource;
19  import org.openehealth.ipf.commons.ihe.xds.core.metadata.*;
20  import org.openehealth.ipf.commons.ihe.xds.core.requests.*;
21  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.*;
22  import org.openehealth.ipf.commons.ihe.xds.core.responses.*;
23  
24  import javax.activation.DataHandler;
25  import java.util.ArrayList;
26  import java.util.Arrays;
27  import java.util.Collections;
28  import java.util.List;
29  
30  /**
31   * Utility class to create sample data used in tests.
32   * @author Jens Riemschneider
33   */
34  public abstract class SampleData {
35      private SampleData() {
36          throw new UnsupportedOperationException("Utility class");
37      }
38  
39      public static QueryResponse createQueryResponseWithLeafClass() {
40          return createQueryResponseWithLeafClass(
41                  Status.PARTIAL_SUCCESS,
42                  new Identifiable("id3", new AssigningAuthority("1.3")));
43      }
44  
45  
46      /**
47       * @return a sample query response using leaf class return type.
48       */
49      public static QueryResponse createQueryResponseWithLeafClass(Status status, Identifiable... patientIDs) {
50          QueryResponse response = new QueryResponse();
51  
52          for (Identifiable patientID : patientIDs) {
53              SubmissionSet submissionSet = createSubmissionSet(patientID);
54              DocumentEntry docEntry = createDocumentEntry(patientID);
55              Folder folder = createFolder(patientID);
56  
57              Association docAssociation = createAssociationDocEntryToSubmissionSet();
58              Association folderAssociation = createAssociationFolderToSubmissionSet();
59              Association docFolderAssociation = createAssociationDocEntryToFolder();
60  
61              response.getSubmissionSets().add(submissionSet);
62              response.getDocumentEntries().add(docEntry);
63              response.getFolders().add(folder);
64              response.getAssociations().add(docAssociation);
65              response.getAssociations().add(folderAssociation);
66              response.getAssociations().add(docFolderAssociation);
67          }
68  
69          response.setStatus(status);
70          
71          return response;
72      }   
73  
74      /**
75       * @return a sample query response using object reference return type.
76       */
77      public static QueryResponse createQueryResponseWithObjRef() {
78          ObjectReference ref1 = new ObjectReference("ref1");
79          ObjectReference ref2 = new ObjectReference("ref2");
80  
81          QueryResponse response = new QueryResponse();
82          response.setStatus(Status.SUCCESS);
83          response.getReferences().add(ref1);
84          response.getReferences().add(ref2);
85          
86          return response;
87      }   
88  
89      /**
90       * @return a sample response.
91       */
92      public static Response createResponse() {
93          Response response = new Response();
94          response.setStatus(Status.FAILURE);
95          response.getErrors().addAll(Arrays.asList(
96                  new ErrorInfo(ErrorCode.PATIENT_ID_DOES_NOT_MATCH, "context1", Severity.ERROR, "location1", null),
97                  new ErrorInfo(ErrorCode.SQL_ERROR, "context2", Severity.WARNING, null, null),
98                  new ErrorInfo(ErrorCode._USER_DEFINED, "context3", Severity.ERROR, "location3", "MyCustomErrorCode")));
99          return response;
100     }    
101 
102     /**
103      * @return a sample response for retrieved documents.
104      */
105     public static RetrievedDocumentSet createRetrievedDocumentSet() {
106         DocumentReference requestData1 = new DocumentReference();
107         requestData1.setDocumentUniqueId("doc1");
108         requestData1.setHomeCommunityId("urn:oid:1.2.3");
109         requestData1.setRepositoryUniqueId("repo1");
110         
111         DataHandler dataHandler1 = createDataHandler();
112         
113         RetrievedDocument doc1 = new RetrievedDocument();
114         doc1.setRequestData(requestData1);
115         doc1.setDataHandler(dataHandler1);
116         doc1.setMimeType("application/test1");
117 
118         DocumentReference requestData2 = new DocumentReference();
119         requestData2.setDocumentUniqueId("doc2");
120         requestData2.setHomeCommunityId("urn:oid:1.2.4");
121         requestData2.setRepositoryUniqueId("repo2");
122 
123         DataHandler dataHandler2 = createDataHandler();        
124         RetrievedDocument doc2 = new RetrievedDocument();
125         doc2.setRequestData(requestData2);
126         doc2.setDataHandler(dataHandler2);
127         doc2.setMimeType("application/test2");
128         doc2.setNewRepositoryUniqueId("repo2-new");
129         doc2.setNewDocumentUniqueId("doc2-new");
130 
131         RetrievedDocumentSet response = new RetrievedDocumentSet();
132         response.getDocuments().add(doc1);
133         response.getDocuments().add(doc2);
134         response.setStatus(Status.SUCCESS);
135         
136         return response;
137     }
138 
139     /**
140      * Creates a dummy data handler
141      * @return the new data handler.
142      */
143     public static DataHandler createDataHandler() {
144         return new DataHandler(new LargeDataSource());
145     }
146 
147     /**
148      * @return a sample request to provide and register documents.
149      */
150     public static ProvideAndRegisterDocumentSet createProvideAndRegisterDocumentSet() {
151         Identifiable patientID = new Identifiable("id3", new AssigningAuthority("1.3"));
152         
153         SubmissionSet submissionSet = createSubmissionSet(patientID);        
154         DocumentEntry docEntry = createDocumentEntry(patientID);        
155         Folder folder = createFolder(patientID);
156         
157         Association docAssociation = createAssociationDocEntryToSubmissionSet();
158         Association folderAssociation = createAssociationFolderToSubmissionSet();
159         Association docFolderAssociation = createAssociationDocEntryToFolder();
160         
161         DataHandler dataHandler = createDataHandler();
162         Document doc = new Document(docEntry, dataHandler);
163         
164         ProvideAndRegisterDocumentSet request = new ProvideAndRegisterDocumentSet();
165         request.setSubmissionSet(submissionSet);
166         request.getDocuments().add(doc);
167         request.getFolders().add(folder);
168         request.getAssociations().add(docAssociation);
169         request.getAssociations().add(folderAssociation);
170         request.getAssociations().add(docFolderAssociation);
171 
172         request.setTargetHomeCommunityId("urn:oid:1.2.3.4.5.6.2333.23");
173 
174         return request;
175     }
176 
177     private static Association createAssociationDocEntryToFolder() {
178         Association docFolderAssociation = new Association();
179         docFolderAssociation.setAssociationType(AssociationType.HAS_MEMBER);
180         docFolderAssociation.setSourceUuid("folder01");
181         docFolderAssociation.setTargetUuid("document01");
182         docFolderAssociation.setEntryUuid("docFolderAss");
183         return docFolderAssociation;
184     }
185 
186     private static Association createAssociationFolderToSubmissionSet() {
187         Association folderAssociation = new Association();
188         folderAssociation.setAssociationType(AssociationType.HAS_MEMBER);
189         folderAssociation.setSourceUuid("submissionSet01");
190         folderAssociation.setTargetUuid("folder01");
191         folderAssociation.setEntryUuid("folderAss");
192         folderAssociation.setPreviousVersion("110");
193         return folderAssociation;
194     }
195 
196     private static Association createAssociationDocEntryToSubmissionSet() {
197         Association docAssociation = new Association();
198         docAssociation.setAssociationType(AssociationType.HAS_MEMBER);
199         docAssociation.setSourceUuid("submissionSet01");
200         docAssociation.setTargetUuid("document01");
201         docAssociation.setLabel(AssociationLabel.ORIGINAL);
202         docAssociation.setEntryUuid("docAss");
203         docAssociation.setPreviousVersion("111");
204         return docAssociation;
205     }
206 
207     /**
208      * Creates a sample folder.
209      * @param patientID
210      *          the patient ID to use.
211      * @return the folder.                         
212      */
213     public static Folder createFolder(Identifiable patientID) {
214         Folder folder = new Folder();
215         folder.setAvailabilityStatus(AvailabilityStatus.APPROVED);
216         folder.getCodeList().add(new Code("code7", new LocalizedString("code7"), "scheme7"));
217         folder.setComments(new LocalizedString("comments3"));
218         folder.setEntryUuid("folder01");
219         folder.setLastUpdateTime("19820910121315");
220         folder.setPatientId(patientID);
221         folder.setTitle(new LocalizedString("Folder 01", "en-US", "UTF8"));
222         folder.setUniqueId("48574589");
223         return folder;
224     }
225 
226     /**
227      * Creates a sample submission set.
228      * @param patientID
229      *          the patient ID to use.
230      * @return the submission set.
231      */
232     public static SubmissionSet createSubmissionSet(Identifiable patientID) {
233         Recipient recipient = new Recipient();
234         recipient.setOrganization(new Organization("org", null, null));
235         
236         Author author = new Author();
237         author.setAuthorPerson(new Person(new Identifiable("id1", new AssigningAuthority("1.1")),
238                 new XpnName("Otto", null, null, null, null, null)));
239 
240         SubmissionSet submissionSet = new SubmissionSet();
241         submissionSet.getAuthors().add(author);
242         submissionSet.setAvailabilityStatus(AvailabilityStatus.APPROVED);
243         submissionSet.setComments(new LocalizedString("comments1"));
244         submissionSet.setContentTypeCode(new Code("code1", new LocalizedString("code1"), "scheme1"));
245         submissionSet.setEntryUuid("submissionSet01");
246         submissionSet.getIntendedRecipients().add(recipient);
247         submissionSet.setPatientId(patientID);
248         submissionSet.setSourceId("1.2.3");
249         submissionSet.setSubmissionTime("1980");
250         submissionSet.setTitle(new LocalizedString("Submission Set 01", "en-US", "UTF8"));
251         submissionSet.setUniqueId("123");
252         return submissionSet;
253     }
254 
255     /**
256      * Creates a document entry
257      * @param patientID
258      *          patient used for the document entry.
259      * @return the new entry.
260      */
261     public static DocumentEntry createDocumentEntry(Identifiable patientID) {
262         Author author = new Author();
263         Name name = new XpnName();
264         name.setFamilyName("Norbi");
265         author.setAuthorPerson(new Person(new Identifiable("id2", new AssigningAuthority("1.2")), name));
266         author.getAuthorInstitution().add(new Organization("authorOrg", null, null));
267         author.getAuthorRole().add(new Identifiable("role1", new AssigningAuthority("1.2.3.1", "ISO")));
268         author.getAuthorRole().add(new Identifiable("role2", null));
269         author.getAuthorSpecialty().add(new Identifiable("spec1", new AssigningAuthority("1.2.3.3", "ISO")));
270         author.getAuthorSpecialty().add(new Identifiable("spec2", null));
271         author.getAuthorTelecom().add(new Telecom("author1@acme.org"));
272         author.getAuthorTelecom().add(new Telecom("author2@acme.org"));
273 
274         Address address = new Address();
275         address.setStreetAddress("hier");
276         
277         PatientInfo patientInfo = new PatientInfo();
278         patientInfo.getAddresses().add(address);
279         patientInfo.setDateOfBirth("1980");
280         patientInfo.setGender("M");
281         patientInfo.getNames().add(new XpnName("Susi", null, null, null, null, null));
282         
283         DocumentEntry docEntry = new DocumentEntry();
284         docEntry.getAuthors().add(author);
285         docEntry.setAvailabilityStatus(AvailabilityStatus.APPROVED);
286         docEntry.setClassCode(new Code("code2", new LocalizedString("code2"), "scheme2"));
287         docEntry.setComments(new LocalizedString("comment2"));
288         docEntry.getConfidentialityCodes().add(new Code("code8", new LocalizedString("code8"), "scheme8"));
289         docEntry.setCreationTime("1981");
290         docEntry.setEntryUuid("document01");
291         docEntry.getEventCodeList().add(new Code("code9", new LocalizedString("code9"), "scheme9"));
292         docEntry.setFormatCode(new Code("code3", new LocalizedString("code3"), "scheme3"));
293         docEntry.setHash("1234567890123456789012345678901234567890");
294         docEntry.setHealthcareFacilityTypeCode(new Code("code4", new LocalizedString("code4"), "scheme4"));
295         docEntry.setLanguageCode("en-US");
296         docEntry.setLegalAuthenticator(new Person(new Identifiable("legal", new AssigningAuthority("1.7")),
297                 new XpnName("Gustav", null, null, null, null, null)));
298         docEntry.setMimeType("application/octet-stream");
299         docEntry.setPatientId(patientID);
300         docEntry.setPracticeSettingCode(new Code("code5", new LocalizedString("code5"), "scheme5"));
301         docEntry.setRepositoryUniqueId("1.2.3.4");
302         docEntry.setServiceStartTime("198012");
303         docEntry.setServiceStopTime("198101");
304         docEntry.setSize(123L);
305         docEntry.setSourcePatientId(new Identifiable("source", new AssigningAuthority("4.1")));
306         docEntry.setSourcePatientInfo(patientInfo);
307         docEntry.setTitle(new LocalizedString("Document 01", "en-US", "UTF8"));
308         docEntry.setTypeCode(new Code("code6", new LocalizedString("code6"), "scheme6"));
309         docEntry.setUniqueId("32848902348");
310         docEntry.setUri("http://hierunten.com");
311         docEntry.getReferenceIdList().add(new ReferenceId(
312                 "ref-id-1", new CXiAssigningAuthority("ABCD", "1.1.2.3", "ISO"),
313                 ReferenceId.ID_TYPE_CODE_ORDER));
314         docEntry.getReferenceIdList().add(new ReferenceId(
315                 "ref-id-2", new CXiAssigningAuthority("DEFG", "2.1.2.3", "ISO"),
316                 "vendor-defined"));
317         return docEntry;
318     }    
319 
320     /**
321      * @return a sample request to register a document set.
322      */
323     public static RegisterDocumentSet createRegisterDocumentSet() {
324         Identifiable patientID = new Identifiable("id3", new AssigningAuthority("1.3"));
325         
326         SubmissionSet submissionSet = createSubmissionSet(patientID);        
327         DocumentEntry docEntry = createDocumentEntry(patientID);        
328         Folder folder = createFolder(patientID);
329         
330         Association docAssociation = createAssociationDocEntryToSubmissionSet();
331         Association folderAssociation = createAssociationFolderToSubmissionSet();
332         Association docFolderAssociation = createAssociationDocEntryToFolder();
333         
334         RegisterDocumentSet request = new RegisterDocumentSet();
335         request.setSubmissionSet(submissionSet);
336         request.getDocumentEntries().add(docEntry);
337         request.getFolders().add(folder);
338         request.getAssociations().add(docAssociation);
339         request.getAssociations().add(folderAssociation);
340         request.getAssociations().add(docFolderAssociation);
341 
342         request.setTargetHomeCommunityId("urn:oid:1.2.3.4.5.6.2333.23");
343 
344         return request;
345     }
346 
347     /**
348      * @return a sample request to retrieve a document set.
349      */
350     public static RetrieveDocumentSet createRetrieveDocumentSet() {
351         RetrieveDocumentSet request = new RetrieveDocumentSet();
352         request.getDocuments().add(new DocumentReference("repo1", "doc1", "urn:oid:1.2.3"));
353         request.getDocuments().add(new DocumentReference("repo2", "doc2", "urn:oid:1.2.4"));
354         return request;
355     }
356 
357     /**
358      * @return a sample request to remove documents.
359      */
360     public static RemoveDocuments createRemoveDocuments() {
361         RemoveDocuments request = new RemoveDocuments();
362         request.getDocuments().add(new DocumentReference("1.1.1", "2.1.1", "urn:oid:1.2.3"));
363         request.getDocuments().add(new DocumentReference("1.1.2", "2.1.2", "urn:oid:1.2.4"));
364         request.getDocuments().add(new DocumentReference("1.1.3", "2.1.3", "urn:oid:1.2.5"));
365         return request;
366     }
367 
368     /**
369      * @return a sample request to retrieve an imaging document set.
370      */
371     public static RetrieveImagingDocumentSet createRetrieveImagingDocumentSet() {
372         RetrieveImagingDocumentSet request = new RetrieveImagingDocumentSet();
373 
374         List<DocumentReference> documentReferences = new ArrayList<>();
375         DocumentReference documentReference1 = new DocumentReference("repo1", "doc1", "urn:oid:1.2.3");
376         documentReferences.add(documentReference1);
377         DocumentReference documentReference2 = new DocumentReference("repo2", "doc2", "urn:oid:1.2.4");
378         documentReferences.add(documentReference2);
379 
380         List<RetrieveSeries> retrieveSerieses = new ArrayList<>();
381         RetrieveSeries retrieveSeries1 = new RetrieveSeries("urn:oid:1.2.1", documentReferences);
382         retrieveSerieses.add(retrieveSeries1);
383         RetrieveSeries retrieveSeries2 = new RetrieveSeries("urn:oid:1.2.2", documentReferences);
384         retrieveSerieses.add(retrieveSeries2);
385 
386         List<RetrieveStudy> retrieveStudies = request.getRetrieveStudies();
387         RetrieveStudy retrieveStudy1 = new RetrieveStudy("urn:oid:1.1.1", retrieveSerieses);
388         retrieveStudies.add(retrieveStudy1);
389         RetrieveStudy retrieveStudy2 = new RetrieveStudy("urn:oid:1.1.2", retrieveSerieses);
390         retrieveStudies.add(retrieveStudy2);
391 
392         request.getTransferSyntaxIds().add("1.2.840.10008.1.2.4.64");
393         request.getTransferSyntaxIds().add("1.2.840.10008.1.2.4.70");
394 
395         return request;
396     }
397     
398     /**
399      * @return a sample stored query for get documents.
400      */
401     public static QueryRegistry createGetDocumentsQuery() {
402         GetDocumentsQuery query = new GetDocumentsQuery();
403         query.setHomeCommunityId("urn:oid:1.2.3.14.15.926");
404         query.setUuids(Collections.singletonList("document01"));
405         
406         return new QueryRegistry(query);
407     }
408 
409     /**
410      * @return a sample stored query for find documents.
411      */
412     public static QueryRegistry createFindDocumentsQuery() {
413         FindDocumentsQuery query = new FindDocumentsQuery();
414         populateDocumentsQuery(query);
415         query.setPatientId(new Identifiable("id3", new AssigningAuthority("1.3")));
416         query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
417         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
418         query.setDocumentAvailability(Collections.singletonList(DocumentAvailability.ONLINE));
419         query.setMetadataLevel(1);
420         return new QueryRegistry(query);
421     }
422 
423     /**
424      * @return a sample stored query for find documents by reference ID.
425      */
426     public static QueryRegistry createFindDocumentsByReferenceIdQuery() {
427         FindDocumentsByReferenceIdQuery query = new FindDocumentsByReferenceIdQuery();
428         populateDocumentsQuery(query);
429         query.setPatientId(new Identifiable("id3", new AssigningAuthority("1.3")));
430         query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
431         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
432 
433         QueryList<ReferenceId> referenceIds = new QueryList<>();
434         referenceIds.getOuterList().add(Arrays.asList(
435                 new ReferenceId("ref-id-11", new CXiAssigningAuthority("", "1.1.1.1", "ISO"),
436                         ReferenceId.ID_TYPE_CODE_UNIQUE_ID),
437                 new ReferenceId("ref-id-12", null, ReferenceId.ID_TYPE_WORKFLOW_INSTANCE_ID),
438                 new ReferenceId("ref-id-13", null, ReferenceId.ID_TYPE_CODE_REFERRAL)));
439         referenceIds.getOuterList().add(Arrays.asList(
440                 new ReferenceId("ref-id-21", new CXiAssigningAuthority("", "1.1.1.2", "ISO"),
441                         ReferenceId.ID_TYPE_CODE_ACCESSION),
442                 new ReferenceId("ref-id-22", null, ReferenceId.ID_TYPE_CODE_ORDER)));
443         query.setTypedReferenceIds(referenceIds);
444 
445         return new QueryRegistry(query);
446     }
447 
448     private static void populateDocumentsQuery(DocumentsQuery query) {
449         
450         query.setHomeCommunityId("12.21.41");
451 
452         query.setClassCodes(Arrays.asList(new Code("code1", null, "scheme1"), new Code("code2", null, "scheme2")));
453         query.setTypeCodes(Arrays.asList(new Code("codet1", null, "schemet1"), new Code("codet2", null, "schemet2")));
454         query.setPracticeSettingCodes(Arrays.asList(new Code("code3", null, "scheme3"), new Code("code4", null, "scheme4")));
455         query.getCreationTime().setFrom("1980");
456         query.getCreationTime().setTo("1981");
457         query.getServiceStartTime().setFrom("1982");
458         query.getServiceStartTime().setTo("1983");
459         query.getServiceStopTime().setFrom("1984");
460         query.getServiceStopTime().setTo("1985");
461         query.setHealthcareFacilityTypeCodes(Arrays.asList(new Code("code5", null, "scheme5"), new Code("code6", null, "scheme6")));
462         QueryList<Code> eventCodes = new QueryList<>();
463         eventCodes.getOuterList().add(
464                 Arrays.asList(new Code("code7", null, "scheme7"), new Code("code8", null, "scheme8")));
465         eventCodes.getOuterList().add(
466                 Collections.singletonList(new Code("code9", null, "scheme9")));
467         query.setEventCodes(eventCodes);
468         QueryList<Code> confidentialityCodes = new QueryList<>();
469         confidentialityCodes.getOuterList().add(
470                 Arrays.asList(new Code("code10", null, "scheme10"), new Code("code11", null, "scheme11")));
471         confidentialityCodes.getOuterList().add(
472                 Collections.singletonList(new Code("code12", null, "scheme12")));
473         query.setConfidentialityCodes(confidentialityCodes);
474         query.setAuthorPersons(Arrays.asList("per'son1", "person2"));
475         query.setFormatCodes(Arrays.asList(new Code("code13", null, "scheme13"), new Code("code14", null, "scheme14")));
476     }
477 
478     /**
479      * @return a sample stored query for find documents (Multi Patient).
480      */
481     public static QueryRegistry createFindDocumentsForMultiplePatientsQuery() {
482         FindDocumentsForMultiplePatientsQuery query = new FindDocumentsForMultiplePatientsQuery();
483         populateDocumentsQuery(query);
484         query.setPatientIds(Arrays.asList(
485                 new Identifiable("id3", new AssigningAuthority("1.3")),
486                 new Identifiable("id4", new AssigningAuthority("1.4"))));
487         query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
488         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
489         return new QueryRegistry(query);
490     }
491 
492 
493     /**
494      * @return a sample stored query for find folders.
495      */
496     public static QueryRegistry createFindFoldersQuery() {
497         FindFoldersQuery query = new FindFoldersQuery();
498         
499         query.setHomeCommunityId("12.21.41");
500         query.setPatientId(new Identifiable("id1", new AssigningAuthority("1.2")));
501         query.getLastUpdateTime().setFrom("1980");
502         query.getLastUpdateTime().setTo("1981");
503         QueryList<Code> codes = new QueryList<>();
504         codes.getOuterList().add(
505                 Arrays.asList(new Code("code7", null, "scheme7"), new Code("code8", null, "scheme8")));
506         codes.getOuterList().add(
507                 Collections.singletonList(new Code("code9", null, "scheme9")));
508         query.setCodes(codes);
509         query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
510         
511         return new QueryRegistry(query);
512     }
513 
514 
515     /**
516      * @return a sample stored query for find folders.
517      */
518     public static QueryRegistry createFindFoldersForMultiplePatientsQuery() {
519         FindFoldersForMultiplePatientsQuery query = new FindFoldersForMultiplePatientsQuery();
520 
521         query.setHomeCommunityId("12.21.41");
522         query.setPatientIds(Arrays.asList(new Identifiable("id1", new AssigningAuthority("1.2")), new Identifiable("id2", new AssigningAuthority("1.2"))));
523         query.getLastUpdateTime().setFrom("1980");
524         query.getLastUpdateTime().setTo("1981");
525         QueryList<Code> codes = new QueryList<>();
526         codes.getOuterList().add(
527                 Arrays.asList(new Code("code7", null, "scheme7"), new Code("code8", null, "scheme8")));
528         codes.getOuterList().add(
529                 Collections.singletonList(new Code("code9", null, "scheme9")));
530         query.setCodes(codes);
531         query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
532 
533         return new QueryRegistry(query);
534     }
535 
536     /**
537      * @return a sample stored query for find submission sets.
538      */
539     public static QueryRegistry createFindSubmissionSetsQuery() {
540         FindSubmissionSetsQuery query = new FindSubmissionSetsQuery();
541         
542         query.setHomeCommunityId("12.21.41");
543         query.setPatientId(new Identifiable("id1", new AssigningAuthority("1.2")));
544         query.getSubmissionTime().setFrom("1980");
545         query.getSubmissionTime().setTo("1981");
546         query.setAuthorPerson("per'son1");
547         query.setSourceIds(Arrays.asList("1.2.3", "3.2.1"));
548         query.setContentTypeCodes(Arrays.asList(new Code("code1", null, "scheme1"), new Code("code2", null, "scheme2")));
549         query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
550         
551         return new QueryRegistry(query);
552     }
553 
554     /**
555      * @return a sample stored query for getting data from all types.
556      */
557     public static QueryRegistry createGetAllQuery() {
558         GetAllQuery query = new GetAllQuery();
559         
560         query.setHomeCommunityId("12.21.41");
561         query.setPatientId(new Identifiable("id1", new AssigningAuthority("1.2")));
562         QueryList<Code> codes = new QueryList<>();
563         codes.getOuterList().add(
564                 Arrays.asList(new Code("code7", null, "scheme7"), new Code("code8", null, "scheme8")));
565         codes.getOuterList().add(
566                 Collections.singletonList(new Code("code9", null, "scheme9")));
567         query.setConfidentialityCodes(codes);
568         query.setFormatCodes(Arrays.asList(new Code("code1", null, "scheme1"), new Code("code2", null, "scheme2")));
569         query.setStatusDocuments(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
570         query.setStatusFolders(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
571         query.setStatusSubmissionSets(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
572         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
573 
574         return new QueryRegistry(query);
575     }
576 
577     /**
578      * @return a sample stored query for getting associations.
579      */
580     public static QueryRegistry createGetAssociationsQuery() {
581         GetAssociationsQuery query = new GetAssociationsQuery();
582         
583         query.setHomeCommunityId("12.21.41");
584         query.setUuids(Arrays.asList("urn:uuid:1.2.3.4", "urn:uuid:2.3.4.5"));
585         
586         return new QueryRegistry(query);
587     }
588 
589     /**
590      * @return a sample stored query for getting associations and documents.
591      */
592     public static QueryRegistry createGetDocumentsAndAssociationsQuery() {
593         GetDocumentsAndAssociationsQuery query = new GetDocumentsAndAssociationsQuery();
594         
595         query.setHomeCommunityId("12.21.41");
596         query.setUuids(Arrays.asList("urn:uuid:1.2.3.4", "urn:uuid:2.3.4.5"));
597         query.setUniqueIds(Arrays.asList("12.21.34", "43.56.89"));
598         
599         return new QueryRegistry(query);
600     }
601 
602     /**
603      * @return a sample stored query for getting folders and their content.
604      */
605     public static QueryRegistry createGetFolderAndContentsQuery() {
606         GetFolderAndContentsQuery query = new GetFolderAndContentsQuery();
607         
608         query.setHomeCommunityId("12.21.41");
609         query.setUuid("urn:uuid:1.2.3.4");
610         query.setUniqueId("12.21.34");
611         QueryList<Code> confidentialityCodes = new QueryList<>();
612         confidentialityCodes.getOuterList().add(
613                 Arrays.asList(new Code("code10", null, "scheme10"), new Code("code11", null, "scheme11")));
614         confidentialityCodes.getOuterList().add(
615                 Collections.singletonList(new Code("code12", null, "scheme12")));
616         query.setConfidentialityCodes(confidentialityCodes);
617         query.setFormatCodes(Arrays.asList(new Code("code13", null, "scheme13"), new Code("code14", null, "scheme14")));
618         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
619         
620         return new QueryRegistry(query);
621     }
622 
623     /**
624      * @return a sample stored query for getting folders based on their documents.
625      */
626     public static QueryRegistry createGetFoldersForDocumentQuery() {
627         GetFoldersForDocumentQuery query = new GetFoldersForDocumentQuery();
628         
629         query.setHomeCommunityId("12.21.41");
630         query.setUuid("urn:uuid:1.2.3.4");
631         query.setUniqueId("12.21.34");
632         QueryList<Code> confidentialityCodes = new QueryList<>();
633         confidentialityCodes.getOuterList().add(
634                 Arrays.asList(new Code("code10", null, "scheme10"), new Code("code11", null, "scheme11")));
635         confidentialityCodes.getOuterList().add(
636                 Collections.singletonList(new Code("code12", null, "scheme12")));
637         
638         return new QueryRegistry(query);
639     }
640 
641     /**
642      * @return a sample stored query for getting folders.
643      */
644     public static QueryRegistry createGetFoldersQuery() {
645         GetFoldersQuery query = new GetFoldersQuery();
646         
647         query.setHomeCommunityId("12.21.41");
648         query.setUuids(Arrays.asList("urn:uuid:1.2.3.4", "urn:uuid:2.3.4.5"));
649         query.setUniqueIds(Arrays.asList("12.21.34", "43.56.89"));
650         
651         return new QueryRegistry(query);
652     }
653 
654     /**
655      * @return a sample stored query for getting documents related to some other object.
656      */
657     public static QueryRegistry createGetRelatedDocumentsQuery() {
658         GetRelatedDocumentsQuery query = new GetRelatedDocumentsQuery();
659         
660         query.setHomeCommunityId("12.21.41");
661         query.setUuid("urn:uuid:1.2.3.4");
662         query.setUniqueId("12.21.34");
663         query.setAssociationTypes(Arrays.asList(AssociationType.APPEND, AssociationType.TRANSFORM));
664         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
665                 
666         return new QueryRegistry(query);
667     }
668 
669     /**
670      * @return a sample stored query for getting submission sets and their contents.
671      */
672     public static QueryRegistry createGetSubmissionSetAndContentsQuery() {
673         GetSubmissionSetAndContentsQuery query = new GetSubmissionSetAndContentsQuery();
674         
675         query.setHomeCommunityId("12.21.41");
676         query.setUuid("urn:uuid:1.2.3.4");
677         query.setUniqueId("12.21.34");
678         QueryList<Code> confidentialityCodes = new QueryList<>();
679         confidentialityCodes.getOuterList().add(
680                 Arrays.asList(new Code("code10", null, "scheme10"), new Code("code11", null, "scheme11")));
681         confidentialityCodes.getOuterList().add(
682                 Collections.singletonList(new Code("code12", null, "scheme12")));
683         query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
684 
685         return new QueryRegistry(query);
686     }
687 
688     /**
689      * @return a sample stored query for getting submission sets.
690      */
691     public static QueryRegistry createGetSubmissionSetsQuery() {
692         GetSubmissionSetsQuery query = new GetSubmissionSetsQuery();
693         
694         query.setHomeCommunityId("12.21.41");
695         query.setUuids(Arrays.asList("urn:uuid:1.2.3.4", "urn:uuid:2.3.4.5"));
696                 
697         return new QueryRegistry(query);
698     }
699 
700     /**
701      * @return a sample stored query for find documents.
702      */
703     public static QueryRegistry createFetchQuery() {
704         FetchQuery query = new FetchQuery();
705 
706         query.setHomeCommunityId("urn:oid:1.2.21.41");
707         query.setPatientId(new Identifiable("id3", new AssigningAuthority("1.3")));
708         query.setClassCodes(Arrays.asList(new Code("code1", null, "scheme1"), new Code("code2", null, "scheme2")));
709         query.setTypeCodes(Arrays.asList(new Code("codet1", null, "schemet1"), new Code("codet2", null, "schemet2")));
710         query.setPracticeSettingCodes(Arrays.asList(new Code("code3", null, "scheme3"), new Code("code4", null, "scheme4")));
711         query.getCreationTime().setFrom("1980");
712         query.getCreationTime().setTo("1981");
713         query.getServiceStartTime().setFrom("1982");
714         query.getServiceStartTime().setTo("1983");
715         query.getServiceStopTime().setFrom("1984");
716         query.getServiceStopTime().setTo("1985");
717         query.setHealthcareFacilityTypeCodes(Arrays.asList(new Code("code5", null, "scheme5"), new Code("code6", null, "scheme6")));
718         QueryList<Code> eventCodes = new QueryList<>();
719         eventCodes.getOuterList().add(
720                 Arrays.asList(new Code("code7", null, "scheme7"), new Code("code8", null, "scheme8")));
721         eventCodes.getOuterList().add(
722                 Collections.singletonList(new Code("code9", null, "scheme9")));
723         query.setEventCodes(eventCodes);
724         QueryList<Code> confidentialityCodes = new QueryList<>();
725         confidentialityCodes.getOuterList().add(
726                 Arrays.asList(new Code("code10", null, "scheme10"), new Code("code11", null, "scheme11")));
727         confidentialityCodes.getOuterList().add(
728                 Collections.singletonList(new Code("code12", null, "scheme12")));
729         query.setConfidentialityCodes(confidentialityCodes);
730         query.setAuthorPersons(Arrays.asList("per'son1", "person2"));
731         query.setFormatCodes(Arrays.asList(new Code("code13", null, "scheme13"), new Code("code14", null, "scheme14")));
732         //query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
733 
734         QueryRegistry queryRegistry = new QueryRegistry(query);
735         queryRegistry.setReturnType(QueryReturnType.LEAF_CLASS_WITH_REPOSITORY_ITEM);
736         return queryRegistry;
737     }
738 
739 
740     public static RemoveMetadata createRemoveMetadata(){
741         RemoveMetadata removeDocs = new RemoveMetadata();
742         removeDocs.getReferences().add(new ObjectReference("urn:uuid:b2632452-1de7-480d-94b1-c2074d79c871", "1.2.3"));
743         removeDocs.getReferences().add(new ObjectReference("urn:uuid:b2632df2-1de7-480d-1045-c2074d79aabd", "5.6.7"));
744 
745         return removeDocs;
746     }
747 
748 }
749