Skip to content

Commit

Permalink
Feature/optional sample id linkage (#57)
Browse files Browse the repository at this point in the history
* feature: add pseudonym id option

* refactor: make ID parameters properties not env

* fix: make MAINZELLISTE_EXTERNAL_ID default true - backward compatibility

---------

Co-authored-by: Pierre Delpy <[email protected]>
  • Loading branch information
PierreDelpy and Pierre Delpy authored Dec 12, 2024
1 parent a729766 commit 3351fd8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ ENV FILE_PATH="/obds2fhir/clinical_data" \
LOG_LEVEL="INFO" \
MAINZELLISTE_URL="http://host.docker.internal:8080" \
MAINZELLISTE_APIKEY="" \
MAINZELLISTE_EXTERNAL_ID="true" \
IDTYPE="" \
SALT="createLocalCustomSalt" \
SSL_CERTIFICATE_VALIDATION="true" \
ADD_DEPARTMENTS="false" \
WAIT_FOR_CONNECTION="false" \
KEEP_INTERNAL_ID="false"
KEEP_INTERNAL_ID="false" \
USE_PSEUDONYM="false"
6 changes: 4 additions & 2 deletions src/main/java/de/samply/obds2fhir/Obds2fhir.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,12 @@ public static void initializeTransformers(boolean pseudonymizeFlag) {
ADT2SinglePatientTransformer.setParameter("filepath", System.getenv().getOrDefault("FILE_PATH",""));
oBDS2MDSTransformer = factory.newTransformer(new StreamSource(Obds2fhir.class.getClassLoader().getResourceAsStream("oBDS2MDS_FHIR.xsl")));
oBDS2MDSTransformer.setParameter("add_department", System.getenv().getOrDefault("ADD_DEPARTMENTS","false"));
oBDS2MDSTransformer.setParameter("keep_internal_id", System.getenv().getOrDefault("KEEP_INTERNAL_ID","false"));
oBDS2MDSTransformer.setParameter("keep_internal_id", System.getProperty("KEEP_INTERNAL_ID", "false"));
oBDS2MDSTransformer.setParameter("use_pseudonym", System.getProperty("USE_PSEUDONYM", "false"));
ADT2MDSTransformer = factory.newTransformer(new StreamSource(Obds2fhir.class.getClassLoader().getResourceAsStream("ADT2MDS_FHIR.xsl")));
ADT2MDSTransformer.setParameter("add_department", System.getenv().getOrDefault("ADD_DEPARTMENTS","false"));
ADT2MDSTransformer.setParameter("keep_internal_id", System.getenv().getOrDefault("KEEP_INTERNAL_ID","false"));
ADT2MDSTransformer.setParameter("keep_internal_id", System.getProperty("KEEP_INTERNAL_ID", "false"));
ADT2MDSTransformer.setParameter("use_pseudonym", System.getProperty("USE_PSEUDONYM", "false"));
MDS2FHIRTransformer = factory.newTransformer(new StreamSource(Obds2fhir.class.getClassLoader().getResourceAsStream("MDS2FHIR.xsl")));
MDS2FHIRTransformer.setParameter("filepath", System.getenv().getOrDefault("FILE_PATH",""));
MDS2FHIRTransformer.setParameter("identifier_system", System.getenv().getOrDefault("IDENTIFIER_SYSTEM","http://dktk.dkfz.de/fhir/onco/core/CodeSystem/PseudonymArtCS"));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/de/samply/obds2fhir/PatientPseudonymizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ private HttpPost createHttpPost (String prename, String surname, String formerna
if (!birthmonth.equals("empty")) idat.add(new BasicNameValuePair("Geburtsmonat", birthmonth));
if (!birthyear.equals("empty")) idat.add(new BasicNameValuePair("Geburtsjahr", birthyear));
if (!gender.equals("empty")) idat.add(new BasicNameValuePair("Geschlecht", gender));
if (!identifier.equals("empty")) idat.add(new BasicNameValuePair("locallyUniqueId", identifier));
if (!identifier.equals("empty") && Boolean.parseBoolean(System.getProperty("MAINZELLISTE_EXTERNAL_ID", "true"))) {
idat.add(new BasicNameValuePair("locallyUniqueId", identifier));
}
idat.add(new BasicNameValuePair("sureness", "true"));
logger.debug("Posting IDAT to Mainzelliste: " +
"Vorname - " + preprocessIDAT(prename, ".", "*") +
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/ADT2MDS_FHIR.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<xsl:strip-space elements="*"/>
<xsl:param name="add_department" />
<xsl:param name="keep_internal_id" />
<xsl:param name="use_pseudonym" />

<xsl:template match="/ADT_GEKID/Menge_Patient">
<Patienten>
Expand All @@ -24,7 +25,6 @@
<xsl:choose>
<xsl:when test="Patienten_Stammdaten/@Patient_ID!=''">
<Patient>
<xsl:variable name="Patient_Id" select="if ($keep_internal_id=true()) then Patienten_Stammdaten/@Patient_ID else hash:hash(Patienten_Stammdaten/@Patient_ID,'','')"/>
<xsl:variable name="Geburtsdatum" select="Patienten_Stammdaten/xsi:Get-FHIR-date(Patienten_Geburtsdatum)"/>
<xsl:variable name="Geburtstag" select="string(replace($Geburtsdatum,'^\d{4}-\d{2}-(\d{2})$','$1'))"/>
<xsl:variable name="Geburtsmonat" select="string(replace($Geburtsdatum,'^\d{4}-(\d{2})-\d{2}$','$1'))"/>
Expand All @@ -38,6 +38,11 @@
xsi:ReplaceEmpty($Geburtsmonat),
xsi:ReplaceEmpty($Geburtsjahr),
xsi:ReplaceEmpty(Patienten_Stammdaten/@Patient_ID))"/>
<xsl:variable name="Patient_Id" select="
if ($use_pseudonym = true())
then (if ($keep_internal_id = true()) then $Patient_Pseudonym else hash:hash($Patient_Pseudonym, '', ''))
else (if ($keep_internal_id = true()) then Patienten_Stammdaten/@Patient_ID else hash:hash(Patienten_Stammdaten/@Patient_ID, '', ''))
" />
<xsl:attribute name="Patient_ID" select="$Patient_Id"/>
<Geschlecht>
<xsl:value-of select="if (Patienten_Stammdaten/Patienten_Geschlecht = 'D') then 'S' else Patienten_Stammdaten/Patienten_Geschlecht" />
Expand Down
50 changes: 28 additions & 22 deletions src/main/resources/oBDS2MDS_FHIR.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,47 @@
<xsl:strip-space elements="*"/>
<xsl:param name="add_department" />
<xsl:param name="keep_internal_id" />
<xsl:param name="use_pseudonym" />

<xsl:template match="/oBDS/Menge_Patient">
<Patienten>
<xsl:apply-templates select="node()| @*"/>
</Patienten>
</xsl:template>

<xsl:template match="Patient">
<Patient>
<xsl:variable name="Patient_Id" select="if ($keep_internal_id=true()) then @Patient_ID else hash:hash(@Patient_ID,'','')"/>
<xsl:attribute name="Patient_ID" select="$Patient_Id"/>
<xsl:variable name="Geburtsdatum" select="Patienten_Stammdaten/Geburtsdatum"/>
<xsl:variable name="Geburtstag" select="string(replace($Geburtsdatum,'\d\d\d\d\-\d\d\-(\d\d)$','$1'))"/>
<xsl:variable name="Geburtsmonat" select="string(replace($Geburtsdatum,'\d\d\d\d\-(\d\d)\-\d\d$','$1'))"/>
<xsl:variable name="Geburtsjahr" select="string(replace($Geburtsdatum,'(\d\d\d\d)\-\d\d\-\d\d$','$1'))"/>
<xsl:choose>
<xsl:when test="Patienten_Stammdaten/Geschlecht!='' and $Geburtsdatum!='' and Patienten_Stammdaten/Vornamen !='' and Patienten_Stammdaten/Nachname!=''">
<DKTK_LOCAL_ID>
<xsl:value-of select="hash:pseudonymize(
xsi:ReplaceEmpty(Patienten_Stammdaten/Geschlecht),
xsi:ReplaceEmpty(Patienten_Stammdaten/Vornamen),
xsi:ReplaceEmpty(Patienten_Stammdaten/Nachname),
xsi:ReplaceEmpty(Patienten_Stammdaten/Geburtsname),
xsi:ReplaceEmpty($Geburtstag),
xsi:ReplaceEmpty($Geburtsmonat),
xsi:ReplaceEmpty($Geburtsjahr),
xsi:ReplaceEmpty(@Patient_ID))"/>
</DKTK_LOCAL_ID>
</xsl:when>
<xsl:otherwise>
<xsl:message><xsl:value-of select="'Warn: Missing IDAT for Patient', @Patient_ID, ' !&#10;&#10;'"/></xsl:message>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="Patienten_Stammdaten/Geschlecht | Patienten_Stammdaten/Geburtsdatum"/>
<xsl:variable name="Patient_Pseudonym">
<xsl:choose>
<xsl:when test="Patienten_Stammdaten/Geschlecht!='' and $Geburtsdatum!='' and Patienten_Stammdaten/Vornamen !='' and Patienten_Stammdaten/Nachname!=''">
<xsl:value-of select="hash:pseudonymize(
xsi:ReplaceEmpty(Patienten_Stammdaten/Geschlecht),
xsi:ReplaceEmpty(Patienten_Stammdaten/Vornamen),
xsi:ReplaceEmpty(Patienten_Stammdaten/Nachname),
xsi:ReplaceEmpty(Patienten_Stammdaten/Geburtsname),
xsi:ReplaceEmpty($Geburtstag),
xsi:ReplaceEmpty($Geburtsmonat),
xsi:ReplaceEmpty($Geburtsjahr),
xsi:ReplaceEmpty(@Patient_ID))"/>
</xsl:when>
<xsl:otherwise>
<xsl:message><xsl:value-of select="'Warn: Missing IDAT for Patient', @Patient_ID, ' !&#10;&#10;'"/></xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Patient_Id" select="
if ($use_pseudonym = true())
then (if ($keep_internal_id = true()) then $Patient_Pseudonym else hash:hash($Patient_Pseudonym, '', ''))
else (if ($keep_internal_id = true()) then @Patient_ID else hash:hash(@Patient_ID, '', ''))
" />
<xsl:attribute name="Patient_ID" select="$Patient_Id"/>
<DKTK_LOCAL_ID><xsl:value-of select="$Patient_Pseudonym"/></DKTK_LOCAL_ID>
<!--<DKTK_ID>TODO</DKTK_ID>-->

<xsl:apply-templates select="Patienten_Stammdaten/Geschlecht | Patienten_Stammdaten/Geburtsdatum"/>
<Vitalstatus_Gesamt Vitalstatus_ID="{concat('vital', $Patient_Id)}">
<Datum_des_letztbekannten_Vitalstatus>
<xsl:value-of select="if (Patienten_Stammdaten/Vitalstatus_Datum != '') then 'Patienten_Stammdaten/Vitalstatus_Datum' else xsi:Datum_des_letztbekannten_Vitalstatus(Menge_Meldung)"/>
Expand Down

0 comments on commit 3351fd8

Please sign in to comment.