use crate::crosswalk::Crosswalk;
pub const XTEHR_CANONICAL: &str = "http://www.xt-ehr.eu/fhir/models";
pub const PRIORITY_SYSTEM: &str =
"http://hl7.eu/fhir/health-data-api/CodeSystem/eehrxf-document-priority-category-cs";
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
pub enum Category {
#[cfg(feature = "patient-summary")]
PatientSummary,
#[cfg(feature = "prescription")]
Prescription,
#[cfg(feature = "dispensation")]
Dispensation,
#[cfg(feature = "imaging")]
Imaging,
#[cfg(feature = "laboratory")]
Laboratory,
#[cfg(feature = "discharge")]
Discharge,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Root {
pub model: &'static str,
pub obligations: &'static str,
}
impl Category {
pub const ENABLED: &'static [Self] = &[
#[cfg(feature = "patient-summary")]
Self::PatientSummary,
#[cfg(feature = "prescription")]
Self::Prescription,
#[cfg(feature = "dispensation")]
Self::Dispensation,
#[cfg(feature = "imaging")]
Self::Imaging,
#[cfg(feature = "laboratory")]
Self::Laboratory,
#[cfg(feature = "discharge")]
Self::Discharge,
];
#[must_use]
pub const fn code(self) -> &'static str {
match self {
#[cfg(feature = "patient-summary")]
Self::PatientSummary => "Patient-Summaries",
#[cfg(feature = "prescription")]
Self::Prescription => "Electronic-Prescriptions",
#[cfg(feature = "dispensation")]
Self::Dispensation => "Electronic-Dispensations",
#[cfg(feature = "imaging")]
Self::Imaging => "Medical-Imaging",
#[cfg(feature = "laboratory")]
Self::Laboratory => "Laboratory-Reports",
#[cfg(feature = "discharge")]
Self::Discharge => "Discharge-Reports",
}
}
#[must_use]
pub fn of_code(code: &str) -> Option<Self> {
Self::ENABLED
.iter()
.copied()
.find(|category| category.code() == code)
}
#[must_use]
pub const fn crosswalks(self) -> &'static [&'static Crosswalk<'static>] {
match self {
#[cfg(feature = "patient-summary")]
Self::PatientSummary => &PATIENT_SUMMARY_SET,
#[cfg(feature = "prescription")]
Self::Prescription => &PRESCRIPTION_SET,
#[cfg(feature = "dispensation")]
Self::Dispensation => &DISPENSATION_SET,
#[cfg(feature = "imaging")]
Self::Imaging => &IMAGING_SET,
#[cfg(feature = "laboratory")]
Self::Laboratory => &LABORATORY_SET,
#[cfg(feature = "discharge")]
Self::Discharge => &DISCHARGE_SET,
}
}
#[must_use]
pub const fn roots(self) -> &'static [Root] {
match self {
#[cfg(feature = "patient-summary")]
Self::PatientSummary => &[Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSPatientSummary",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSPatientSummaryObligations",
}],
#[cfg(feature = "prescription")]
Self::Prescription => &[Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSMedicationPrescription",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSMedicationPrescriptionObligations",
}],
#[cfg(feature = "dispensation")]
Self::Dispensation => &[Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSMedicationDispense",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSMedicationDispenseObligations",
}],
#[cfg(feature = "imaging")]
Self::Imaging => &[
Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSImagingReport",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSImagingReportObligations",
},
Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSImagingStudy",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSImagingStudyObligations",
},
],
#[cfg(feature = "laboratory")]
Self::Laboratory => &[Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSLaboratoryReport",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSLaboratoryReportObligations",
}],
#[cfg(feature = "discharge")]
Self::Discharge => &[Root {
model: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSDischargeReport",
obligations: "http://www.xt-ehr.eu/fhir/models/StructureDefinition/EHDSDischargeReportObligations",
}],
}
}
}
#[cfg(feature = "patient-summary")]
static PATIENT_SUMMARY_SET: [&Crosswalk<'static>; 1] =
[&crate::crosswalk::patient_summary::PATIENT_SUMMARY];
#[cfg(feature = "prescription")]
static PRESCRIPTION_SET: [&Crosswalk<'static>; 1] = [&crate::crosswalk::prescription::PRESCRIPTION];
#[cfg(feature = "dispensation")]
static DISPENSATION_SET: [&Crosswalk<'static>; 1] = [&crate::crosswalk::dispensation::DISPENSATION];
#[cfg(feature = "imaging")]
static IMAGING_SET: [&Crosswalk<'static>; 2] = [
&crate::crosswalk::imaging::IMAGING_REPORT,
&crate::crosswalk::imaging::IMAGING_STUDY,
];
#[cfg(feature = "laboratory")]
static LABORATORY_SET: [&Crosswalk<'static>; 1] = [&crate::crosswalk::laboratory::LABORATORY];
#[cfg(feature = "discharge")]
static DISCHARGE_SET: [&Crosswalk<'static>; 1] = [&crate::crosswalk::discharge::DISCHARGE];