Skip to content

Commit

Permalink
Add improved examples for reporting pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrichton committed Dec 4, 2023
1 parent 36b4e03 commit 3472b80
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
56 changes: 43 additions & 13 deletions analytics-datastore-clickhouse/importer/config/clickhouseTables.js
Original file line number Diff line number Diff line change
@@ -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;
24 changes: 23 additions & 1 deletion kafka-mapper-consumer/fhir-mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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/', '')"
}
]
}
]
}
]

0 comments on commit 3472b80

Please sign in to comment.