Compare commits

..

No commits in common. "master" and "v0.4.0" have entirely different histories.

13 changed files with 55 additions and 85 deletions

View File

@ -11,11 +11,11 @@ clap = { version = "4.5", features = ["std", "help", "usage", "derive", "error-c
console = "0.15"
csv = "1.3"
dialoguer = "0.11"
itertools = "0.14"
itertools = "0.13"
mysql = "25.0"
serde = { version = "1.0", features = ["derive"] }
urlencoding = "2.1"
regex = "1.11"
regex = "1.10"
[profile.release]
opt-level = "s"

View File

@ -2,9 +2,6 @@
Anwendung zur Durchführung einer Plausibilitätsprüfung anhand der Daten für die BZKF Real World Data Platform.
**Hinweis:** Dies ist eine Weiterführung des ursprünglichen
Projekts [bzkf-rwdp-check](https://github.com/CCC-MF/bzkf-rwdp-check)
## Aufbau der ETL-Strecke an den Standorten
Die Daten werden aus der Onkostar-Datenbank ausgelesen und in Apache-Kafka eingespeist.
@ -113,8 +110,4 @@ Mithilfe dieser Anwendung kann auch der aktuelle Inhalt der Datenbank gegen die
Export verglichen werden.
Der Befehl `check-export` kann zusammen mit der Angabe der Protokolldatei (`--file`) und der Angabe des
Exports (`--package=...` bzw. `--export-package=...`) und den Optionen für den Datenbankzugriff ausgeführt werden.
Zur Überprüfung werden irrelevante Leerzeichen und Zeilenumbrüche entfernt und _Self-Closed-Tags_ ersetzt
(`<Meldeanlass />` => `<Meldeanlass></Meldeanlass>`),
da in Onkostar in der Datenbank und der LKR-Export-Protokolldatei verschiedene Formatierungen verwendet werden (können).
Exports (`--export-package=...`) und den Optionen für den Datenbankzugriff ausgeführt werden.

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -62,8 +62,6 @@ pub enum SubCommand {
year: String,
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
ignore_exports_since: Option<String>,
#[arg(long, help = "Ignoriere Meldungen, die nicht im oBDS 2.x Format sind")]
ignore_non_obds_2: bool,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
#[arg(
@ -105,8 +103,6 @@ pub enum SubCommand {
year: String,
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
ignore_exports_since: Option<String>,
#[arg(long, help = "Ignoriere Meldungen, die nicht im oBDS 2.x Format sind")]
ignore_non_obds_2: bool,
#[arg(long, help = "Export mit Trennzeichen ';' für Excel")]
xls_csv: bool,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
@ -146,8 +142,6 @@ pub enum SubCommand {
year: String,
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
ignore_exports_since: Option<String>,
#[arg(long, help = "Ignoriere Meldungen, die nicht im oBDS 2.x Format sind")]
ignore_non_obds_2: bool,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
#[arg(
@ -179,13 +173,8 @@ pub enum SubCommand {
user: String,
#[arg(short, long, help = "LKR-Export-Protokoll-Datei")]
file: PathBuf,
#[arg(
long,
alias = "export-package",
help = "Exportpaketnummer",
default_value = "0"
)]
package: u16,
#[arg(long, help = "Exportpaketnummer", default_value = "0")]
export_package: u16,
},
}

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -55,7 +55,6 @@ impl DatabaseSource {
&self,
year: &str,
ignore_exports_since: &str,
ignore_non_obds_2: bool,
include_extern: bool,
include_histo_zyto: bool,
schema_versions: bool,
@ -63,7 +62,6 @@ impl DatabaseSource {
let params = params! {
"year" => year,
"ignore_exports_since" => ignore_exports_since,
"ignore_non_obds_2" => if ignore_non_obds_2 { 1 } else { 0 },
"include_extern" => if include_extern { 1 } else { 0 },
"include_histo_zyto" => if include_histo_zyto { 1 } else { 0 }
};
@ -99,7 +97,6 @@ impl DatabaseSource {
&self,
year: &str,
ignore_exports_since: &str,
ignore_non_obds_2: bool,
use_pat_id: bool,
include_extern: bool,
include_histo_zyto: bool,
@ -112,7 +109,6 @@ impl DatabaseSource {
params! {
"year" => year,
"ignore_exports_since" => ignore_exports_since,
"ignore_non_obds_2" => if ignore_non_obds_2 { 1 } else { 0 },
"include_extern" => if include_extern { 1 } else { 0 },
"include_histo_zyto" => if include_histo_zyto { 1 } else { 0 }
},
@ -138,14 +134,14 @@ impl DatabaseSource {
Err(())
}
pub fn exported(&self, package: u16) -> Result<Vec<(String, String)>, ()> {
pub fn exported(&self, export_id: u16) -> Result<Vec<(String, String)>, ()> {
match Pool::new(self.0.as_str()) {
Ok(pool) => {
if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) {
return match connection.exec_map(
EXPORTED_TO_LKR,
params! {
"export_id" => package,
"export_id" => export_id,
},
|(id, xml_data)| (id, xml_data),
) {

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -51,9 +51,9 @@ fn request_password_if_none(password: Option<String>) -> String {
}
}
fn sanitize_year(year: &str) -> String {
fn sanitize_year(year: String) -> String {
if year.len() == 4 {
year.to_string()
year
} else {
format!("2{:0>3}", year)
}
@ -129,13 +129,12 @@ fn main() -> Result<(), Box<dyn Error>> {
user,
year,
ignore_exports_since,
ignore_non_obds_2,
include_extern,
include_histo_zyto,
schema_versions,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(&year);
let year = sanitize_year(year);
let _ = term.write_line(
&style(format!("Warte auf Daten für das Diagnosejahr {}...", year))
@ -149,7 +148,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.check(
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
ignore_non_obds_2,
include_extern,
include_histo_zyto,
schema_versions,
@ -171,13 +169,12 @@ fn main() -> Result<(), Box<dyn Error>> {
output,
year,
ignore_exports_since,
ignore_non_obds_2,
xls_csv,
include_extern,
include_histo_zyto,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(&year);
let year = sanitize_year(year);
let _ = term.write_line(
&style(format!("Warte auf Daten für das Diagnosejahr {}...", year))
@ -191,7 +188,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.export(
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
ignore_non_obds_2,
pat_id,
include_extern,
include_histo_zyto,
@ -236,12 +232,11 @@ fn main() -> Result<(), Box<dyn Error>> {
file,
year,
ignore_exports_since,
ignore_non_obds_2,
include_extern,
include_histo_zyto,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(&year);
let year = sanitize_year(year);
let _ = term.write_line(
&style(format!("Warte auf Daten für das Diagnosejahr {}...", year))
@ -255,7 +250,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.export(
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
ignore_non_obds_2,
pat_id,
include_extern,
include_histo_zyto,
@ -269,7 +263,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut not_in_csv = db_items
.iter()
.filter(|&db_item| {
.filter(|db_item| {
!csv_items
.iter()
.map(|csv_item| &csv_item.condition_id)
@ -299,7 +293,7 @@ fn main() -> Result<(), Box<dyn Error>> {
not_in_csv
.iter()
.for_each(|&item| match Check::is_relevant(&item.icd_10_code) {
.for_each(|item| match Check::is_relevant(&item.icd_10_code) {
true => {
let _ = term.write_line(&format!(
"{:<64} {:<10} {:<5} {:<5} {}",
@ -330,7 +324,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut not_in_db = csv_items
.iter()
.filter(|&csv_item| {
.filter(|csv_item| {
!db_items
.iter()
.map(|db_item| &db_item.condition_id)
@ -450,14 +444,14 @@ fn main() -> Result<(), Box<dyn Error>> {
port,
user,
file,
package,
export_package,
} => {
let password = request_password_if_none(password);
let _ = term.write_line(
&style(format!(
"Warte auf Daten für den LKR-Export '{}'...",
package
export_package
))
.blue()
.bright()
@ -467,7 +461,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let db = DatabaseSource::new(&database, &host, &password, port, &user);
let db_entries = db
.exported(package)
.exported(export_package)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
let db_meldungen = db_entries
@ -504,16 +498,6 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(),
);
fn print_missing_ids(missing_ids: &[&String], term: &Term) {
missing_ids.iter().sorted().for_each(|&item| {
let _ = term.write_line(&format!(
"{} ({})",
item,
to_database_id(item).unwrap_or("?".into())
));
});
}
if db_meldungen.len() != xml_meldungen.len() {
let _ = term.write_line(
&style("\nNicht übereinstimmende Anzahl an Meldungen:")
@ -538,7 +522,13 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(),
);
print_missing_ids(&missing_db_ids, &term);
missing_db_ids.iter().sorted().for_each(|&item| {
let _ = term.write_line(&format!(
"{} ({})",
item,
to_database_id(item).unwrap_or("?".into())
));
});
}
if !missing_xml_ids.is_empty() {
@ -548,7 +538,13 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(),
);
print_missing_ids(&missing_xml_ids, &term);
missing_xml_ids.iter().sorted().for_each(|&item| {
let _ = term.write_line(&format!(
"{} ({})",
item,
to_database_id(item).unwrap_or("?".into())
));
});
}
}
@ -572,7 +568,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.to_string(),
);
multiple_meldung_entries.iter().for_each(|&item| {
multiple_meldung_entries.iter().for_each(|item| {
let _ = term.write_line(&item.to_string());
});
}
@ -608,7 +604,7 @@ fn main() -> Result<(), Box<dyn Error>> {
different_content
.iter()
.sorted_by(|&id1, &id2| {
.sorted_by(|id1, id2| {
to_database_id(id1)
.unwrap_or_default()
.cmp(&to_database_id(id2).unwrap_or_default())

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -29,17 +29,15 @@ FROM (
EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid,
lme.versionsnummer,
SHA2(CONCAT('https://fhir.diz.uk-erlangen.de/identifiers/onkostar-xml-condition-id|', EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID'), 'condition', EXTRACTVALUE(lme.xml_daten, '//Diagnose/@Tumor_ID')), 256) AS cond_id,
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Primaertumor_ICD_Code'), ' ', 1) AS condcodingcode,
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1) AS diagnosedatum,
SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
SUBSTRING_INDEX(EXTRACTVALUE(lm.xml_daten, '//Primaertumor_ICD_Code'), ' ', 1) AS condcodingcode,
SUBSTRING_INDEX(EXTRACTVALUE(lm.xml_daten, '//Diagnosedatum'), ' ', 1) AS diagnosedatum,
SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lm.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
FROM lkr_meldung_export lme
WHERE lme.xml_daten LIKE '%ICD_Version%'
AND lme.typ <> -1
AND lme.xml_daten NOT LIKE '%<Menge_Tumorkonferenz%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
AND (lme.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
AND (EXTRACTVALUE(lme.xml_daten, '//Meldende_Stelle') NOT LIKE '%9999%' OR 1 <= :include_extern)
AND (EXTRACTVALUE(lme.xml_daten, '//ADT_GEKID/@Schema_Version') LIKE '2.%' OR 1 = :ignore_non_obds_2)
JOIN lkr_meldung lm ON (lm.id = lme.lkr_meldung AND lme.typ <> '-1' AND lm.extern <= :include_extern)
WHERE lm.xml_daten LIKE '%ICD_Version%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lm.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
AND (lm.xml_daten LIKE '%<cTNM%' OR lm.xml_daten LIKE '%<pTNM%' OR lm.xml_daten LIKE '%<Menge_Histologie>%' OR lm.xml_daten LIKE '%<Menge_Weitere_Klassifikation>%')
AND (lm.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
) o1
LEFT OUTER JOIN (

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -121,11 +121,10 @@ FROM (
FROM lkr_meldung_export lme
WHERE lme.xml_daten LIKE '%ICD_Version%'
AND lme.typ <> -1
AND lme.xml_daten NOT LIKE '%<Menge_Tumorkonferenz%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
AND (lme.xml_daten LIKE '%<cTNM%' OR lme.xml_daten LIKE '%<pTNM%' OR lme.xml_daten LIKE '%<Menge_Histologie>%' OR lme.xml_daten LIKE '%<Menge_Weitere_Klassifikation>%')
AND (lme.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
AND (EXTRACTVALUE(lme.xml_daten, '//Meldende_Stelle') NOT LIKE '%9999%' OR 1 <= :include_extern)
AND (EXTRACTVALUE(lme.xml_daten, '//ADT_GEKID/@Schema_Version') LIKE '2.%' OR 1 = :ignore_non_obds_2)
) o1
LEFT OUTER JOIN (
SELECT DISTINCT

View File

@ -1,7 +1,7 @@
/*
* This file is part of bzkf-rwdp-check
*
* Copyright (C) 2024 the original author or authors.
* Copyright (C) 2024 Comprehensive Cancer Center Mainfranken and contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -121,11 +121,10 @@ FROM (
FROM lkr_meldung_export lme
WHERE lme.xml_daten LIKE '%ICD_Version%'
AND lme.typ <> -1
AND lme.xml_daten NOT LIKE '%<Menge_Tumorkonferenz%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
AND (lme.xml_daten LIKE '%<cTNM%' OR lme.xml_daten LIKE '%<pTNM%' OR lme.xml_daten LIKE '%<Menge_Histologie>%' OR lme.xml_daten LIKE '%<Menge_Weitere_Klassifikation>%')
AND (lme.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
AND (EXTRACTVALUE(lme.xml_daten, '//Meldende_Stelle') NOT LIKE '%9999%' OR 1 <= :include_extern)
AND (EXTRACTVALUE(lme.xml_daten, '//ADT_GEKID/@Schema_Version') LIKE '2.%' OR 1 = :ignore_non_obds_2)
) o1
LEFT OUTER JOIN (
SELECT DISTINCT