From 180d808dd428e87e1e69495432ba41a802bab833 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 16 May 2024 17:32:59 +0200 Subject: [PATCH] fix: include older exported versions instead of skipping --- src/resources/export.sql | 7 +++---- src/resources/query.sql | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/resources/export.sql b/src/resources/export.sql index 6e0dce7..7481927 100644 --- a/src/resources/export.sql +++ b/src/resources/export.sql @@ -34,18 +34,17 @@ FROM ( 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' 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 AND (lme.xml_daten LIKE '%%' OR lme.xml_daten LIKE '%%') - AND le.exportiert_am < :ignore_exports_since ) o1 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, - 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 + JOIN lkr_export le ON (lme.lkr_export = le.id) WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year GROUP BY cond_id ORDER BY cond_id diff --git a/src/resources/query.sql b/src/resources/query.sql index e062b70..2b81985 100644 --- a/src/resources/query.sql +++ b/src/resources/query.sql @@ -119,18 +119,17 @@ FROM ( 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' 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 AND (lme.xml_daten LIKE '%%' OR lme.xml_daten LIKE '%%') - AND le.exportiert_am < :ignore_exports_since ) o1 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, - 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 + JOIN lkr_export le ON (lme.lkr_export = le.id) WHERE SUBSTRING_INDEX(SUBSTRING_INDEX(EXTRACTVALUE(lme.xml_daten, '//Diagnosedatum'), ' ', 1), '.', -1) = :year GROUP BY cond_id ORDER BY cond_id