Skip to main content

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