Skip to content
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

Create parseSearchParams Script #8

Merged
merged 3 commits into from
Aug 9, 2024
Merged

Conversation

cgolemme
Copy link
Contributor

@cgolemme cgolemme commented Aug 7, 2024

Summary

In this PR, I created a script to get the search parameters associated with each FHIR resource type.

New behavior

npm run build:search-parameters now creates a searchParameters.ts file that is a record of types mapped to all search parameters and their types associated with each resource type. This is accomplished by using the structure definitions to get the inheritance patterns for each resource, and then use the search-params.json to get the search parameters associated with each resource type. Specifically, this script looks at the base component of each search param in the search-parameters.json file and adds an object whose key is the name field of the search param and whose key is the code field for each resource type that appears in the base of each search param in search-parameters.json

Code changes

  • README.md - updated the readme to reflect the change in behavior from this PR.
  • src/data/searchParameters.ts - exports an object that has each resource type as keys and then search parameters and their types associated with each resource type as values.
  • src/scripts/parseSearchParams.ts - script to create the object described above. Uses the structure definitions to get the inheritance patterns for each resource, and then uses the search-params.json to get the search parameters associated with each resource type.
  • src/scripts/parseProperties.ts removed an unnecessary console.log I added in a previous PR

Testing guidance

  • npm run check
  • npm run build:search-parameters
  • Look at the FHIR spec for a given resource and compare the search parameters listed there to the ones that are listed in the file searchParameters.ts. A good example to test is the Binary resource. Binary specifies no search parameters but inherits from Resource whose search parameters are shown here https://hl7.org/fhir/R4/resource.html#search. Compare this with BiologicallyDerivedProduct which also defines no search parameters but instead inherits from DomainResource (https://hl7.org/fhir/R4/domainResouce.html#search). BiologicallyDerivedProduct should have all search parameters of resource as well as the one search parameter that DomainResource has (_text)
  • You can then check another resource that has search parameters defined and compare the file that the script creates to the spec. An example for this could be Condition. Here are the search params for that https://hl7.org/fhir/R4/Condition.html#search. Check that the ones listed match the file created, as well as the parameters that are inherited.

@cgolemme cgolemme marked this pull request as ready for review August 7, 2024 15:01
@elsaperelli elsaperelli self-requested a review August 8, 2024 15:48
@elsaperelli elsaperelli self-assigned this Aug 8, 2024
src/scripts/parseSearchParams.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@elsaperelli elsaperelli merged commit baadd4f into main Aug 9, 2024
@elsaperelli elsaperelli deleted the Create-search-params-script branch August 9, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants