From 3472b80b3508cf2d669b3184f24f0ef3c2fb21d2 Mon Sep 17 00:00:00 2001 From: Ryan Crichton Date: Mon, 4 Dec 2023 09:48:44 +0200 Subject: [PATCH] Add improved examples for reporting pipeline --- .../importer/config/clickhouseTables.js | 56 ++++++++++++++----- kafka-mapper-consumer/fhir-mapping.json | 24 +++++++- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/analytics-datastore-clickhouse/importer/config/clickhouseTables.js b/analytics-datastore-clickhouse/importer/config/clickhouseTables.js index 8c3ba4e7..ab9767a9 100644 --- a/analytics-datastore-clickhouse/importer/config/clickhouseTables.js +++ b/analytics-datastore-clickhouse/importer/config/clickhouseTables.js @@ -1,22 +1,52 @@ -const CLUSTERED_MODE = process.env.CLUSTERED_MODE || 'true'; +const CLUSTERED_MODE = process.env.CLUSTERED_MODE || "true"; const queries = Boolean(CLUSTERED_MODE) === true ? [ - `CREATE TABLE default_table( - createdAt Date, - updatedAt Date - ) - ENGINE=MergeTree - ORDER BY tuple();`, + `CREATE TABLE patient_example( + id String, + version String NULL, + inserted_at DateTime DEFAULT now(), + last_updated Date NULL, + goldenId String, + patientGivenName String, + patientFamilyName String, + ) + ENGINE=MergeTree + ORDER BY tuple();`, + `CREATE TABLE observation_example( + id String, + version String NULL, + inserted_at DateTime DEFAULT now(), + last_updated Date NULL, + observationValue Double, + patientId String, + ) + ENGINE=MergeTree + ORDER BY tuple();`, ] : [ - `CREATE TABLE default.default_table ON CLUSTER '{cluster}' ( - createdAt Date, - updatedAt Date - ) - ENGINE = ReplicatedMergeTree('/clickhouse/tables/{cluster}/{shard}/{table}', '{replica}') - ORDER BY tuple();`, + `CREATE TABLE patient_example ON CLUSTER '{cluster}' ( + id String, + version String NULL, + inserted_at DateTime DEFAULT now(), + last_updated Date NULL, + goldenId String, + patientGivenName String, + patientFamilyName String, + ) + ENGINE = ReplicatedMergeTree('/clickhouse/tables/{cluster}/{shard}/{table}', '{replica}') + ORDER BY tuple();`, + `CREATE TABLE observation_example ON CLUSTER '{cluster}' ( + id String, + version String NULL, + inserted_at DateTime DEFAULT now(), + last_updated Date NULL, + observationValue Double, + patientId String, + ) + ENGINE = ReplicatedMergeTree('/clickhouse/tables/{cluster}/{shard}/{table}', '{replica}') + ORDER BY tuple();`, ]; module.exports = queries; diff --git a/kafka-mapper-consumer/fhir-mapping.json b/kafka-mapper-consumer/fhir-mapping.json index 943ed02f..e15d482f 100644 --- a/kafka-mapper-consumer/fhir-mapping.json +++ b/kafka-mapper-consumer/fhir-mapping.json @@ -3,8 +3,12 @@ "resourceType": "Patient", "tableMappings": [ { - "targetTable": "patient", + "targetTable": "patient_example", "columnMappings": [ + { + "columnName": "goldenId", + "fhirPath": "Patient.link.where(type='refer').other.reference.replace('Patient/', '')" + }, { "columnName": "patientGivenName", "fhirPath": "Patient.name.given" @@ -16,5 +20,23 @@ ] } ] + }, + { + "resourceType": "Observation", + "tableMappings": [ + { + "targetTable": "observation_example", + "columnMappings": [ + { + "columnName": "observationValue", + "fhirPath": "Observation.valueQuantity.value" + }, + { + "columnName": "patientId", + "fhirPath": "Observation.subject.reference.replace('Patient/', '')" + } + ] + } + ] } ]