-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use keyword for description, rules for everything else
When producing FSH for an Invariant, use the Description keyword for the description element. For all other metadata elements, use assignment rules instead. These rules will always come before any other rules on the Invariant.
- Loading branch information
1 parent
1c78ec0
commit bd3aca3
Showing
2 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
import { fshtypes } from 'fsh-sushi'; | ||
import { Exportable, ExportableAssignmentRule, ExportableInsertRule } from '.'; | ||
import { fshifyString } from './common'; | ||
import { EOL } from 'os'; | ||
|
||
export class ExportableInvariant extends fshtypes.Invariant implements Exportable { | ||
rules: (ExportableAssignmentRule | ExportableInsertRule)[]; | ||
|
||
constructor(name: string) { | ||
super(name); | ||
} | ||
|
||
metadataToFSH(): string { | ||
const resultLines: string[] = []; | ||
resultLines.push(`Invariant: ${this.name}`); | ||
if (this.description) { | ||
// Description can be a multiline string. | ||
// If it contains newline characters, treat it as a multiline string. | ||
if (this.description.indexOf('\n') > -1) { | ||
resultLines.push(`Description: """${this.description}"""`); | ||
} else { | ||
resultLines.push(`Description: "${fshifyString(this.description)}"`); | ||
} | ||
} | ||
if (this.severity) { | ||
resultLines.push(`* severity = ${this.severity}`); | ||
} | ||
if (this.expression) { | ||
resultLines.push(`* expression = "${fshifyString(this.expression)}"`); | ||
} | ||
if (this.xpath) { | ||
resultLines.push(`* xpath = "${fshifyString(this.xpath)}"`); | ||
} | ||
return resultLines.join(EOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters