Skip to content

dwh-scripts/extract_logged_cda_to_csv_by_zip.sh does not work sufficiently #10

Description

@jonasbienzeisler

Bug: extract_logged_cda_to_csv_by_zip.sh does not populate several CSV columns


Summary

Running the Bash script extract_logged_cda_to_csv_by_zip.sh against the 14-day Wolfsburg sample placed on the fileshare produces a CSV whose header lists all required AKTIN / DIVI fields, yet several columns are always NA.
Screenshots provided by Dr. Jennifer Kreklow show the empty fields highlighted in yellow (see cedis_mts_transfer.png & docid_case_diag.png).

This blocks QA and prevents starting the full export.


Affected columns

CSV column | Expected CDA element / CodeSystem | Current value | Notes -- | -- | -- | -- CEDIS Code | | NA | all rows MTS Score | | NA | all rows Transfer | | NA | all rows Discharge Code | | NA | all rows Document ID | | NA | all rows Internal Case Nr. | | NA | all rows Diagnosis | | NA | all rows

Steps to reproduce

  1. Request two real-world test CDAs from IT (see Contact below) that contain non-empty values for the affected fields.

  2. Place the CDAs in a directory, e.g. /share/cda_test/.

  3. Run the script:
    ./extract_logged_cda_to_csv_by_zip.sh /path/to/aktin.properties /share/cda_test/

  4. Open the generated cda_data_<timestamp>.csv and verify that the columns listed above are still NA.


Environment

  • Script version 1.1 (10 Oct 2024)

  • Bash 5.2, Debian 12 container (same behaviour on RHEL 9)

  • aktin.properties from Wolfsburg deployment (encounter & billing roots verified)


Contact

  • Tomasz Babiuch – (please provide two representative CDA files covering the missing fields)

  • CC: Robert Dietrichs, Dr. Jennifer Kreklow


Analysis / Suspected root causes

  1. Incorrect root IDs – The encounter_root and billing_root values in aktin.properties may not match the IDs actually used in the test CDAs.

  2. Regex too strict – Current grep patterns require an explicit xsi:type prefix and may not allow namespace variations.

  3. Multiple occurrences – Using head -1 might pick the wrong section (e.g. administrative vs. clinical) where the field is genuinely empty.


Proposed fix

  • Generalise regex patterns to accept optional namespace prefixes and whitespace.

  • Validate root IDs by echoing them in the log; abort with a clear error if not found.

  • Add a helper script / unit test that parses a mini-CDA snippet for each field.

  • Emit a warning whenever a header field resolves to NA but the tag exists elsewhere in the file (helps QA).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions