haste_fhir_client/
lib.rs

1use haste_fhir_model::r4::generated::resources::{
2    Bundle, CapabilityStatement, Parameters, Resource, ResourceType,
3};
4use haste_fhir_operation_error::OperationOutcomeError;
5use json_patch::Patch;
6
7use crate::{
8    request::{FHIRRequest, FHIRResponse},
9    url::ParsedParameters,
10};
11
12#[cfg(feature = "axum")]
13pub mod axum;
14#[cfg(feature = "http")]
15pub mod http;
16pub mod middleware;
17pub mod request;
18pub mod url;
19
20pub trait FHIRClient<CTX, Error>: Send + Sync {
21    fn request(
22        &self,
23        ctx: CTX,
24        request: FHIRRequest,
25    ) -> impl Future<Output = Result<FHIRResponse, Error>> + Send;
26
27    fn capabilities(
28        &self,
29        ctx: CTX,
30    ) -> impl Future<Output = Result<CapabilityStatement, OperationOutcomeError>> + Send;
31
32    fn search_system(
33        &self,
34        ctx: CTX,
35        parameters: ParsedParameters,
36    ) -> impl Future<Output = Result<Bundle, Error>> + Send;
37    fn search_type(
38        &self,
39        ctx: CTX,
40        resource_type: ResourceType,
41        parameters: ParsedParameters,
42    ) -> impl Future<Output = Result<Bundle, Error>> + Send;
43
44    fn create(
45        &self,
46        ctx: CTX,
47        resource_type: ResourceType,
48        resource: Resource,
49    ) -> impl Future<Output = Result<Resource, Error>> + Send;
50
51    fn update(
52        &self,
53        ctx: CTX,
54        resource_type: ResourceType,
55        id: String,
56        resource: Resource,
57    ) -> impl Future<Output = Result<Resource, Error>> + Send;
58
59    fn conditional_update(
60        &self,
61        ctx: CTX,
62        resource_type: ResourceType,
63        parameters: ParsedParameters,
64        resource: Resource,
65    ) -> impl Future<Output = Result<Resource, Error>> + Send;
66
67    fn patch(
68        &self,
69        ctx: CTX,
70        resource_type: ResourceType,
71        id: String,
72        patches: Patch,
73    ) -> impl Future<Output = Result<Resource, Error>> + Send;
74
75    fn read(
76        &self,
77        ctx: CTX,
78        resource_type: ResourceType,
79        id: String,
80    ) -> impl Future<Output = Result<Option<Resource>, Error>> + Send;
81
82    fn vread(
83        &self,
84        ctx: CTX,
85        resource_type: ResourceType,
86        id: String,
87        version_id: String,
88    ) -> impl Future<Output = Result<Option<Resource>, Error>> + Send;
89
90    fn delete_instance(
91        &self,
92        ctx: CTX,
93        resource_type: ResourceType,
94        id: String,
95    ) -> impl Future<Output = Result<(), Error>> + Send;
96
97    fn delete_type(
98        &self,
99        ctx: CTX,
100        resource_type: ResourceType,
101        parameters: ParsedParameters,
102    ) -> impl Future<Output = Result<(), Error>> + Send;
103
104    fn delete_system(
105        &self,
106        ctx: CTX,
107        parameters: ParsedParameters,
108    ) -> impl Future<Output = Result<(), Error>> + Send;
109
110    fn history_system(
111        &self,
112        ctx: CTX,
113        parameters: ParsedParameters,
114    ) -> impl Future<Output = Result<Bundle, Error>> + Send;
115
116    fn history_type(
117        &self,
118        ctx: CTX,
119        resource_type: ResourceType,
120        parameters: ParsedParameters,
121    ) -> impl Future<Output = Result<Bundle, Error>> + Send;
122
123    fn history_instance(
124        &self,
125        ctx: CTX,
126        resource_type: ResourceType,
127        id: String,
128        parameters: ParsedParameters,
129    ) -> impl Future<Output = Result<Bundle, Error>> + Send;
130
131    fn invoke_instance(
132        &self,
133        ctx: CTX,
134        resource_type: ResourceType,
135        id: String,
136        operation: String,
137        parameters: Parameters,
138    ) -> impl Future<Output = Result<Resource, Error>> + Send;
139
140    fn invoke_type(
141        &self,
142        ctx: CTX,
143        resource_type: ResourceType,
144        operation: String,
145        parameters: Parameters,
146    ) -> impl Future<Output = Result<Resource, Error>> + Send;
147
148    fn invoke_system(
149        &self,
150        ctx: CTX,
151        operation: String,
152        parameters: Parameters,
153    ) -> impl Future<Output = Result<Resource, Error>> + Send;
154
155    fn transaction(
156        &self,
157        ctx: CTX,
158        bundle: Bundle,
159    ) -> impl Future<Output = Result<Bundle, Error>> + Send;
160
161    fn batch(&self, ctx: CTX, bundle: Bundle)
162    -> impl Future<Output = Result<Bundle, Error>> + Send;
163}