Skip to content

Commit

Permalink
Merge pull request #232 from FHIR/tabular_example
Browse files Browse the repository at this point in the history
Add tabular profile and an example.
  • Loading branch information
rbrush authored Apr 24, 2024
2 parents d924849 + 9fef6fc commit a6bc27a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
37 changes: 37 additions & 0 deletions input/fsh/examples.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@ Usage: #example
* path = "family"
* name = "family_name"

Instance: ShareablePatientDemographics
InstanceOf: ViewDefinition
Description: """
Creates the same view as the 'PatientDemographics' example, but applies both the
ShareableViewDefinition and TabularViewDefinition profiles.
"""
Usage: #example
* url = "http://example.com/ShareablePatientDemographics"
* name = "patient_demographics"
* fhirVersion[+] = #4.0
* fhirVersion[+] = #5.0
* status = #draft
* resource = #Patient
* meta
* profile[+] = "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ShareableViewDefinition"
* profile[+] = "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/TabularViewDefinition"
* select[+]
* column[+]
* path = "getResourceKey()"
* name = "id"
* type = "string"
* column[+]
* path = "gender"
* name = "gender"
* type = "string"
* select[+]
* forEach = "name.where(use = 'official').first()"
* column[+]
* path = "given.join(' ')"
* name = "given_name"
* description = "A single given name field with all names joined together."
* type = "string"
* column[+]
* path = "family"
* name = "family_name"
* type = "string"

Instance: PatientAddresses
InstanceOf: ViewDefinition
Description: """An example of unnesting patient addresses into multiple
Expand Down
36 changes: 35 additions & 1 deletion input/fsh/profiles.fsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
Invariant: no-collections
Description: """
Tabular view columns must not be collections.
"""
Severity: #error
Expression: "collection.empty() or collection = false"

Invariant: primitives-only
Description: """
Tabular view columns only contain primitive values.
"""
Severity: #error
Expression: "type in ('base64Binary' | 'boolean' | 'canonical' | 'code' | 'dateTime' | 'decimal' | 'id' | 'instant' | 'integer' | 'integer64' | 'markdown' | 'oid' | 'string' | 'positiveInt' | 'time' | 'unsignedInt' | 'url' | 'uuid')"

Profile: ShareableViewDefinition
Title: "Shareable View Definition"
Parent: ViewDefinition
Description: "A Shareable View Definition"
Description: """
A profile for View Definitions intended to be shared between multiple systems. This requires there
be a defined URL, name, and version. Also, each column must have specified type so consuming
systems

Shareable View Definitions often also use the TabularViewDefinition profile, requiring
that the view be shareable and contain only tabular values, as is common in many databases
and analytic tools.
"""
* url 1..1
* name 1..1
* fhirVersion 1..*
* select.column.type 1..1

Profile: TabularViewDefinition
Title: "Tabular View Definition"
Parent: ViewDefinition
Description: """
A profile for View Definitions where each resulting field must contain only a simple scalar value.
This is sometimes referred to as 'CSV Mode', but applies to any system that explicitly constrains its
views or tables to tabluar data.
"""
* select.column obeys no-collections
* select.column obeys primitives-only

This file was deleted.

0 comments on commit a6bc27a

Please sign in to comment.