use crate::error::Result;
use crate::record::{CompositionIndexRow, VersionRow};
use openehr::base::{HierObjectId, ObjectVersionId};
use openehr::rm::common::{Contribution, Version};
use openehr::rm::data_types::DvDateTime;
use openehr::rm::ehr::{Composition, Ehr};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CommitOutcome {
pub version_uid: ObjectVersionId,
pub created_container: bool,
}
pub trait Store {
fn engine(&self) -> &'static str;
fn install(&mut self) -> Result<()>;
fn create_ehr(&mut self, ehr: &Ehr) -> Result<()>;
fn get_ehr(&self, ehr_id: &HierObjectId) -> Result<Ehr>;
fn create_contribution(
&mut self,
ehr_id: &HierObjectId,
contribution: &Contribution,
) -> Result<()>;
fn commit_composition(
&mut self,
ehr_id: &HierObjectId,
version: &Version<Composition>,
contribution_uid: &str,
) -> Result<CommitOutcome>;
fn get_version(&self, uid: &ObjectVersionId) -> Result<VersionRow>;
fn latest_version(&self, versioned_object_uid: &HierObjectId) -> Result<VersionRow>;
fn version_at_time(
&self,
versioned_object_uid: &HierObjectId,
at: &DvDateTime,
) -> Result<VersionRow>;
fn all_versions(&self, versioned_object_uid: &HierObjectId) -> Result<Vec<VersionRow>>;
fn find_compositions_by_archetype(
&self,
ehr_id: &HierObjectId,
archetype_id: &str,
) -> Result<Vec<CompositionIndexRow>>;
}