mirror of
https://github.com/pcvolkmer/bzkf-rwdp-check.git
synced 2025-04-19 19:16:51 +00:00
Merge pull request #4 from pcvolkmer/issue_1
feat: show schema versions and change extern detection
This commit is contained in:
commit
7fc724db6a
@ -67,10 +67,14 @@ Dies eignet sich um nachträglich Zahlen zu einem bestimmten Datum zu ermitteln.
|
|||||||
|
|
||||||
Der optionale Parameter `--include-extern` schließt Meldungen mit externer Diagnosestellung ein.
|
Der optionale Parameter `--include-extern` schließt Meldungen mit externer Diagnosestellung ein.
|
||||||
Diese sind normalerweise nicht enthalten.
|
Diese sind normalerweise nicht enthalten.
|
||||||
|
Die Entscheidung, ob eine Meldung intern oder extern gemeldet wird, wird anhand der `Melder_ID` getroffen.
|
||||||
|
Enthält diese die Zeichenkette `9999` wird von einer externen Meldung ausgegangen.
|
||||||
|
|
||||||
Der optionale Parameter `--include-histo-zyto` schließt Meldungen mit Meldeanlass `histologhie_zytologie` ein.
|
Der optionale Parameter `--include-histo-zyto` schließt Meldungen mit Meldeanlass `histologhie_zytologie` ein.
|
||||||
Diese sind normalerweise ebenfalls nicht enthalten.
|
Diese sind normalerweise ebenfalls nicht enthalten.
|
||||||
|
|
||||||
|
Mit dem optionalen Parameter `--schema-versions` werden die Angaben zudem noch oBDS-Schema-Version getrennt ausgegeben.
|
||||||
|
|
||||||
## 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
|
||||||
|
@ -69,6 +69,8 @@ pub enum SubCommand {
|
|||||||
help = "Meldungen mit Meldeanlass 'histologie_zytologie' einschließen"
|
help = "Meldungen mit Meldeanlass 'histologie_zytologie' einschließen"
|
||||||
)]
|
)]
|
||||||
include_histo_zyto: bool,
|
include_histo_zyto: bool,
|
||||||
|
#[arg(long, help = "Meldungen mit oBDS-Schema-version anzeigen")]
|
||||||
|
schema_versions: 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"
|
||||||
|
@ -23,6 +23,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
pub struct Icd10GroupSize {
|
pub struct Icd10GroupSize {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub schema_version: Option<String>,
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +69,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,
|
||||||
|
schema_version: None,
|
||||||
size: record.1.len(),
|
size: record.1.len(),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
@ -24,7 +24,23 @@ use mysql::prelude::Queryable;
|
|||||||
use mysql::{params, Pool};
|
use mysql::{params, Pool};
|
||||||
|
|
||||||
use crate::common::{ExportData, Icd10GroupSize};
|
use crate::common::{ExportData, Icd10GroupSize};
|
||||||
use crate::resources::{EXPORTED_TO_LKR, EXPORT_QUERY, SQL_QUERY};
|
use crate::resources::{EXPORTED_TO_LKR, EXPORT_QUERY, SQL_QUERY, SQL_QUERY_WITH_SCHEMA_VERSION};
|
||||||
|
|
||||||
|
fn result_mapper() -> fn((String, String, usize)) -> Icd10GroupSize {
|
||||||
|
|(icd10_group, _, count)| Icd10GroupSize {
|
||||||
|
name: icd10_group,
|
||||||
|
schema_version: None,
|
||||||
|
size: count,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn result_mapper_with_schema_version() -> fn((String, String, usize)) -> Icd10GroupSize {
|
||||||
|
|(icd10_group, schema_version, count)| Icd10GroupSize {
|
||||||
|
name: icd10_group,
|
||||||
|
schema_version: Some(schema_version),
|
||||||
|
size: count,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct DatabaseSource(String);
|
pub struct DatabaseSource(String);
|
||||||
|
|
||||||
@ -41,25 +57,31 @@ impl DatabaseSource {
|
|||||||
ignore_exports_since: &str,
|
ignore_exports_since: &str,
|
||||||
include_extern: bool,
|
include_extern: bool,
|
||||||
include_histo_zyto: bool,
|
include_histo_zyto: bool,
|
||||||
|
schema_versions: bool,
|
||||||
) -> Result<Vec<Icd10GroupSize>, ()> {
|
) -> Result<Vec<Icd10GroupSize>, ()> {
|
||||||
match Pool::new(self.0.as_str()) {
|
let params = params! {
|
||||||
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,
|
"year" => year,
|
||||||
"ignore_exports_since" => ignore_exports_since,
|
"ignore_exports_since" => ignore_exports_since,
|
||||||
"include_extern" => if include_extern { 1 } else { 0 },
|
"include_extern" => if include_extern { 1 } else { 0 },
|
||||||
"include_histo_zyto" => if include_histo_zyto { 1 } else { 0 }
|
"include_histo_zyto" => if include_histo_zyto { 1 } else { 0 }
|
||||||
},
|
};
|
||||||
|(icd10_group, count)| Icd10GroupSize {
|
|
||||||
name: icd10_group,
|
match Pool::new(self.0.as_str()) {
|
||||||
size: count,
|
Ok(pool) => {
|
||||||
},
|
if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) {
|
||||||
|
return match schema_versions {
|
||||||
|
true => match connection.exec_map(
|
||||||
|
SQL_QUERY_WITH_SCHEMA_VERSION,
|
||||||
|
params,
|
||||||
|
result_mapper_with_schema_version(),
|
||||||
) {
|
) {
|
||||||
Ok(result) => Ok(result),
|
Ok(result) => Ok(result),
|
||||||
Err(_) => Err(()),
|
Err(_) => Err(()),
|
||||||
|
},
|
||||||
|
false => match connection.exec_map(SQL_QUERY, params, result_mapper()) {
|
||||||
|
Ok(result) => Ok(result),
|
||||||
|
Err(_) => Err(()),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/main.rs
20
src/main.rs
@ -67,26 +67,34 @@ fn print_items(items: &[Icd10GroupSize]) {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
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} ={:>6}",
|
||||||
|
item.name,
|
||||||
|
item.schema_version.as_ref().unwrap_or(&String::new()),
|
||||||
|
item.size
|
||||||
|
));
|
||||||
});
|
});
|
||||||
let sum: usize = items
|
let sum: usize = items
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|item| item.name != "Other")
|
.filter(|item| item.name != "Other")
|
||||||
.map(|item| item.size)
|
.map(|item| item.size)
|
||||||
.sum();
|
.sum();
|
||||||
let _ = term.write_line(&style("─".repeat(27)).dim().to_string());
|
let _ = term.write_line(&style("─".repeat(35)).dim().to_string());
|
||||||
let _ = term.write_line(
|
let _ = term.write_line(
|
||||||
&style(format!("{:<20}={:>6}", "Summe (C**.*/D**.*)", sum))
|
&style(format!(
|
||||||
|
"{:<20} {:<6} ={:>6}",
|
||||||
|
"Summe (C**.*/D**.*)", "", sum
|
||||||
|
))
|
||||||
.dim()
|
.dim()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
let sum: usize = items.iter().map(|item| item.size).sum();
|
let sum: usize = items.iter().map(|item| item.size).sum();
|
||||||
let _ = term.write_line(
|
let _ = term.write_line(
|
||||||
&style(format!("{:<20}={:>6}", "Gesamtsumme", sum))
|
&style(format!("{:<20} {:<6} ={:>6}", "Gesamtsumme", "", sum))
|
||||||
.dim()
|
.dim()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
let _ = term.write_line(&style("─".repeat(27)).dim().to_string());
|
let _ = term.write_line(&style("─".repeat(35)).dim().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_extern_notice(include_extern: bool) {
|
fn print_extern_notice(include_extern: bool) {
|
||||||
@ -123,6 +131,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
ignore_exports_since,
|
ignore_exports_since,
|
||||||
include_extern,
|
include_extern,
|
||||||
include_histo_zyto,
|
include_histo_zyto,
|
||||||
|
schema_versions,
|
||||||
} => {
|
} => {
|
||||||
let password = request_password_if_none(password);
|
let password = request_password_if_none(password);
|
||||||
let year = sanitize_year(year);
|
let year = sanitize_year(year);
|
||||||
@ -141,6 +150,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
&ignore_exports_since.unwrap_or("9999-12-31".into()),
|
&ignore_exports_since.unwrap_or("9999-12-31".into()),
|
||||||
include_extern,
|
include_extern,
|
||||||
include_histo_zyto,
|
include_histo_zyto,
|
||||||
|
schema_versions,
|
||||||
)
|
)
|
||||||
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
.map_err(|_e| "Fehler bei Zugriff auf die Datenbank")?;
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
pub const SQL_QUERY: &str = include_str!("query.sql");
|
pub const SQL_QUERY: &str = include_str!("query.sql");
|
||||||
|
|
||||||
|
pub const SQL_QUERY_WITH_SCHEMA_VERSION: &str = include_str!("query_with_schema_version.sql");
|
||||||
|
|
||||||
pub const EXPORT_QUERY: &str = include_str!("export.sql");
|
pub const EXPORT_QUERY: &str = include_str!("export.sql");
|
||||||
|
|
||||||
pub const EXPORTED_TO_LKR: &str = include_str!("exported-to-lkr.sql");
|
pub const EXPORTED_TO_LKR: &str = include_str!("exported-to-lkr.sql");
|
||||||
|
@ -107,34 +107,34 @@ SELECT CASE
|
|||||||
|
|
||||||
ELSE 'Other'
|
ELSE 'Other'
|
||||||
END AS ICD10_GROUP,
|
END AS ICD10_GROUP,
|
||||||
|
'' AS schema_version,
|
||||||
COUNT(*) as COUNT
|
COUNT(*) as COUNT
|
||||||
FROM (
|
FROM (
|
||||||
|
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
lme.lkr_meldung,
|
||||||
EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid,
|
EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid,
|
||||||
|
EXTRACTVALUE(lme.xml_daten, '//ADT_GEKID/@Schema_Version') AS schema_version,
|
||||||
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(lm.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(lm.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' 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(lm.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
AND lme.typ <> -1
|
||||||
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 SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
||||||
AND (lm.xml_daten NOT LIKE '%histologie_zytologie%' OR 1 = :include_histo_zyto)
|
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)
|
||||||
) o1
|
) o1
|
||||||
LEFT OUTER JOIN (
|
LEFT OUTER JOIN (
|
||||||
|
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
|
lme.lkr_meldung,
|
||||||
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,
|
||||||
CASE WHEN le.exportiert_am < :ignore_exports_since THEN MAX(versionsnummer) ELSE ~0 END AS max_version
|
CASE WHEN STR_TO_DATE(EXTRACTVALUE(lme.xml_daten, '//Meldedatum'), '%d.%c.%Y') < :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
|
||||||
|
) o2
|
||||||
) o2
|
|
||||||
ON (o1.cond_id = o2.cond_id AND o1.versionsnummer < max_version)
|
ON (o1.cond_id = o2.cond_id AND o1.versionsnummer < max_version)
|
||||||
WHERE diagnosejahr = :year AND o2.cond_id IS NULL
|
WHERE diagnosejahr = :year AND o2.cond_id IS NULL
|
||||||
GROUP BY ICD10_GROUP;
|
GROUP BY ICD10_GROUP;
|
140
src/resources/query_with_schema_version.sql
Normal file
140
src/resources/query_with_schema_version.sql
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of bzkf-rwdp-check
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
SELECT CASE
|
||||||
|
WHEN condcodingcode LIKE 'C00%'
|
||||||
|
OR condcodingcode LIKE 'C01%'
|
||||||
|
OR condcodingcode LIKE 'C02%'
|
||||||
|
OR condcodingcode LIKE 'C03%'
|
||||||
|
OR condcodingcode LIKE 'C04%'
|
||||||
|
OR condcodingcode LIKE 'C05%'
|
||||||
|
OR condcodingcode LIKE 'C06%'
|
||||||
|
OR condcodingcode LIKE 'C07%'
|
||||||
|
OR condcodingcode LIKE 'C08%'
|
||||||
|
OR condcodingcode LIKE 'C09%'
|
||||||
|
OR condcodingcode LIKE 'C10%'
|
||||||
|
OR condcodingcode LIKE 'C11%'
|
||||||
|
OR condcodingcode LIKE 'C12%'
|
||||||
|
OR condcodingcode LIKE 'C13%'
|
||||||
|
OR condcodingcode LIKE 'C14%' THEN 'C00-C14'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C15%' THEN 'C15'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C16%' THEN 'C16'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C18%'
|
||||||
|
OR condcodingcode LIKE 'C19%'
|
||||||
|
OR condcodingcode LIKE 'C20%'
|
||||||
|
OR condcodingcode LIKE 'C21%' THEN 'C18-C21'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C22%' THEN 'C22'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C23%'
|
||||||
|
OR condcodingcode LIKE 'C24%' THEN 'C23-C24'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C25%' THEN 'C25'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C32%' THEN 'C32'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C33%'
|
||||||
|
OR condcodingcode LIKE 'C34%' THEN 'C33-C34'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C43%' THEN 'C43'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C50%'
|
||||||
|
OR condcodingcode LIKE 'D05%' THEN 'C50, D05'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C53%'
|
||||||
|
OR condcodingcode LIKE 'D06%' THEN 'C53, D06'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C54%'
|
||||||
|
OR condcodingcode LIKE 'C55%' THEN 'C54-C55'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C56%'
|
||||||
|
OR condcodingcode = 'D39.1' THEN 'C56, D39.1'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C61%' THEN 'C61'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C62%' THEN 'C62'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C64%' THEN 'C64'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C67%'
|
||||||
|
OR condcodingcode = 'D09.0'
|
||||||
|
OR condcodingcode = 'D41.4' THEN 'C67, D09.0, D41.4'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C70%'
|
||||||
|
OR condcodingcode LIKE 'C71%'
|
||||||
|
OR condcodingcode LIKE 'C72%' THEN 'C70-C72'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C73%' THEN 'C73'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C81%' THEN 'C81'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C82%'
|
||||||
|
OR condcodingcode LIKE 'C83%'
|
||||||
|
OR condcodingcode LIKE 'C84%'
|
||||||
|
OR condcodingcode LIKE 'C85%'
|
||||||
|
OR condcodingcode LIKE 'C86%'
|
||||||
|
OR condcodingcode LIKE 'C87%'
|
||||||
|
OR condcodingcode LIKE 'C88%'
|
||||||
|
OR condcodingcode LIKE 'C96%' THEN 'C82-C88, C96'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C90%' THEN 'C90'
|
||||||
|
|
||||||
|
WHEN condcodingcode LIKE 'C91%'
|
||||||
|
OR condcodingcode LIKE 'C92%'
|
||||||
|
OR condcodingcode LIKE 'C93%'
|
||||||
|
OR condcodingcode LIKE 'C94%'
|
||||||
|
OR condcodingcode LIKE 'C95%' THEN 'C91-C95'
|
||||||
|
|
||||||
|
ELSE 'Other'
|
||||||
|
END AS ICD10_GROUP,
|
||||||
|
schema_version,
|
||||||
|
COUNT(*) as COUNT
|
||||||
|
FROM (
|
||||||
|
SELECT DISTINCT
|
||||||
|
lme.lkr_meldung,
|
||||||
|
EXTRACTVALUE(lme.xml_daten, '//Patienten_Stammdaten/@Patient_ID') AS pid,
|
||||||
|
EXTRACTVALUE(lme.xml_daten, '//ADT_GEKID/@Schema_Version') AS schema_version,
|
||||||
|
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(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) AS diagnosejahr
|
||||||
|
FROM lkr_meldung_export lme
|
||||||
|
WHERE lme.xml_daten LIKE '%ICD_Version%'
|
||||||
|
AND lme.typ <> -1
|
||||||
|
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)
|
||||||
|
) o1
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT DISTINCT
|
||||||
|
lme.lkr_meldung,
|
||||||
|
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,
|
||||||
|
CASE WHEN STR_TO_DATE(EXTRACTVALUE(lme.xml_daten, '//Meldedatum'), '%d.%c.%Y') < :ignore_exports_since THEN MAX(versionsnummer) ELSE ~0 END AS max_version
|
||||||
|
FROM lkr_meldung_export lme
|
||||||
|
WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year
|
||||||
|
GROUP BY cond_id ORDER BY cond_id
|
||||||
|
) o2
|
||||||
|
ON (o1.cond_id = o2.cond_id AND o1.versionsnummer < max_version)
|
||||||
|
WHERE diagnosejahr = :year AND o2.cond_id IS NULL
|
||||||
|
GROUP BY ICD10_GROUP, schema_version;
|
Loading…
x
Reference in New Issue
Block a user