-
Notifications
You must be signed in to change notification settings - Fork 7
Use new FPL API #277
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
Merged
Merged
Use new FPL API #277
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1ce25c4
Use new FPL API
mint-thompson 44ed4e6
Use most recent SUSHI and FPL dependencies
mint-thompson 482ec61
Override SUSHI logger with GoFSH logger in FHIRDefinitions
mint-thompson abc6ebd
Suppress logger output in CardRuleExtractor tests
mint-thompson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,11 +5,16 @@ import { CONFORMANCE_AND_TERMINOLOGY_RESOURCES } from './InstanceProcessor'; | |
| import { StructureDefinitionProcessor } from './StructureDefinitionProcessor'; | ||
| import { ValueSetProcessor } from './ValueSetProcessor'; | ||
| import { WildFHIR } from './WildFHIR'; | ||
| import { FHIRDefinitions, logger } from '../utils'; | ||
| import { FHIRDefinitions, logger, logMessage } from '../utils'; | ||
| import { InMemoryVirtualPackage } from 'fhir-package-loader'; | ||
|
|
||
| // Like FSHTank in SUSHI, but it doesn't contain FSH, it contains FHIR. And who ever heard of a tank of FHIR? But a lake of FHIR... | ||
| export class LakeOfFHIR implements utils.Fishable { | ||
| constructor(public docs: WildFHIR[]) {} | ||
| readonly defs: FHIRDefinitions; | ||
|
|
||
| constructor(public docs: WildFHIR[]) { | ||
cmoesel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.defs = new FHIRDefinitions(); | ||
| } | ||
|
|
||
| /** | ||
| * Gets all non-instance structure definitions (profiles, extensions, logicals, and resources) in the lake | ||
|
|
@@ -111,32 +116,40 @@ export class LakeOfFHIR implements utils.Fishable { | |
| } | ||
| } | ||
|
|
||
| async prepareDefs() { | ||
| this.assignMissingIds(); | ||
| this.removeDuplicateDefinitions(); | ||
| await this.defs.initialize(); | ||
| const lakeMap = new Map<string, any>(); | ||
| this.docs.forEach(wildFHIR => { | ||
| lakeMap.set(wildFHIR.path, wildFHIR.content); | ||
| }); | ||
| const lakePackage = new InMemoryVirtualPackage( | ||
| { name: 'wild-fhir', version: '1.0.0' }, | ||
| lakeMap, | ||
| { | ||
| log: (level: string, message: string) => { | ||
| logMessage(level, message); | ||
| } | ||
| } | ||
| ); | ||
| return this.defs.loadVirtualPackage(lakePackage); | ||
| } | ||
|
|
||
| fishForFHIR(item: string, ...types: utils.Type[]) { | ||
| // The simplest approach is just to re-use the FHIRDefinitions fisher. But since this.docs can be modified by anyone at any time | ||
| // the only safe way to do this is by rebuilding a FHIRDefinitions object each time we need it. If this becomes a performance | ||
| // concern, we can optimize it later -- but performance isn't a huge concern in GoFSH. Note also that this approach may need to be | ||
| // updated if we ever need to support fishing for Instances. | ||
| const defs = new FHIRDefinitions(); | ||
| this.docs.forEach(d => defs.add(d.content)); | ||
| return defs.fishForFHIR(item, ...types); | ||
| return this.defs.fishForFHIR(item, ...types); | ||
| } | ||
|
|
||
| fishForMetadata(item: string, ...types: utils.Type[]): utils.Metadata { | ||
| // The simplest approach is just to re-use the FHIRDefinitions fisher. But since this.docs can be modified by anyone at any time | ||
| // the only safe way to do this is by rebuilding a FHIRDefinitions object each time we need it. If this becomes a performance | ||
| // concern, we can optimize it later -- but performance isn't a huge concern in GoFSH. Note also that this approach may need to be | ||
| // updated if we ever need to support fishing for Instances. | ||
| const defs = new FHIRDefinitions(); | ||
| this.docs.forEach(d => defs.add(d.content)); | ||
| return defs.fishForMetadata(item, ...types); | ||
| return this.defs.fishForMetadata(item, ...types); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar question about the comment here as above. |
||
|
|
||
| /** | ||
| * Removes any definitions from this.docs that have the same resourceType and id as | ||
| * a previous definition, as long as there is a defined id. | ||
| * Logs an error when it finds a duplicate | ||
| */ | ||
| removeDuplicateDefinitions() { | ||
| private removeDuplicateDefinitions() { | ||
| const dupPaths: string[] = []; | ||
| this.docs = uniqWith(this.docs, (a, b) => { | ||
| const isDuplicate = | ||
|
|
@@ -165,7 +178,7 @@ export class LakeOfFHIR implements utils.Fishable { | |
| * If there is no name or if it is any other type of resource, we add a clearly generated id with a counter. | ||
| * Log a warning if it finds any definitions without an id | ||
| */ | ||
| assignMissingIds() { | ||
| private assignMissingIds() { | ||
| const createdIdPaths: string[] = []; | ||
| let generatedId = 0; | ||
| this.docs.forEach((d, index) => { | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to make a
createFHIRDefinitionsfunction like in SUSHI?