Skip to main content

haste_fhir_terminology/
lib.rs

1use haste_fhir_client::canonical_resolver::CanonicalResolver;
2use haste_fhir_generated_ops::generated::{CodeSystemLookup, ValueSetExpand, ValueSetValidateCode};
3use haste_fhir_operation_error::{OperationOutcomeError, derive::OperationOutcomeError};
4
5pub mod client;
6
7#[derive(OperationOutcomeError, Debug)]
8pub enum TerminologyError {
9    #[error(code = "processing", diagnostic = "Failed to expand value set")]
10    ExpansionError,
11    #[error(code = "processing", diagnostic = "Failed to validate code")]
12    ValidationError,
13    #[error(code = "processing", diagnostic = "Failed to lookup code system")]
14    LookupError,
15}
16
17pub trait FHIRTerminology {
18    fn expand<Resolver: CanonicalResolver + Sync + Send + Clone + 'static>(
19        &self,
20        resolver: Resolver,
21        input: ValueSetExpand::Input,
22    ) -> impl Future<Output = Result<ValueSetExpand::Output, OperationOutcomeError>> + Send;
23    fn validate<Resolver: CanonicalResolver + Sync + Send + Clone + 'static>(
24        &self,
25        resolver: Resolver,
26        input: ValueSetValidateCode::Input,
27    ) -> impl Future<Output = Result<ValueSetValidateCode::Output, OperationOutcomeError>> + Send;
28    fn lookup<Resolver: CanonicalResolver + Sync + Send + Clone + 'static>(
29        &self,
30        resolver: Resolver,
31        input: CodeSystemLookup::Input,
32    ) -> impl Future<Output = Result<CodeSystemLookup::Output, OperationOutcomeError>> + Send;
33}