Skip to content

Commit

Permalink
Merge pull request #118 from aehrc/_export_fixes
Browse files Browse the repository at this point in the history
Update SQL script that exports FHIR resources to NDJSON files.
  • Loading branch information
alistairewj authored Oct 28, 2024
2 parents c8a3744 + a53583b commit 4327224
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ psql -d mimiciv -f create_fhir_tables.sql
psql -d mimiciv -f validate_fhir_tables.sql
```


#### Export to ndjson files

- Export the FHIR resources to ndjson files in `<output-dir>` by running [create_fhir_jsons.sql](...) found in the folder `mimic-fhir/sql`
(replace `<output-dir>` with the desired existing and empty output directory).

```sh
psql -d mimiciv -v "outputdir=<output-dir>" -f sql/create_fhir_jsons.sql
````

## HAPI FHIR for use in validation/export

- The first step in validation/export is getting the fhir server running. In our case we will use HAPI FHIR.
Expand Down
17 changes: 16 additions & 1 deletion sql/create_fhir_jsons.sql
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ do $$ BEGIN RAISE 'outputdir not set, exiting'; END; $$ LANGUAGE plpgsql;
\set command '\\copy mimic_fhir.medication_dispense_ed(fhir) TO ' :'outputfile' :with_format
:command

\echo medication_dispense_mix
\set outputfile :outputdir/MimicMedicationMix.ndjson
\set command '\\copy mimic_fhir.medication_mix(fhir) TO ' :'outputfile' :with_format
:command

\echo medadmin
\set outputfile :outputdir/MimicMedicationAdministration.ndjson
\set command '\\copy mimic_fhir.medication_administration(fhir) TO ' :'outputfile' :with_format
Expand Down Expand Up @@ -150,6 +155,16 @@ do $$ BEGIN RAISE 'outputdir not set, exiting'; END; $$ LANGUAGE plpgsql;
:command

\echo observation_vitalsigns
\set outputfile :outputdir/MimicObservationVitalSigns.ndjson
\set outputfile :outputdir/MimicObservationVitalSignsED.ndjson
\set command '\\copy mimic_fhir.observation_vital_signs(fhir) TO ' :'outputfile' :with_format
:command

\echo specimen
\set outputfile :outputdir/MimicSpecimen.ndjson
\set command '\\copy mimic_fhir.specimen(fhir) TO ' :'outputfile' :with_format
:command

\echo specimen_lab
\set outputfile :outputdir/MimicSpecimenLab.ndjson
\set command '\\copy mimic_fhir.specimen_lab(fhir) TO ' :'outputfile' :with_format
:command

0 comments on commit 4327224

Please sign in to comment.