Skip to content

Commit

Permalink
fixed optional json
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickskowronekdkfz committed Oct 29, 2024
1 parent ad2bb5b commit 4ef1fd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 7 additions & 1 deletion src/fhir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ pub struct Entry {
#[serde(rename_all = "camelCase")]
pub struct Resource {
pub meta: Meta,
#[serde(skip_serializing_if = "Option::is_none")]
pub birth_date: Option<String>,
pub resource_type: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub gender: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deceased_date_time: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deceased: Option<bool>,
pub id: String,
pub identifier: Vec<Identifier>,
pub identifier: Option<Vec<Identifier>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub extension: Option<Vec<Extension>>,
}

Expand Down
23 changes: 11 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ async fn main() -> anyhow::Result<()> {
for project in projects {
println!("Adding project information to patients of {}", project.name);
for id_type in ["L", "G"] {
let token = match ma_token_request(&mainzel_client, &session_id, &project, &id_type).await {
Ok(url) => url,
Err(_e) => {
eprintln!("Project {} not configured in mainzelliste", project.name);
continue;
}
};
let token =
match ma_token_request(&mainzel_client, &session_id, &project, &id_type).await {
Ok(url) => url,
Err(_e) => {
eprintln!("Project {} not configured in mainzelliste", project.name);
continue;
}
};
let Ok(patients) = get_patient(&mainzel_client, token).await else {
println!("Did not found any patients from project {}", project.name);
continue;
Expand All @@ -101,11 +102,9 @@ async fn main() -> anyhow::Result<()> {
if !extension.contains(&project_extension) {
extension.push(project_extension);
}
} else {
fhir_patient.extension = Some(vec![project_extension]);
post_patient_to_fhir_server(&fhir_client, fhir_patient).await;
println!("Added project to Patient {}", patient);
}
post_patient_to_fhir_server(&fhir_client, fhir_patient).await;
println!("Added project to Patient {}", patient);
}
Err(e) => {
eprintln!("Did not find patient with pseudonym {}\n{:#}", &patient, e);
Expand Down Expand Up @@ -142,7 +141,7 @@ async fn ma_token_request(
client: &Client,
session_id: &str,
project: &Project,
id_type: &str
id_type: &str,
) -> anyhow::Result<String> {
let mrdataids = mainzelliste::SearchId {
id_string: "*".to_owned(),
Expand Down

0 comments on commit 4ef1fd4

Please sign in to comment.