mirror of
https://github.com/pcvolkmer/bzkf-rwdp-check.git
synced 2025-04-19 19:16:51 +00:00
feat: do not include external diagnoses by default
This commit is contained in:
parent
4cf671716f
commit
655995070c
@ -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.
|
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.
|
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
|
## Export aus der Onkostar-Datenbank
|
||||||
|
|
||||||
Die Anwendung ist in der Lage, mit dem Befehl `export` die Spalten
|
Die Anwendung ist in der Lage, mit dem Befehl `export` die Spalten
|
||||||
|
@ -61,6 +61,8 @@ pub enum SubCommand {
|
|||||||
year: String,
|
year: String,
|
||||||
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
|
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
|
||||||
ignore_exports_since: Option<String>,
|
ignore_exports_since: Option<String>,
|
||||||
|
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
|
||||||
|
include_extern: bool,
|
||||||
},
|
},
|
||||||
#[command(
|
#[command(
|
||||||
about = "Erstellt eine (reduzierte) CSV-Datei zum direkten Vergleich mit der OPAL-CSV-Datei"
|
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>,
|
ignore_exports_since: Option<String>,
|
||||||
#[arg(long, help = "Export mit Trennzeichen ';' für Excel")]
|
#[arg(long, help = "Export mit Trennzeichen ';' für Excel")]
|
||||||
xls_csv: bool,
|
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")]
|
#[command(about = "Abgleich zwischen CSV-Datei für OPAL und Onkostar-Datenbank")]
|
||||||
Compare {
|
Compare {
|
||||||
@ -125,6 +129,8 @@ pub enum SubCommand {
|
|||||||
year: String,
|
year: String,
|
||||||
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
|
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
|
||||||
ignore_exports_since: Option<String>,
|
ignore_exports_since: Option<String>,
|
||||||
|
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
|
||||||
|
include_extern: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,13 +34,18 @@ impl DatabaseSource {
|
|||||||
DatabaseSource(url)
|
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()) {
|
match Pool::new(self.0.as_str()) {
|
||||||
Ok(pool) => {
|
Ok(pool) => {
|
||||||
if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) {
|
if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) {
|
||||||
return match connection.exec_map(
|
return match connection.exec_map(
|
||||||
SQL_QUERY,
|
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 {
|
|(icd10_group, count)| Icd10GroupSize {
|
||||||
name: icd10_group,
|
name: icd10_group,
|
||||||
size: count,
|
size: count,
|
||||||
@ -64,13 +69,14 @@ impl DatabaseSource {
|
|||||||
year: &str,
|
year: &str,
|
||||||
ignore_exports_since: &str,
|
ignore_exports_since: &str,
|
||||||
use_pat_id: bool,
|
use_pat_id: bool,
|
||||||
|
include_extern: bool,
|
||||||
) -> Result<Vec<ExportData>, ()> {
|
) -> Result<Vec<ExportData>, ()> {
|
||||||
match Pool::new(self.0.as_str()) {
|
match Pool::new(self.0.as_str()) {
|
||||||
Ok(pool) => {
|
Ok(pool) => {
|
||||||
if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) {
|
if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) {
|
||||||
return match connection.exec_map(
|
return match connection.exec_map(
|
||||||
EXPORT_QUERY,
|
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, diagnosis_date, pat_id)| ExportData {
|
||||||
condition_id,
|
condition_id,
|
||||||
icd_10_code,
|
icd_10_code,
|
||||||
|
29
src/main.rs
29
src/main.rs
@ -87,6 +87,13 @@ fn print_items(items: &[Icd10GroupSize]) {
|
|||||||
let _ = term.write_line(&style("─".repeat(27)).dim().to_string());
|
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>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let term = Term::stdout();
|
let term = Term::stdout();
|
||||||
|
|
||||||
@ -105,6 +112,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
user,
|
user,
|
||||||
year,
|
year,
|
||||||
ignore_exports_since,
|
ignore_exports_since,
|
||||||
|
include_extern,
|
||||||
} => {
|
} => {
|
||||||
let password = request_password_if_none(password);
|
let password = request_password_if_none(password);
|
||||||
let year = sanitize_year(year);
|
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 db = DatabaseSource::new(&database, &host, &password, port, &user);
|
||||||
let items = db
|
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")?;
|
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
||||||
|
|
||||||
let _ = term.clear_last_lines(1);
|
let _ = term.clear_last_lines(1);
|
||||||
|
|
||||||
|
print_extern_notice(include_extern);
|
||||||
print_items(&items);
|
print_items(&items);
|
||||||
}
|
}
|
||||||
SubCommand::Export {
|
SubCommand::Export {
|
||||||
@ -134,7 +147,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
output,
|
output,
|
||||||
year,
|
year,
|
||||||
ignore_exports_since,
|
ignore_exports_since,
|
||||||
xls_csv
|
xls_csv,
|
||||||
|
include_extern,
|
||||||
} => {
|
} => {
|
||||||
let password = request_password_if_none(password);
|
let password = request_password_if_none(password);
|
||||||
let year = sanitize_year(year);
|
let year = sanitize_year(year);
|
||||||
@ -151,6 +165,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
&year,
|
&year,
|
||||||
&ignore_exports_since.unwrap_or("9999-12-31".into()),
|
&ignore_exports_since.unwrap_or("9999-12-31".into()),
|
||||||
pat_id,
|
pat_id,
|
||||||
|
include_extern,
|
||||||
)
|
)
|
||||||
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
||||||
|
|
||||||
@ -161,7 +176,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
if xls_csv {
|
if xls_csv {
|
||||||
writer_builder = writer_builder.delimiter(b';');
|
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
|
items
|
||||||
.iter()
|
.iter()
|
||||||
@ -177,6 +194,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
.green()
|
.green()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
print_extern_notice(include_extern);
|
||||||
}
|
}
|
||||||
SubCommand::Compare {
|
SubCommand::Compare {
|
||||||
pat_id,
|
pat_id,
|
||||||
@ -188,6 +207,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
file,
|
file,
|
||||||
year,
|
year,
|
||||||
ignore_exports_since,
|
ignore_exports_since,
|
||||||
|
include_extern,
|
||||||
} => {
|
} => {
|
||||||
let password = request_password_if_none(password);
|
let password = request_password_if_none(password);
|
||||||
let year = sanitize_year(year);
|
let year = sanitize_year(year);
|
||||||
@ -204,6 +224,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
&year,
|
&year,
|
||||||
&ignore_exports_since.unwrap_or("9999-12-31".into()),
|
&ignore_exports_since.unwrap_or("9999-12-31".into()),
|
||||||
pat_id,
|
pat_id,
|
||||||
|
include_extern,
|
||||||
)
|
)
|
||||||
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
||||||
|
|
||||||
@ -222,6 +243,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
print_extern_notice(include_extern);
|
||||||
|
|
||||||
let _ = term.write_line(
|
let _ = term.write_line(
|
||||||
&style(format!(
|
&style(format!(
|
||||||
"{} Conditions aus der Datenbank für das Jahr {} - aber nicht in Datei '{}'",
|
"{} Conditions aus der Datenbank für das Jahr {} - aber nicht in Datei '{}'",
|
||||||
|
@ -33,7 +33,7 @@ FROM (
|
|||||||
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1) AS diagnosedatum,
|
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(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
|
||||||
FROM lkr_meldung_export lme
|
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)
|
JOIN lkr_export le ON (le.id = lme.lkr_export)
|
||||||
WHERE lme.xml_daten LIKE '%ICD_Version%'
|
WHERE lme.xml_daten LIKE '%ICD_Version%'
|
||||||
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
||||||
|
@ -118,7 +118,7 @@ FROM (
|
|||||||
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Primaertumor_ICD_Code'), ' ', 1) AS condcodingcode,
|
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
|
SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
|
||||||
FROM lkr_meldung_export lme
|
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)
|
JOIN lkr_export le ON (le.id = lme.lkr_export)
|
||||||
WHERE lme.xml_daten LIKE '%ICD_Version%'
|
WHERE lme.xml_daten LIKE '%ICD_Version%'
|
||||||
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
||||||
|
Loading…
x
Reference in New Issue
Block a user