Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename 'alias' to 'name' and make column name and paths required. #168

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions input/fsh/examples.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ Usage: #example
* select[+]
* column[+]
* path = "getResourceKey()"
* alias = "id"
* name = "id"
* column[+]
* path = "gender"
* name = "gender"
* select[+]
* forEach = "name.where(use = 'official').first()"
* column[+]
* path = "given.join(' ')"
* alias = "given_name"
* name = "given_name"
* description = "A single given name field with all names joined together."
* column[+]
* path = "family"
* alias = "family_name"
* name = "family_name"

Instance: PatientAddresses
InstanceOf: ViewDefinition
Expand All @@ -37,20 +38,22 @@ Usage: #example
* select[+]
* column[+]
* path = "getResourceKey()"
* alias = "patient_id"
* name = "patient_id"
* select[+]
* forEach = "address"
* column[+]
* path = "line.join('\n')"
* alias = "street"
* name = "street"
* description = "The full street address, including newlines if present."
* column[+]
* path = "use"
* name = "use"
* column[+]
* path = "city"
* name = "city"
* column[+]
* path = "postalCode"
* alias = "zip"
* name = "zip"

Instance: UsCoreBloodPressures
InstanceOf: ViewDefinition
Expand All @@ -72,41 +75,41 @@ Usage: #example
* select[+]
* column[+]
* path = "getResourceKey()"
* alias = "id"
* name = "id"
* column[+]
* path = "subject.getReferenceKey('Patient')"
* alias = "patient_id"
* name = "patient_id"
* description = "Can be used to join to patient tables created by other views."
* column[+]
* path = "effective.ofType(dateTime)"
* alias = "effective_date_time"
* name = "effective_date_time"
* select[+]
* forEach = "component.where(code.coding.exists(system='http://loinc.org' and code=%systolic_bp)).first()"
* column[+]
* alias = "sbp_quantity_system"
* name = "sbp_quantity_system"
* path = "value.ofType(Quantity).system"
* column[+]
* alias = "sbp_quantity_code"
* name = "sbp_quantity_code"
* path = "value.ofType(Quantity).code"
* column[+]
* alias = "sbp_quantity_display"
* name = "sbp_quantity_display"
* path = "value.ofType(Quantity).unit"
* column[+]
* alias = "sbp_quantity_value"
* name = "sbp_quantity_value"
* path = "value.ofType(Quantity).value"
* select[+]
* forEach = "component.where(code.coding.exists(system='http://loinc.org' and code=%diastolic_bp)).first()"
* column[+]
* alias = "dbp_quantity_system"
* name = "dbp_quantity_system"
* path = "value.ofType(Quantity).system"
* column[+]
* alias = "dbp_quantity_code"
* name = "dbp_quantity_code"
* path = "value.ofType(Quantity).code"
* column[+]
* alias = "dbp_quantity_display"
* name = "dbp_quantity_display"
* path = "value.ofType(Quantity).unit"
* column[+]
* alias = "dbp_quantity_value"
* name = "dbp_quantity_value"
* path = "value.ofType(Quantity).value"
* where[+]
* path = "code.coding.exists(system='http://loinc.org' and code=%bp_code)"
8 changes: 4 additions & 4 deletions input/fsh/models.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ criteria are defined by FHIRPath expressions.
A column to be produced in the resuting table. The column is relative to the select structure
that contains it.
"""
* path 0..1 string "FHIRPath expression that creates a column and defines its content" """
* path 1..1 string "FHIRPath expression that creates a column and defines its content" """
A FHIRPath expression that evaluates to the value that will be output in the column for each
resource. The input context is the collection of resources of the type specified in the resource
element. Constants defined in Reference({constant}) can be referenced as %[name].
"""
* alias 0..1 string "Column alias produced in the output" """
Alias of the column produced in the output, must be in a database-friendly format.
* name 1..1 string "Column name produced in the output" """
Name of the column produced in the output, must be in a database-friendly format.
"""
* alias obeys sql-name
* name obeys sql-name
* description 0..1 markdown "Description of the column" """
A human-readable description of the column.
"""
Expand Down
6 changes: 3 additions & 3 deletions input/pagecontent/StructureDefinition-ViewDefinition-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ observations, and so on.

#### The selected fields
The ViewDefinition has a [select](StructureDefinition-ViewDefinition-definitions.html#diff_ViewDefinition.select) structure that uses [FHIRPath]
(https://hl7.org/fhirpath/) expressions to select fields from the FHIR structure and an optional
alias for the output field name.
(https://hl7.org/fhirpath/) expressions to select fields from the FHIR structure and place them in the column with the specified name.


#### The "where" criteria
The [where](StructureDefinition-ViewDefinition-definitions.html#diff_ViewDefinition.where) field determines which resources should be used in the view.
Expand All @@ -25,4 +25,4 @@ For instance, users may have different views for blood pressure observations or
Several other fields give the view a name, draft status, and other descriptive information as seen below.

A system-specific *view runner* implementation can execute a view definition and
return the results as a table easily used in the user's tech stack. See the [layers](layers.html) page for details.
return the results as a table easily used in the user's tech stack. See the [layers](layers.html) page for details.
20 changes: 10 additions & 10 deletions input/pagecontent/StructureDefinition-ViewDefinition-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ For example, a minimal view of Patients could look like this:
"column": [
{
"path": "getResourceKey()",
"alias": "id"
"name": "id"
},
{
"path": "active"
Expand All @@ -110,13 +110,13 @@ like this:
"column": [
{
"path": "getResourceKey()",
"alias": "id"
"name": "id"
},
{
// The 'Patient' parameter is optional, but ensures the returned value
// will either be a patient row key or null.
"path": "subject.getReferenceKey('Patient')",
"alias": "patient_id",
"name": "patient_id",
},
]
}],
Expand Down Expand Up @@ -243,21 +243,21 @@ For example, the columns in this ViewDefinition will appear in alphabetical orde
"resource": "..."
"select": [{
"column": [
{ "path": "'A'", "alias": "a" },
{ "path": "'B'", "alias": "b" },
{ "path": "'A'", "name": "a" },
{ "path": "'B'", "name": "b" },
]
"select": [{
"forEach": "aNestedStructure",
"column": [
{ "path": "'C'", "alias": "c" },
{ "path": "'D'", "alias": "d" },
{ "path": "'C'", "name": "c" },
{ "path": "'D'", "name": "d" },
]
}]
},
{
"column": [
{ "path": "'E'", "alias": "e" },
{ "path": "'F'", "alias": "f" },
{ "path": "'E'", "name": "e" },
{ "path": "'F'", "name": "f" },
]
}]
}
Expand Down Expand Up @@ -336,7 +336,7 @@ common and can simplify analysis in some systems.
"column": [
{ "path": "id" },
{
"alias": "birth_date",
"name": "birth_date",
"path": "birthDate",
"tags": [
{
Expand Down
10 changes: 5 additions & 5 deletions input/pagecontent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ futher, making FHIR work well with familiar and efficient SQL engines and surrou

We do this by creating simple, tabular *views* of the underlying FHIR data that are tailored
to specific needs. Views are defined with [FHIRPath](https://hl7.org/fhirpath/) expressions in
a logical structure to specify things like column aliases and unnested items.
a logical structure to specify things like column names and unnested items.

Let's start with a simple example, defining a "patient_demographics" view with the following
[ViewDefinition](StructureDefinition-ViewDefinition.html) structure:
Expand All @@ -20,8 +20,8 @@ Let's start with a simple example, defining a "patient_demographics" view with t
"select": [
{
"column": [
{ "path": "getResourceKey()", "alias": "id" },
{ "path": "gender" }
{ "path": "getResourceKey()", "name": "id" },
{ "path": "gender", "name": "gender }
]
},
{
Expand All @@ -30,12 +30,12 @@ Let's start with a simple example, defining a "patient_demographics" view with t
"column": [
{
"path": "given.join(' ')",
"alias": "given_name",
"name": "given_name",
"description": "A single given name field with all names joined together."
},
{
"path": "family",
"alias": "family_name"
"name": "family_name"
}
]
}
Expand Down