### FSH Caret Path Example: Extension Short Description
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
An example demonstrating how to use a caret path to set the 'short' description of an extension, which is defined in the first ElementDefinition.
```fsh
. ^short
```
--------------------------------
### Example: Correct rule ordering for Quantity assignment (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Shows the correct way to assign both value and unit to a Quantity by reversing the order of the rules from the incorrect example.
```FSH
* valueQuantity = 55.0 'mm'
* valueQuantity.unit = "millimeter"
```
--------------------------------
### Define Inline Extensions for US Core Race Example (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates defining inline extensions for the US Core Race example using FSH. This includes specifying local names, cardinality, and flags for extensions like 'ombCategory', 'detailed', and 'text'.
```fsh
* extension contains
ombCategory 0..5 MS and
detailed 0..* and
text 1..1 MS
// rules defining the inline extensions would typically follow:
* extension[ombCategory].value[x] only Coding
* extension[ombCategory].value[x] from http://hl7.org/fhir/us/core/ValueSet/omb-race-category (required)
* extension[text].value[x] only string
// etc.
```
--------------------------------
### Example: Assign Patient reference to Observation.subject (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Assigns a reference to an example Patient resource named 'EveAnyperson' to the 'subject' element of an Observation.
```FSH
* subject = Reference(EveAnyperson)
```
--------------------------------
### Example: Define an example Patient resource (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Defines an example Patient resource instance named 'EveAnyperson' with given and family names. This is used in conjunction with resource references.
```FSH
Instance: EveAnyperson
InstanceOf: Patient
Description: "Eve Anyperson"
Usage: #example
* name.given = "Eve"
* name.family = "Anyperson"
```
--------------------------------
### FSH Top-Level Path Example
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates how to specify the path to a top-level element in FSH. The path is simply the element's name, as the resource context is inferred.
```fsh
status
```
--------------------------------
### Example: Constraining Systolic and Diastolic BP Slices
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Provides an example of constraining the content of 'systolicBP' and 'diastolicBP' slices. It shows how to assign codes, specify value types, and set units for these constrained slices.
```FSH
* component[systolicBP].code = $LNC#8480-6 // Systolic blood pressure
* component[systolicBP].value[x] only Quantity
* component[systolicBP].value[x] = $UCUM#mm[Hg] "mmHg"
* component[diastolicBP].code = $LNC#8462-4 // Diastolic blood pressure
* component[diastolicBP].value[x] only Quantity
* component[diastolicBP].value[x] = $UCUM#mm[Hg] "mmHg"
```
--------------------------------
### Example: Express weight in pounds using UMLS (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Expresses a weight in pounds using a UMLS code for units and a display string 'pounds'. This is noted as not recommended.
```FSH
* valueQuantity = 155.0 http://terminology.hl7.org/CodeSystem/umls#C0439219 "pounds"
```
--------------------------------
### Soft Indexing with Indented Rules (FSH) - Example 2
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Provides another example of soft indexing combined with indented paths. It clarifies that when a rule with '[+]' sets context for multiple subsequent rules, the index increments only once for the first rule, and subsequent rules use '[=]'.
```fsh
* rest.resource[+]
* type = #Organization
* interaction[+].code = #create
* interaction[+].code = #update
* interaction[+].code = #delete
* rest.resource[+]
* type = #Condition
* interaction[+].code = #create
* interaction[+].code = #update
```
```fsh
* rest.resource[+].type = #Organization
* rest.resource[=].interaction[+].code = #create
* rest.resource[=].interaction[+].code = #update
* rest.resource[=].interaction[+].code = #delete
* rest.resource[+].type = #Condition
* rest.resource[=].interaction[+].code = #create
```
--------------------------------
### FSH Caret Path Example: StructureDefinition.experimental
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
An example demonstrating how to use a caret path in a profile definition to access the 'experimental' attribute of the corresponding StructureDefinition.
```fsh
^experimental
```
--------------------------------
### FSH Reference Path Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Shows how to specify paths to specific reference types within a reference element. This can be done using the target resource/profile name, its canonical URL, or its ID.
```fsh
performer[Practitioner]
```
```fsh
performer[http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization]
```
```fsh
performer[us-core-organization]
```
--------------------------------
### Example: Apply Questionnaire Item Rule Set
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates the application of the 'Question' parameterized rule set to populate a Questionnaire instance. Each 'insert Question(...)' call provides specific values for the parameters, dynamically generating questionnaire items.
```fhirpath
Instance: TravelRecord
InstanceOf: Questionnaire
// skip some
* insert Question(tr1, When did you leave?, date, false)
* insert Question(tr2, When did you return?, date, false)
* insert Question(tr3, What countries did you visit?, code, true)
```
--------------------------------
### FSH Reference Syntax Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates the FHIR Shorthand syntax for creating references to other FHIR resources or profiles. It shows how to specify targets by name, id, or URL, and how to handle multiple targets using 'or'.
```FSH
Reference(USCorePatientProfile)
Reference(us-core-patient)
Reference(http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient)
Reference(Patient or Group)
Reference(JaneDoe)
```
--------------------------------
### Example: Assign resource instance within Bundle.entry.resource (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Assigns a resource instance directly to the 'resource' element within the first entry of a Bundle. This is used when the element's datatype is Resource, not Reference(Resource).
```FSH
* entry[0].resource = EveAnyperson
```
--------------------------------
### FSH Caret Path Example: ElementDefinition.binding.description
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
An example showing a caret path in a profile of Patient to access the 'binding.description' of the ElementDefinition corresponding to 'communication.language'.
```fsh
communication.language ^binding.description
```
--------------------------------
### FSH Nested Element Path Example
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Illustrates how to construct paths to nested elements in FSH by listing properties in order, separated by dots. The resource name is omitted as it's inferred from the context.
```fsh
batch.lotNumber
```
```fsh
dosage.site.text
```
--------------------------------
### Complete Slicing Example for Tumor Dimensions
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
A comprehensive example demonstrating how to slice Observation components to represent tumor dimensions. It includes defining slicing discriminators, rules, contains rules, and constraining the properties of each tumor dimension slice.
```FSH
Profile: TumorSize
Parent: Observation
Id: example-tumor-size
Title: "Tumor Size"
Description: "Records the one to three dimensions of a tumor"
* code = $LNC#21889-1 //"Size Tumor"
// other rules omitted
* component ^slicing.discriminator.type = #pattern
* component ^slicing.discriminator.path = "code"
* component ^slicing.rules = #open
* component ^slicing.description = "Slice based on the component.code pattern"
// Contains rule
* component contains tumorLongestDimension 1..1 and tumorOtherDimension 0..2
// Set properties of each slice
* component[tumorLongestDimension] ^short = "Longest tumor dimension"
* component[tumorLongestDimension] ^definition = "The longest tumor dimension in cm or mm."
* component[tumorLongestDimension].code = $LNC#33728-7 // "Size.maximum dimension in Tumor"
* component[tumorLongestDimension].value[x] only Quantity
* component[tumorLongestDimension].value[x] from TumorSizeUnitsVS (required) // value set defined elsewhere
* component[tumorOtherDimension] ^short = "Other tumor dimension(s)"
* component[tumorOtherDimension] ^definition = "The second or third tumor dimension in cm or mm."
* component[tumorOtherDimension] ^comment = "Additional tumor dimensions should be ordered from largest to smallest."
* component[tumorOtherDimension].code = $LNC#33729-5 // "Size additional dimension in Tumor"
* component[tumorOtherDimension].value[x] only Quantity
* component[tumorOtherDimension].value[x] from TumorSizeUnitsVS (required)
```
--------------------------------
### Example: Set valueQuantity to 55 millimeters with display string (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Sets the valueQuantity of an Observation to 55.0 with the UCUM unit 'mm' and the display string 'millimeter'.
```FSH
* valueQuantity = 55.0 'mm' "millimeter"
```
--------------------------------
### Example: Set only valueQuantity.value (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Sets only the numerical value of Observation.valueQuantity to 55.0, without specifying units.
```FSH
* valueQuantity.value = 55.0
```
--------------------------------
### Example: Alternative correct Quantity assignment (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Presents an alternative correct method for assigning value and unit to a Quantity using a UCUM alias and setting the value separately.
```FSH
* valueQuantity = $UCUM#mm "millimeter"
* valueQuantity.value = 55.0
```
--------------------------------
### FSH Canonical Syntax Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Illustrates the FHIR Shorthand syntax for creating canonical references to FHIR items. It covers referencing by name, id, or URL, and how to append specific versions.
```FSH
Canonical(yesnodontknow)
Canonical(ExampleValueSet)
Canonical(us-core-allergyintolerance|3.1.1)
```
--------------------------------
### Example: Set valueQuantity to 55 millimeters (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Sets the valueQuantity of an Observation to 55.0 with the UCUM unit 'mm' for millimeters.
```FSH
* valueQuantity = 55.0 'mm'
```
--------------------------------
### Example: Expanded Set Extension Context Rule Set
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Illustrates the expanded form of the 'SetContext' rule set after parameter substitution. Each 'insert' statement is translated into the concrete FHIRPath rules with the provided parameter values embedded.
```fhirpath
* ^context[+].type = #element
* ^context[=].expression = "Procedure"
* ^context[+].type = #element
* ^context[=].expression = "MedicationRequest"
* ^context[+].type = #element
* ^context[=].expression = "MedicationAdministration"
```
--------------------------------
### Example: Set units to pounds using UMLS alias (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Sets the units of Observation.valueQuantity to pounds using a UMLS unit code and a display string, assuming '$UMLS' is defined as an alias. This is noted as not recommended.
```FSH
* valueQuantity = $UMLS#C0439219 "pounds"
```
--------------------------------
### Soft Indexing with Indented Rules (FSH) - Example 1
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Shows the interaction between soft indexing (using '[+]') and indented rules. When a rule with '[+]' sets context, subsequent indented rules use '[=]' for the same index, incrementing only once.
```fsh
* item[+]
* linkId = "title"
* type = #display
```
```fsh
* item[+].linkId = "title"
* item[=].type = #display
```
--------------------------------
### FSH Rule Syntax Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates the general syntax for FSH rules, which are distinguished by a leading asterisk (*). Rules are used for various operations like populating and constraining FHIR resources.
```fsh
* {rule statement}
```
--------------------------------
### Assign Caret Paths in FSH
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Provides examples of using caret paths (`^`) in FSH to assign values to metadata or properties of definitional instances. This includes setting flags, custom URLs, and descriptions for elements.
```FSH
* ^experimental = true
```
```FSH
* ^url = "http://example.org/custom/myextension"
```
```FSH
* value[x] ^short = "Measurement in cm"
* value[x] ^definition = "The measurement in centimeters. Values in other units must be converted to centimeters in order to conform with this profile."
```
```FSH
* value[x]
* ^short = "Measurement in cm"
* ^definition = "The measurement in centimeters. Values in other units must be converted to centimeters in order to conform with this profile."
```
```FSH
* #active ^designation[0].use = $SCT#900000000000003001 "Fully specified name"
```
```FSH
* include $SCT#84162001 "Cold"
* ^designation[0].use = $SCT#900000000000003001 "Fully specified name"
* ^designation[0].value = "Cold sensation quality (qualifier value)"
```
--------------------------------
### Soft Indexing for Array Population (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates how soft indexing (`[+]` and `[=]`) simplifies populating arrays by dynamically managing indices. This is particularly useful for long arrays where insertions or deletions are frequent. The examples show equivalent explicit numerical indexing.
```FSH
* name[+].given = "Robert"
* name[=].family = "Smith"
* name[+].given = "Rob"
* name[=].family = "Smith"
* name[+].given = "Bob"
* name[=].family = "Smith"
```
```FSH
* name[0].given = "Robert"
* name[0].family = "Smith"
* name[1].given = "Rob"
* name[1].family = "Smith"
* name[2].given = "Bob"
* name[2].family = "Smith"
```
--------------------------------
### Accessing Hierarchical Code Metadata Path
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This example shows how to specify a path to a metadata element within a hierarchical code structure. It demonstrates accessing the 'code' property of the first designation for the '#recurrence' code, which is a child of the '#active' code.
```FSH
#active #recurrence ^property[0].code
```
--------------------------------
### Set Code Metadata using Caret Syntax (Designation)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This example illustrates setting metadata for a code using the caret syntax. Specifically, it sets the 'designation.use' attribute for the '#active' code to a specific value representing 'Fully specified name'.
```FSH
* #active ^designation[0].use = $SCT#900000000000003001 "Fully specified name"
```
--------------------------------
### Example: Incorrect rule ordering for Quantity assignment (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates how incorrect ordering of rules can lead to the loss of a previously assigned value in a Quantity. The second rule clears the entire Quantity before applying new values.
```FSH
* valueQuantity.unit = "millimeter"
* valueQuantity = 55.0 'mm'
```
--------------------------------
### Example: Apply Set Extension Context Rule Set
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Shows how to apply the 'SetContext' parameterized rule set. By inserting the rule set with different resource names (e.g., Procedure, MedicationRequest), the 'path' parameter is substituted, dynamically configuring the extension context for each resource.
```fhirpath
* insert SetContext(Procedure)
* insert SetContext(MedicationRequest)
* insert SetContext(MedicationAdministration)
```
--------------------------------
### Example: Reslicing Observation Component for Apgar Score
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
An example illustrating how to reslice the 'respirationScore' component slice of an Observation to represent one-, five-, and ten-minute Apgar scores. This demonstrates practical application of reslicing syntax.
```FSH
* component contains
appearanceScore 0..3 and
pulseScore 0..3 and
grimaceScore 0..3 and
activityScore 0..3 and
respirationScore 0..3
* component[respirationScore] contains
oneMinuteScore 0..1 and
fiveMinuteScore 0..1 and
tenMinuteScore 0..1
```
--------------------------------
### FSH Whitespace Reformatting Example
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates how repeated whitespace in FSH can be reformatted for readability without changing the meaning, except within string literals. This example shows a complex 'contains' rule being broken down into multiple lines.
```FSH
* component contains appearanceScore 0..3 and pulseScore 0..3 and grimaceScore 0..3 and activityScore 0..3 and respirationScore 0..3
MAY be reformatted as:
* component contains
appearanceScore 0..3 and
pulseScore 0..3 and
grimaceScore 0..3 and
activityScore 0..3 and
respirationScore 0..3
```
--------------------------------
### Example Condition Resource with Contained Patient (JSON)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This JSON output represents the Condition resource generated from the FSH example where a Patient instance is inlined. It shows the 'contained' array holding the Patient resource and the 'subject' field referencing it.
```JSON
{
"resourceType": "Condition",
"id": "EvesCondition",
"contained": [
{
"resourceType": "Patient",
"id": "EveAnyperson",
"name": [
{
"given": [
"Eve"
],
"family": "Anyperson"
}
]
}
],
"code": {
"coding": [
{
"code": "bar",
"system": "http://foo.org"
}
]
},
"subject": {
"reference": "#EveAnyperson"
}
}
```
--------------------------------
### Example: Set Extension Context Rule Set
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates a parameterized rule set 'SetContext' used to define the context for an extension. It takes a 'path' parameter, which is substituted into the expression for the extension's context. This allows for flexible application of extensions to different resource types.
```fhirpath
RuleSet: SetContext(path)
* ^context[+].type = #element
* ^context[=].expression = "{path}"
```
--------------------------------
### FSH Binding Rules Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/overview.md
Binding rules specify the set of enumerated values for elements with coded values. They include FHIR's binding strengths like 'example', 'preferred', 'extensible', or 'required'.
```FSH
* gender from http://hl7.org/fhir/ValueSet/administrative-gender (required)
```
```FSH
* address.state from USPSTwoLetterAlphabeticCodes (extensible) // USPSTwoLetterAlphabeticCodes is a value set defined in US Core
```
--------------------------------
### Example: Interpreted Set Extension Context Rule Set
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Presents the final interpretation of the expanded 'SetContext' rule set, resolving soft indices. This shows how the rule set, when applied multiple times, correctly generates indexed elements for the extension context.
```fhirpath
* ^context[0].type = #element
* ^context[0].expression = "Procedure"
* ^context[1].type = #element
* ^context[1].expression = "MedicationRequest"
* ^context[2].type = #element
* ^context[2].expression = "MedicationAdministration"
```
--------------------------------
### Multiple Paths in Context-Setting Rule (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates a scenario where a rule with multiple paths sets context for subsequent rules. In this case, only the last path specified in the context-setting rule is used for subsequent indentation.
```fsh
* birthDate and name MS
* family 1..1
```
```fsh
* birthDate and name MS
* name.family 1..1
```
--------------------------------
### Set Context with Path Rules (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Illustrates how a path rule, when indented, sets the context for subsequent rules. This allows for more concise definitions by avoiding repetition of the parent path.
```fsh
* name
* family 1..1
* given 1..1
```
```fsh
* name.family 1..1
* name.given 1..1
```
--------------------------------
### Define US Core Patient Instance (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This snippet defines an example instance of a US Core Patient profile. It includes common fields like name, birthDate, and extensions for race and ethnicity. The 'Usage: #example' indicates it's for illustrative purposes.
```FSH
Instance: EveAnyperson
InstanceOf: http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient
Title: "Eve Anyperson"
Usage: #example
* name.given = "Eve"
* name.family = "Anyperson"
* birthDate = 1960-04-25
* extension[us-core-race].extension[ombCategory].valueCoding = RaceAndEthnicityCDC#2106-3 "White"
* extension[us-core-ethnicity].extension[ombCategory].valueCoding = RaceAndEthnicityCDC#2186-5 "Non Hispanic or Latino"
```
--------------------------------
### FSH Complex Path Example
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/overview.md
Demonstrates the use of complex paths in FHIR Shorthand (FSH) to refer to nested elements within a resource. This example targets the 'valueCodeableConcept' element within an extension named 'evidenceType'.
```fsh
Profile: MyProfile
* extension[evidenceType].valueCodeableConcept
```
--------------------------------
### Define Example Patient Instance in FSH
Source: https://context7.com/hl7/fhir-shorthand/llms.txt
Defines a concrete example of a FHIR Patient resource using FSH. This instance includes basic demographic information, identifiers, and address details. It serves as a clear illustration of the Patient resource structure.
```fsh
Instance: PatientExample
InstanceOf: Patient
Title: "Patient Example - Jane Doe"
Description: "An example patient for demonstration purposes."
Usage: #example
* identifier.system = "http://hospital.example.org/patients"
* identifier.value = "12345"
* active = true
* name.given = "Jane"
* name.family = "Doe"
* gender = #female
* birthDate = "1990-05-15"
* address.line = "123 Main Street"
* address.city = "Anytown"
* address.state = "CA"
* address.postalCode = "90210"
* address.country = "US"
```
--------------------------------
### Define Hierarchical Codes in CodeSystem (Explicit Parent)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This example demonstrates defining a code system with hierarchical codes using explicit parent codes. Each child code explicitly references its parent using the '#{parent code} #{child code}' syntax. This method is clear for complex hierarchies.
```FSH
CodeSystem: AnteaterCS
Id: anteater-code-system
Title: "Anteater Code System"
Description: "A code system for anteater taxonomy with hierarchical codes"
* #Anteater "Anteater" "Members of suborder Vermilingua, distinguished by its propensity to eat ants"
* #Anteater #Tamandua "Members of genus Tamandua" "The Tamandua genus of anteaters, mainly found in forests and grasslands"
* #Anteater #Tamandua #NorthernTamandua "Northern Tamandua" "The northern species of Tamandua anteaters"
* #Anteater #Tamandua #SouthernTamandua "Southern Tamandua" "The southern species of Tamandua anteaters"
* #Anteater #GiantAnteater "Giant Anteater" "The Giant Anteater, typically 6 - 7 feet in length"
```
--------------------------------
### FSH: Parameterized Rule Set Definition and Usage Example (Patient Names)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This snippet shows a FHIR Shorthand (FSH) rule set named 'Name' that accepts 'first' and 'last' parameters to populate patient names. It also includes an example of how to insert this parameterized rule set into a Patient instance, demonstrating the substitution of 'Robert', 'Smith', 'Rob', and 'Bob'.
```FSH
RuleSet: Name(first, last)
* name[+].given = "{first}"
* name[=].family = "{last}"
```
```FSH
Instance: MrSmith
InstanceOf: Patient
Title: "Mr. Smith"
Description: "The patient Robert Smith"
// some rules
* insert Name(Robert, Smith)
* insert Name(Rob, Smith)
* insert Name(Bob, Smith)
// more rules
```
```FSH
Instance: MrSmith
InstanceOf: Patient
Title: "Mr. Smith"
Description: "The patient Robert Smith"
// some rules
* name[0].given = "Robert"
* name[0].family = "Smith"
* name[1].given = "Rob"
* name[1].family = "Smith"
* name[2].given = "Bob"
* name[2].family = "Smith"
// more rules
```
--------------------------------
### Define CapabilityStatement using FSH Instance Grammar
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This snippet demonstrates how to define a CapabilityStatement resource using FSH instance grammar. It utilizes 'InstanceOf: CapabilityStatement' and 'Usage: #definition' to declare the resource type and its purpose. The CapabilityStatement is then populated using assignment statements.
```FSH
InstanceOf: CapabilityStatement
Usage: #definition
// CapabilityStatement is populated using assignment statements
```
--------------------------------
### FSH Cardinality Rules Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/overview.md
Cardinality rules constrain the number of occurrences of an element, defining both upper and lower bounds, or just one of them.
```FSH
* note 1..1
```
```FSH
* note 1..
```
```FSH
* note ..1
```
--------------------------------
### Define Hierarchical Codes in CodeSystem (Indentation)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
This example shows defining a code system with hierarchical codes using indentation. Child codes are indented two spaces per level under their parent code. This syntax offers a more compact representation for nested structures.
```FSH
CodeSystem: AnteaterCS
Id: anteater-code-system
Title: "Anteater Code System"
Description: "A code system for anteater taxonomy with hierarchical codes"
* #Anteater "Anteater" "Members of suborder Vermilingua, distinguished by its propensity to eat ants"
* #Tamandua "Members of genus Tamandua" "The Tamandua genus of anteaters, mainly found in forests and grasslands"
* #NorthernTamandua "Northern Tamandua" "The northern species of Tamandua anteaters"
* #SouthernTamandua "Southern Tamandua" "The southern species of Tamandua anteaters"
* #GiantAnteater "Giant Anteater" "The Giant Anteater, typically 6 - 7 feet in length"
```
--------------------------------
### Specify Extension Context using Extension URL in FSH
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Shows how to define an extension and specify its context using the URL of another extension. This indicates that 'MyExtension' can be applied in the context where the 'capabilitystatement-search-parameter-combination' extension is used.
```fsh
Extension: MyExtension
Context: http://hl7.org/fhir/StructureDefinition/capabilitystatement-search-parameter-combination
```
--------------------------------
### Example: Set only valueQuantity units with UCUM (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Sets only the units of Observation.valueQuantity to millimeters using the UCUM code 'mm' and the display string 'millimeter', without setting the numerical value.
```FSH
* valueQuantity = 'mm' "millimeter"
```
--------------------------------
### FSH Value Set Rules (Extensional) Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/overview.md
Extensional value set rules list individual codes to be included or excluded from a value set.
```FSH
* include $SCT#54102005 "G1 grade (finding)"
```
```FSH
* exclude $SCT#12619005 "Tumor grade GX"
```
--------------------------------
### FSH Type Rules Examples
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/overview.md
Type rules restrict the data type of values that can be assigned to an element. They can specify a single type or a choice of types.
```FSH
* value[x] only CodeableConcept
```
```FSH
* onset[x] only Period or Range
```
```FSH
* recorder only Reference(Practitioner)
```
```FSH
* recorder only Reference(Practitioner or PractitionerRole)
```
--------------------------------
### FSH Insert Rule Syntax
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Demonstrates the syntax for inserting rulesets into FSH definitions. This allows for reusable sets of rules and supports parameterization.
```fsh
* insert {RuleSet}
* insert {RuleSet}({parameter1}, {parameter2}, ...)
* insert {RuleSet}({parameter1}, {parameter2}, ...)
```
--------------------------------
### FSH ValueSet Declaration
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/overview.md
Example of a 'ValueSet' declaration statement in FHIR Shorthand (FSH). This declaration introduces and names a new ValueSet resource definition.
```fsh
ValueSet: ConditionStatusTrendVS
```
--------------------------------
### Add Standalone Extension Defined in Same FSH Project
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Example of adding a standalone extension named 'Laterality', defined within the same FSH project, to a 'bodySite' attribute. This illustrates how to reference locally defined extensions.
```fsh
* bodySite.extension contains Laterality named laterality 0..1
// intervening lines not shown
Extension: Laterality
Description: "Body side of a body location."
* value[x] only CodeableConcept
* value[x] from LateralityVS (required)
```
--------------------------------
### Assign Resource Reference (FSH)
Source: https://github.com/hl7/fhir-shorthand/blob/master/input/pagecontent/reference.md
Assigns a reference to another resource instance using the Reference() constructor. This is the standard way to link resources.
```FSH
* = Reference({Resource})
```