feat: enable messages with 'histologie_zytologie' using optional flag

This commit is contained in:
2024-05-22 16:09:45 +02:00
parent 02497cd007
commit af44351f09
6 changed files with 51 additions and 13 deletions

View File

@ -63,6 +63,11 @@ pub enum SubCommand {
ignore_exports_since: Option<String>,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
#[arg(
long,
help = "Meldungen mit Meldeanlass 'histologie_zytologie' einschließen"
)]
include_histo_zyto: bool,
},
#[command(
about = "Erstellt eine (reduzierte) CSV-Datei zum direkten Vergleich mit der OPAL-CSV-Datei"
@ -99,6 +104,11 @@ pub enum SubCommand {
xls_csv: bool,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
#[arg(
long,
help = "Meldungen mit Meldeanlass 'histologie_zytologie' einschließen"
)]
include_histo_zyto: bool,
},
#[command(about = "Abgleich zwischen CSV-Datei für OPAL und Onkostar-Datenbank")]
Compare {
@ -131,6 +141,11 @@ pub enum SubCommand {
ignore_exports_since: Option<String>,
#[arg(long, help = "Meldungen mit externer Diagnose einschließen")]
include_extern: bool,
#[arg(
long,
help = "Meldungen mit Meldeanlass 'histologie_zytologie' einschließen"
)]
include_histo_zyto: bool,
},
}

View File

@ -40,13 +40,19 @@ impl DatabaseSource {
year: &str,
ignore_exports_since: &str,
include_extern: bool,
include_histo_zyto: 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, "include_extern" => if include_extern { 1 } else { 0 } },
params! {
"year" => year,
"ignore_exports_since" => ignore_exports_since,
"include_extern" => if include_extern { 1 } else { 0 },
"include_histo_zyto" => if include_histo_zyto { 1 } else { 0 }
},
|(icd10_group, count)| Icd10GroupSize {
name: icd10_group,
size: count,
@ -71,13 +77,19 @@ impl DatabaseSource {
ignore_exports_since: &str,
use_pat_id: bool,
include_extern: bool,
include_histo_zyto: 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, "include_extern" => if include_extern { 1 } else { 0 } },
params! {
"year" => year,
"ignore_exports_since" => ignore_exports_since,
"include_extern" => if include_extern { 1 } else { 0 },
"include_histo_zyto" => if include_histo_zyto { 1 } else { 0 }
},
|(condition_id, icd_10_code, diagnosis_date, pat_id)| ExportData {
condition_id,
icd_10_code,

View File

@ -120,6 +120,7 @@ fn main() -> Result<(), Box<dyn Error>> {
year,
ignore_exports_since,
include_extern,
include_histo_zyto,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(year);
@ -136,6 +137,7 @@ fn main() -> Result<(), Box<dyn Error>> {
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
include_extern,
include_histo_zyto,
)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
@ -156,6 +158,7 @@ fn main() -> Result<(), Box<dyn Error>> {
ignore_exports_since,
xls_csv,
include_extern,
include_histo_zyto,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(year);
@ -173,6 +176,7 @@ fn main() -> Result<(), Box<dyn Error>> {
&ignore_exports_since.unwrap_or("9999-12-31".into()),
pat_id,
include_extern,
include_histo_zyto,
)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
@ -215,6 +219,7 @@ fn main() -> Result<(), Box<dyn Error>> {
year,
ignore_exports_since,
include_extern,
include_histo_zyto,
} => {
let password = request_password_if_none(password);
let year = sanitize_year(year);
@ -232,6 +237,7 @@ fn main() -> Result<(), Box<dyn Error>> {
&ignore_exports_since.unwrap_or("9999-12-31".into()),
pat_id,
include_extern,
include_histo_zyto,
)
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;

View File

@ -37,7 +37,7 @@ FROM (
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%')
AND (lm.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
) o1
LEFT OUTER JOIN (

View File

@ -122,7 +122,7 @@ FROM (
WHERE lme.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%')
AND (lm.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
) o1
LEFT OUTER JOIN (