1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.commons.ihe.fhir.iti66;
18
19 import ca.uhn.fhir.model.api.Include;
20 import ca.uhn.fhir.rest.annotation.*;
21 import ca.uhn.fhir.rest.api.SortSpec;
22 import ca.uhn.fhir.rest.api.server.IBundleProvider;
23 import ca.uhn.fhir.rest.param.DateRangeParam;
24 import ca.uhn.fhir.rest.param.ReferenceParam;
25 import ca.uhn.fhir.rest.param.StringParam;
26 import ca.uhn.fhir.rest.param.TokenOrListParam;
27 import ca.uhn.fhir.rest.param.TokenParam;
28 import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
29 import org.hl7.fhir.dstu3.model.DocumentManifest;
30 import org.hl7.fhir.dstu3.model.IdType;
31 import org.hl7.fhir.dstu3.model.Patient;
32 import org.hl7.fhir.dstu3.model.Practitioner;
33 import org.hl7.fhir.instance.model.api.IAnyResource;
34 import org.openehealth.ipf.commons.ihe.fhir.AbstractPlainProvider;
35
36 import javax.servlet.http.HttpServletRequest;
37 import javax.servlet.http.HttpServletResponse;
38 import java.util.Set;
39
40
41
42
43
44
45
46 public class Iti66ResourceProvider extends AbstractPlainProvider {
47
48 @SuppressWarnings("unused")
49 @Search(type = DocumentManifest.class)
50 public IBundleProvider documentManifestSearch(
51 @RequiredParam(name = DocumentManifest.SP_PATIENT, chainWhitelist = {"", Patient.SP_IDENTIFIER}) ReferenceParam patient,
52 @OptionalParam(name = DocumentManifest.SP_CREATED) DateRangeParam created,
53 @OptionalParam(name = DocumentManifest.SP_AUTHOR + "." + Practitioner.SP_FAMILY) StringParam authorFamilyName,
54 @OptionalParam(name = DocumentManifest.SP_AUTHOR + "." + Practitioner.SP_GIVEN) StringParam authorGivenName,
55 @OptionalParam(name = DocumentManifest.SP_TYPE) TokenOrListParam type,
56 @OptionalParam(name = DocumentManifest.SP_SOURCE) TokenOrListParam source,
57 @OptionalParam(name = DocumentManifest.SP_STATUS) TokenOrListParam status,
58
59 @OptionalParam(name = IAnyResource.SP_RES_ID) TokenParam resourceId,
60 @Sort SortSpec sortSpec,
61 @IncludeParam Set<Include> includeSpec,
62 HttpServletRequest httpServletRequest,
63 HttpServletResponse httpServletResponse) {
64
65
66 Iti66SearchParameters parameters = Iti66SearchParameters.builder()
67 .created(created)
68 .authorFamilyName(authorFamilyName)
69 .authorGivenName(authorGivenName)
70 .type(type)
71 .source(source)
72 .status(status)
73 ._id(resourceId)
74 .sortSpec(sortSpec)
75 .includeSpec(includeSpec)
76 .fhirContext(getFhirContext())
77 .build();
78
79 String chain = patient.getChain();
80 if (Patient.SP_IDENTIFIER.equals(chain)) {
81 parameters.setPatientIdentifier(patient.toTokenParam(getFhirContext()));
82 } else if (chain == null || chain.isEmpty()) {
83 parameters.setPatientReference(patient);
84 }
85
86
87 return requestBundleProvider(null, parameters, httpServletRequest, httpServletResponse);
88 }
89
90
91
92
93
94
95
96
97
98
99
100 @SuppressWarnings("unused")
101 @Read(version = true, type = DocumentManifest.class)
102 public DocumentManifest documentManifestRetrieve(
103 @IdParam IdType id,
104 HttpServletRequest httpServletRequest,
105 HttpServletResponse httpServletResponse) {
106 if (id == null) throw new InvalidRequestException("Must provide ID with READ request");
107
108 return requestResource(id, DocumentManifest.class, httpServletRequest, httpServletResponse);
109 }
110
111 }