feat: do not include external diagnoses by default

This commit is contained in:
Paul-Christian Volkmer 2024-05-16 12:33:53 +02:00
parent 4cf671716f
commit 655995070c
6 changed files with 46 additions and 8 deletions

View File

@ -64,6 +64,9 @@ Der zusätzliche Parameter `--ignore-exports-since` ist optional.
Wird er angegeben, werden keine Einträge mit Exportdatum ab diesem Datum verwendet.
Dies eignet sich um nachträglich Zahlen zu einem bestimmten Datum zu ermitteln.
Der Parameter `--include-extern` schließt Meldungen mit externer Diagnosestellung ein.
Diese sind normalerweise nicht enthalten.
## Export aus der Onkostar-Datenbank
Die Anwendung ist in der Lage, mit dem Befehl `export` die Spalten

View File

@ -61,6 +61,8 @@ 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 = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
},
#[command(
about = "Erstellt eine (reduzierte) CSV-Datei zum direkten Vergleich mit der OPAL-CSV-Datei"
@ -95,6 +97,8 @@ pub enum SubCommand {
ignore_exports_since: Option<String>,
#[arg(long, help = "Export mit Trennzeichen ';' für Excel")]
xls_csv: bool,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
},
#[command(about = "Abgleich zwischen CSV-Datei für OPAL und Onkostar-Datenbank")]
Compare {
@ -125,6 +129,8 @@ 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 = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
},
}

View File

@ -34,13 +34,18 @@ impl DatabaseSource {
DatabaseSource(url)
}
pub fn check(&self, year: &str, ignore_exports_since: &str) -> Result<Vec<Icd10GroupSize>, ()> {
pub fn check(
&self,
year: &str,
ignore_exports_since: &str,
include_extern: bool,
) -> Result<Vec<Icd10GroupSize>, ()> {
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(
SQL_QUERY,
params! {"year" => year, "ignore_exports_since" => ignore_exports_since},
params! {"year" => year, "ignore_exports_since" => ignore_exports_since, "include_extern" => if include_extern { 1 } else { 0 } },
|(icd10_group, count)| Icd10GroupSize {
name: icd10_group,
size: count,
@ -64,13 +69,14 @@ impl DatabaseSource {
year: &str,
ignore_exports_since: &str,
use_pat_id: bool,
include_extern: bool,
) -> Result<Vec<ExportData>, ()> {
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(
EXPORT_QUERY,
params! {"year" => year, "ignore_exports_since" => ignore_exports_since},
params! {"year" => year, "ignore_exports_since" => ignore_exports_since, "include_extern" => if include_extern { 1 } else { 0 } },
|(condition_id, icd_10_code, diagnosis_date, pat_id)| ExportData {
condition_id,
icd_10_code,

View File

@ -87,6 +87,13 @@ fn print_items(items: &[Icd10GroupSize]) {
let _ = term.write_line(&style("".repeat(27)).dim().to_string());
}
fn print_extern_notice(include_extern: bool) {
let _ = Term::stdout().write_line(format!("{} Die Datenbankanfrage schließt Meldungen mit externer Diagnose {}.", style("Hinweis:").bold().underlined(), match include_extern {
true => style("ein").yellow(),
false => style("nicht ein (Standard)").green()
}).as_str());
}
fn main() -> Result<(), Box<dyn Error>> {
let term = Term::stdout();
@ -105,6 +112,7 @@ fn main() -> Result<(), Box<dyn Error>> {
user,
year,
ignore_exports_since,
include_extern,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(year);
@ -117,11 +125,16 @@ fn main() -> Result<(), Box<dyn Error>> {
let db = DatabaseSource::new(&database, &host, &password, port, &user);
let items = db
.check(&year, &ignore_exports_since.unwrap_or("9999-12-31".into()))
.check(
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
include_extern,
)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
let _ = term.clear_last_lines(1);
print_extern_notice(include_extern);
print_items(&items);
}
SubCommand::Export {
@ -134,7 +147,8 @@ fn main() -> Result<(), Box<dyn Error>> {
output,
year,
ignore_exports_since,
xls_csv
xls_csv,
include_extern,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(year);
@ -151,6 +165,7 @@ fn main() -> Result<(), Box<dyn Error>> {
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
pat_id,
include_extern,
)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
@ -161,7 +176,9 @@ fn main() -> Result<(), Box<dyn Error>> {
if xls_csv {
writer_builder = writer_builder.delimiter(b';');
}
let mut writer = writer_builder.from_path(Path::new(&output)).expect("writeable file");
let mut writer = writer_builder
.from_path(Path::new(&output))
.expect("writeable file");
items
.iter()
@ -177,6 +194,8 @@ fn main() -> Result<(), Box<dyn Error>> {
.green()
.to_string(),
);
print_extern_notice(include_extern);
}
SubCommand::Compare {
pat_id,
@ -188,6 +207,7 @@ fn main() -> Result<(), Box<dyn Error>> {
file,
year,
ignore_exports_since,
include_extern,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(year);
@ -204,6 +224,7 @@ fn main() -> Result<(), Box<dyn Error>> {
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
pat_id,
include_extern,
)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
@ -222,6 +243,8 @@ fn main() -> Result<(), Box<dyn Error>> {
})
.collect::<Vec<_>>();
print_extern_notice(include_extern);
let _ = term.write_line(
&style(format!(
"{} Conditions aus der Datenbank für das Jahr {} - aber nicht in Datei '{}'",

View File

@ -33,7 +33,7 @@ FROM (
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1) AS diagnosedatum,
SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
FROM lkr_meldung_export lme
JOIN lkr_meldung lm ON (lm.id = lme.lkr_meldung AND lme.typ <> '-1')
JOIN lkr_meldung lm ON (lm.id = lme.lkr_meldung AND lme.typ <> '-1' AND lm.extern <= :include_extern)
JOIN lkr_export le ON (le.id = lme.lkr_export)
WHERE lme.xml_daten LIKE '%ICD_Version%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year

View File

@ -118,7 +118,7 @@ FROM (
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Primaertumor_ICD_Code'), ' ', 1) AS condcodingcode,
SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
FROM lkr_meldung_export lme
JOIN lkr_meldung lm ON (lm.id = lme.lkr_meldung AND lme.typ <> '-1')
JOIN lkr_meldung lm ON (lm.id = lme.lkr_meldung AND lme.typ <> '-1' AND lm.extern <= :include_extern)
JOIN lkr_export le ON (le.id = lme.lkr_export)
WHERE lme.xml_daten LIKE '%ICD_Version%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year