21 Commits

Author SHA1 Message Date
9d7e511725 chore: bump version 2024-05-22 10:27:35 +02:00
e4c3e61f35 chore: update dependencies 2024-05-22 10:26:56 +02:00
38f9fe3628 chore: code cleanup 2024-05-22 10:26:35 +02:00
ab15e5c9ff feat: ignore messages containing 'histologie_zytologie' 2024-05-21 16:11:54 +02:00
8ec24efc96 chore: bump version 2024-05-16 17:33:28 +02:00
180d808dd4 fix: include older exported versions instead of skipping 2024-05-16 17:32:59 +02:00
ba97610fbe chore: bump version 2024-05-16 12:41:59 +02:00
655995070c feat: do not include external diagnoses by default 2024-05-16 12:33:53 +02:00
4cf671716f docs: add information about csv export option 2024-04-04 08:10:07 +02:00
3684ff8172 feat: add export with semicolon as separator 2024-04-03 19:47:30 +02:00
c4c2297bb0 docs: add information about supported databases. 2024-04-03 14:37:41 +02:00
9a87aa5e97 chore: update dependencies 2024-03-27 14:46:11 +01:00
5a59deb75d feat: limit connection timeout 2024-03-13 17:58:17 +01:00
f3c08a972b feat: ignore items after optional export date param 2024-03-13 17:57:37 +01:00
2ee397d4b4 feat: print out sum 2024-03-12 15:24:46 +01:00
299b4bcc39 build: update clap dependency and add authors/description/repository 2024-03-07 17:43:31 +01:00
88cd49db47 refactor: extract methods 2024-02-29 07:31:57 +01:00
f8037caaf9 refactor: use len() instead of iter().count() 2024-02-29 07:06:35 +01:00
716b666153 refactor: use filter_map() 2024-02-28 17:14:04 +01:00
5a162bc502 refactor: use matches!() macro 2024-02-28 17:13:32 +01:00
2297e20cba build: new dev version 2024-02-28 17:10:07 +01:00
9 changed files with 185 additions and 92 deletions

View File

@ -1,19 +1,21 @@
[package] [package]
name = "bzkf-rwdp-check" name = "bzkf-rwdp-check"
version = "0.1.0" version = "0.3.2"
edition = "2021" edition = "2021"
authors = ["Paul-Christian Volkmer <volkmer_p@ukw.de>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html description = "Anwendung zur Durchführung einer Plausibilitätsprüfung anhand der Daten für die BZKF Real World Data Platform."
repository = "https://github.com/CCC-MF/bzkf-rwdp-check"
[dependencies] [dependencies]
clap = { version = "4.4", features = ["std", "help", "usage", "derive", "error-context"], default-features = false } clap = { version = "4.5", features = ["std", "help", "usage", "derive", "error-context"], default-features = false }
console = "0.15" console = "0.15"
csv = "1.3" csv = "1.3"
dialoguer = "0.11" dialoguer = "0.11"
itertools = "0.12" itertools = "0.13"
mysql = "24.0" mysql = "25.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
urlencoding = "2.1" urlencoding = "2.1"
regex = "1.10"
[profile.release] [profile.release]
opt-level = "s" opt-level = "s"

View File

@ -22,6 +22,8 @@ flowchart LR
Die Anwendung gibt für die möglichen Quellen der Kennzahlen die Anzahl der _Conditions_, gruppiert nach ICD-10 Gruppen, Die Anwendung gibt für die möglichen Quellen der Kennzahlen die Anzahl der _Conditions_, gruppiert nach ICD-10 Gruppen,
aus. aus.
Unterstützt wird eien OPAL-CSV-Datei (wie für BZKF vorgesehen) und eine Onkostar-Datenbank, basierend auf MariaDB oder MySQL.
![Ausgabe](docs/screenshot.png) ![Ausgabe](docs/screenshot.png)
## Kennzahlen aus der CSV-Datei ## Kennzahlen aus der CSV-Datei
@ -58,6 +60,13 @@ Options:
-y, --year <YEAR> Jahr der Diagnose -y, --year <YEAR> Jahr der Diagnose
``` ```
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 ## 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
@ -76,6 +85,7 @@ zusätzlich gibt es noch die folgenden Parameter:
Options: Options:
--pat-id Export mit Klartext-Patienten-ID --pat-id Export mit Klartext-Patienten-ID
-o, --output <OUTPUT> Ausgabedatei -o, --output <OUTPUT> Ausgabedatei
--xls-csv Export mit Trennzeichen ';' für Excel
``` ```
## Vergleich CSV-Datei für OPAL und Onkostar-Datenbank ## Vergleich CSV-Datei für OPAL und Onkostar-Datenbank

View File

@ -19,6 +19,7 @@
*/ */
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use regex::Regex;
#[derive(Parser)] #[derive(Parser)]
#[command(author, version, about)] #[command(author, version, about)]
@ -58,6 +59,10 @@ pub enum SubCommand {
user: String, user: String,
#[arg(short = 'y', long, help = "Jahr der Diagnose")] #[arg(short = 'y', long, help = "Jahr der Diagnose")]
year: String, 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( #[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"
@ -88,6 +93,12 @@ pub enum SubCommand {
output: String, output: String,
#[arg(short = 'y', long, help = "Jahr der Diagnose")] #[arg(short = 'y', long, help = "Jahr der Diagnose")]
year: String, year: String,
#[arg(long, value_parser = value_is_date, help = "Ignoriere LKR-Exporte seit Datum")]
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")] #[command(about = "Abgleich zwischen CSV-Datei für OPAL und Onkostar-Datenbank")]
Compare { Compare {
@ -116,5 +127,21 @@ pub enum SubCommand {
file: String, file: String,
#[arg(short = 'y', long, help = "Jahr der Diagnose")] #[arg(short = 'y', long, help = "Jahr der Diagnose")]
year: String, 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,
}, },
} }
fn value_is_date(value: &str) -> Result<String, String> {
let re = Regex::new(r"^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$").unwrap();
if re.is_match(value) {
Ok(value.into())
} else {
Err(format!(
"Ungültiges Datum '{}', bitte im Format 'yyyy-mm-dd' angeben",
value
))
}
}

View File

@ -68,7 +68,7 @@ impl Check {
.map(|(icd10, group)| (icd10, group.collect::<Vec<_>>())) .map(|(icd10, group)| (icd10, group.collect::<Vec<_>>()))
.map(|record| Icd10GroupSize { .map(|record| Icd10GroupSize {
name: record.0, name: record.0,
size: record.1.iter().count(), size: record.1.len(),
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -76,10 +76,7 @@ impl Check {
} }
pub fn is_relevant(code: &str) -> bool { pub fn is_relevant(code: &str) -> bool {
match Self::map_icd_code(code).as_str() { !matches!(Self::map_icd_code(code).as_str(), "Other")
"Other" => false,
_ => true,
}
} }
fn map_icd_code(code: &str) -> String { fn map_icd_code(code: &str) -> String {

View File

@ -18,6 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
use std::time::Duration;
use mysql::prelude::Queryable; use mysql::prelude::Queryable;
use mysql::{params, Pool}; use mysql::{params, Pool};
@ -33,13 +35,18 @@ impl DatabaseSource {
DatabaseSource(url) DatabaseSource(url)
} }
pub fn check(&self, year: &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.get_conn() { 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}, 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,
@ -58,13 +65,19 @@ impl DatabaseSource {
Err(()) Err(())
} }
pub fn export(&self, year: &str, use_pat_id: bool) -> Result<Vec<ExportData>, ()> { pub fn export(
&self,
year: &str,
ignore_exports_since: &str,
use_pat_id: bool,
include_extern: bool,
) -> 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.get_conn() { 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}, 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,

View File

@ -23,7 +23,7 @@ use std::path::Path;
use clap::Parser; use clap::Parser;
use console::{style, Term}; use console::{style, Term};
use csv::Writer; use csv::WriterBuilder;
use itertools::Itertools; use itertools::Itertools;
use crate::cli::{Cli, SubCommand}; use crate::cli::{Cli, SubCommand};
@ -36,6 +36,27 @@ mod database;
mod opal; mod opal;
mod resources; mod resources;
fn request_password_if_none(password: Option<String>) -> String {
if let Some(password) = password {
password
} else {
let password = dialoguer::Password::new()
.with_prompt("Password")
.interact()
.unwrap_or_default();
let _ = Term::stdout().clear_last_lines(1);
password
}
}
fn sanitize_year(year: String) -> String {
if year.len() == 4 {
year
} else {
format!("2{:0>3}", year)
}
}
fn print_items(items: &[Icd10GroupSize]) { fn print_items(items: &[Icd10GroupSize]) {
let term = Term::stdout(); let term = Term::stdout();
let _ = term.write_line( let _ = term.write_line(
@ -46,6 +67,38 @@ fn print_items(items: &[Icd10GroupSize]) {
items.iter().for_each(|item| { items.iter().for_each(|item| {
let _ = term.write_line(&format!("{:<20}={:>6}", item.name, item.size)); let _ = term.write_line(&format!("{:<20}={:>6}", item.name, item.size));
}); });
let sum: usize = items
.iter()
.filter(|item| item.name != "Other")
.map(|item| item.size)
.sum();
let _ = term.write_line(&style("".repeat(27)).dim().to_string());
let _ = term.write_line(
&style(format!("{:<20}={:>6}", "Summe (C**.*/D**.*)", sum))
.dim()
.to_string(),
);
let sum: usize = items.iter().map(|item| item.size).sum();
let _ = term.write_line(
&style(format!("{:<20}={:>6}", "Gesamtsumme", sum))
.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>> {
@ -65,23 +118,11 @@ fn main() -> Result<(), Box<dyn Error>> {
port, port,
user, user,
year, year,
ignore_exports_since,
include_extern,
} => { } => {
let password = if let Some(password) = password { let password = request_password_if_none(password);
password let year = sanitize_year(year);
} else {
let password = dialoguer::Password::new()
.with_prompt("Password")
.interact()
.unwrap_or_default();
let _ = term.clear_last_lines(1);
password
};
let year = if year.len() == 4 {
year
} else {
format!("2{:0>3}", year)
};
let _ = term.write_line( let _ = term.write_line(
&style(format!("Warte auf Daten für das Diagnosejahr {}...", year)) &style(format!("Warte auf Daten für das Diagnosejahr {}...", year))
@ -91,11 +132,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) .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 {
@ -107,23 +153,12 @@ fn main() -> Result<(), Box<dyn Error>> {
user, user,
output, output,
year, year,
ignore_exports_since,
xls_csv,
include_extern,
} => { } => {
let password = if let Some(password) = password { let password = request_password_if_none(password);
password let year = sanitize_year(year);
} else {
let password = dialoguer::Password::new()
.with_prompt("Password")
.interact()
.unwrap_or_default();
let _ = term.clear_last_lines(1);
password
};
let year = if year.len() == 4 {
year
} else {
format!("2{:0>3}", year)
};
let _ = term.write_line( let _ = term.write_line(
&style(format!("Warte auf Daten für das Diagnosejahr {}...", year)) &style(format!("Warte auf Daten für das Diagnosejahr {}...", year))
@ -133,12 +168,24 @@ 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
.export(&year, pat_id) .export(
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
pat_id,
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);
let mut writer = Writer::from_path(Path::new(&output)).expect("writeable file"); let writer_builder = &mut WriterBuilder::new();
let mut writer_builder = writer_builder.has_headers(true);
if xls_csv {
writer_builder = writer_builder.delimiter(b';');
}
let mut writer = writer_builder
.from_path(Path::new(&output))
.expect("writeable file");
items items
.iter() .iter()
@ -154,6 +201,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,
@ -164,23 +213,11 @@ fn main() -> Result<(), Box<dyn Error>> {
user, user,
file, file,
year, year,
ignore_exports_since,
include_extern,
} => { } => {
let password = if let Some(password) = password { let password = request_password_if_none(password);
password let year = sanitize_year(year);
} else {
let password = dialoguer::Password::new()
.with_prompt("Password")
.interact()
.unwrap_or_default();
let _ = term.clear_last_lines(1);
password
};
let year = if year.len() == 4 {
year
} else {
format!("2{:0>3}", year)
};
let _ = term.write_line( let _ = term.write_line(
&style(format!("Warte auf Daten für das Diagnosejahr {}...", year)) &style(format!("Warte auf Daten für das Diagnosejahr {}...", year))
@ -190,7 +227,12 @@ 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 db_items = db let db_items = db
.export(&year, pat_id) .export(
&year,
&ignore_exports_since.unwrap_or("9999-12-31".into()),
pat_id,
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);
@ -208,6 +250,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 '{}'",

View File

@ -41,8 +41,7 @@ impl OpalCsvFile {
let items = reader let items = reader
.deserialize::<OpalRecord>() .deserialize::<OpalRecord>()
.filter(|record| record.is_ok()) .filter_map(|record| record.ok())
.map(|record| record.unwrap())
.map(|record| Record { .map(|record| Record {
condition_id: record.cond_id, condition_id: record.cond_id,
icd10_code: record.cond_coding_code, icd10_code: record.cond_coding_code,
@ -57,8 +56,7 @@ impl OpalCsvFile {
let items = reader let items = reader
.deserialize::<ExportData>() .deserialize::<ExportData>()
.filter(|record| record.is_ok()) .filter_map(|record| record.ok())
.map(|record| record.unwrap())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
Ok(items) Ok(items)

View File

@ -29,22 +29,23 @@ FROM (
EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid, EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid,
lme.versionsnummer, 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, 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(lm.xml_daten, '//Primaertumor_ICD_Code'), ' ', 1) AS condcodingcode,
SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1) AS diagnosedatum, SUBSTRING_INDEX(EXTRACTVALUE(lm.xml_daten, '//Diagnosedatum'), ' ', 1) AS diagnosedatum,
SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lm.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)
WHERE lme.xml_daten LIKE '%ICD_Version%' WHERE lm.xml_daten LIKE '%ICD_Version%'
AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year AND SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lm.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 (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%')
) o1 ) o1
LEFT OUTER JOIN ( LEFT OUTER JOIN (
SELECT SELECT DISTINCT
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, 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,
MAX(versionsnummer) AS max_version CASE WHEN le.exportiert_am < :ignore_exports_since THEN MAX(versionsnummer) ELSE ~0 END AS max_version
FROM lkr_meldung_export lme FROM lkr_meldung_export lme
JOIN lkr_export le ON (lme.lkr_export = le.id)
WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
GROUP BY cond_id ORDER BY cond_id GROUP BY cond_id ORDER BY cond_id

View File

@ -115,21 +115,22 @@ FROM (
EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid, EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid,
lme.versionsnummer, 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, 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(lm.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(lm.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)
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(lm.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 (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%')
) o1 ) o1
LEFT OUTER JOIN ( LEFT OUTER JOIN (
SELECT SELECT DISTINCT
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, 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,
MAX(versionsnummer) AS max_version CASE WHEN le.exportiert_am < :ignore_exports_since THEN MAX(versionsnummer) ELSE ~0 END AS max_version
FROM lkr_meldung_export lme FROM lkr_meldung_export lme
JOIN lkr_export le ON (lme.lkr_export = le.id)
WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
GROUP BY cond_id ORDER BY cond_id GROUP BY cond_id ORDER BY cond_id