1use serde::{Deserialize, Serialize};
2use std::env;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Config {
7 pub version: Option<String>,
8 pub sender: Entity,
9 pub requester: Entity,
10 pub receivers: Vec<Entity>,
11 pub patient: PatientConfig,
12 pub security: Option<SecurityConfig>,
13 pub encryption: Option<EncryptionConfig>,
14 pub custom_tags: Option<Vec<String>>,
15 pub report: Option<ReportConfig>,
16 pub files: Option<Vec<FileConfig>>,
17 pub consent: Option<ConsentConfig>,
18 pub deid_keys: Option<Vec<String>>,
19 pub jws_signing_key: Option<String>,
20 pub verify_assertions: Option<bool>,
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct Entity {
26 pub name: String,
27 pub id: String,
28 pub contact: ContactInfo,
29 pub assertion: Option<AssertionConfig>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ContactInfo {
36 Email(String),
37 Detailed { system: String, value: String },
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct AssertionConfig {
43 pub alg: String,
44 pub public_key: String,
45 pub fingerprint: Option<String>,
46 pub key_reference: Option<String>,
47 pub signature: Option<String>,
48 pub expires_at: Option<String>,
49 pub private_key: Option<String>, }
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct PatientConfig {
55 pub name: Option<String>,
56 pub id: Option<String>,
57 pub dob: Option<String>,
58 pub sex: Option<String>,
59 pub identifiers: Option<Vec<IdentifierConfig>>,
60 pub verification: Option<VerificationConfig>,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct IdentifierConfig {
66 pub system: String,
67 pub value: String,
68 pub use_field: Option<String>, }
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct VerificationConfig {
74 pub status: String,
75 pub method: String,
76 pub timestamp: Option<String>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct SecurityConfig {
82 pub classification: Option<String>,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct EncryptionConfig {
88 pub recipient_public_key: String,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct ReportConfig {
94 pub file: Option<String>,
95 pub url: Option<String>,
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum FileConfig {
102 Path(String),
103 Detailed { path: String, name: Option<String> },
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct ConsentConfig {
109 pub status: String,
110 pub scope: Option<Vec<String>>,
111 pub method: Option<String>,
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
116pub struct StudyConfig {
117 pub description: Option<String>,
118 pub uid: Option<String>,
119 pub modality: Option<String>,
120 pub body_part: Option<String>,
121}
122
123impl Default for Config {
124 fn default() -> Self {
125 Self {
126 version: Some("1.0".to_string()),
127 sender: Entity {
128 name: "".to_string(),
129 id: "".to_string(),
130 contact: ContactInfo::Email("".to_string()),
131 assertion: None,
132 },
133 requester: Entity {
134 name: "".to_string(),
135 id: "".to_string(),
136 contact: ContactInfo::Email("".to_string()),
137 assertion: None,
138 },
139 receivers: vec![],
140 patient: PatientConfig {
141 name: None,
142 id: None,
143 dob: None,
144 sex: None,
145 identifiers: None,
146 verification: None,
147 },
148 security: Some(SecurityConfig {
149 classification: Some("confidential".to_string()),
150 }),
151 encryption: None,
152 custom_tags: None,
153 report: None,
154 files: None,
155 consent: None,
156 deid_keys: None,
157 jws_signing_key: None,
158 verify_assertions: None,
159 }
160 }
161}
162
163#[derive(Debug, Clone)]
165pub struct ValidationConfig {
166 pub schema_path: String,
167}
168
169impl Default for ValidationConfig {
170 fn default() -> Self {
171 let schema_path =
172 env::var("JMIX_SCHEMA_DIR").unwrap_or_else(|_| "../jmix/schemas".to_string());
173 Self { schema_path }
174 }
175}