Skip to content

Commit

Permalink
Use most recent SUSHI and FPL dependencies
Browse files Browse the repository at this point in the history
For LakeOfFHIR, since assignMissingIds and removeDuplicateDefinitions
are preparatory steps, add them to the beginning of prepareDefs. Since
they should only be used as these preparatory steps, the methods are
also marked as private.

FSH grammar supports designation on a concept in a CodeSystem. These
test fixtures are therefore now supported and renamed accordingly. This
means that since only a missing name and id makes a CodeSystem
unprocessable, and an id will be added by LakeOfFHIR if it is missing,
it means that any CodeSystem resource is processable after
LakeOfFHIR.prepareDefs is called.

Add helper function to simplify test setup in
ResolveValueSetComponentRuleURLsOptimizer.

Mark FHIRProcessor tests as async, since the calls to restokeLake should
be awaited.

Minor cleanup in some other files.
  • Loading branch information
mint-thompson committed Dec 24, 2024
1 parent 1ce25c4 commit 44ed4e6
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 224 deletions.
33 changes: 18 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
"diff": "^7.0.0",
"diff2html": "^3.4.48",
"fhir": "^4.12.0",
"fhir-package-loader": "^2.0.0-beta.3",
"fhir-package-loader": "^2.0.1",
"flat": "^5.0.2",
"fs-extra": "^11.2.0",
"fsh-sushi": "file:../fsh-sushi-new-fpl.tgz",
"fsh-sushi": "^3.13.1",
"ini": "^5.0.0",
"lodash": "^4.17.21",
"readline-sync": "^1.4.10",
Expand Down
9 changes: 4 additions & 5 deletions src/processor/LakeOfFHIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ export class LakeOfFHIR implements utils.Fishable {
}

async prepareDefs() {
// In theory, this.docs can be modified at any time. In practice, GoFSH only modifies it with calls to
// removeDuplicateDefinitions and assignMissingIds, which are called before the lake is ever used.
// So, it's reasonably safe to provide this function to be called right after those modification functions.
this.assignMissingIds();
this.removeDuplicateDefinitions();
await this.defs.initialize();
const lakeMap = new Map<string, any>();
this.docs.forEach(wildFHIR => {
Expand Down Expand Up @@ -158,7 +157,7 @@ export class LakeOfFHIR implements utils.Fishable {
* 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 =
Expand Down Expand Up @@ -187,7 +186,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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/MasterFisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FHIRDefinitions } from '../utils';
export class MasterFisher implements utils.Fishable {
constructor(
public lakeOfFHIR: LakeOfFHIR,
public external: FHIRDefinitions
public external?: FHIRDefinitions
) {}

fishForStructureDefinition(item: string) {
Expand Down
5 changes: 0 additions & 5 deletions src/utils/Processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ export function ensureOutputDir(output = path.join('.', 'gofsh')): string {

export async function getFhirProcessor(inDir: string, defs: FHIRDefinitions, fileType: string) {
const lake = getLakeOfFHIR(inDir, fileType);

// Assign any missing ids where we can before filtering out duplicates so that all
// the definitions with the same resourceType without an id don't get filtered out.
lake.assignMissingIds();
lake.removeDuplicateDefinitions();
await lake.prepareDefs();

if (defs == null) {
Expand Down
Loading

0 comments on commit 44ed4e6

Please sign in to comment.