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

Support for VSAC FHIR API #28

Merged
merged 3 commits into from
Oct 16, 2023
Merged

Support for VSAC FHIR API #28

merged 3 commits into from
Oct 16, 2023

Conversation

cmoesel
Copy link
Member

@cmoesel cmoesel commented Oct 12, 2023

This PR adds support for the VSAC API by adding a useFHIR boolean parameter to the CodeService constructor. The SVS API is still used by default, as it seems to be faster than the FHIR API.

I've also taken the opportunity to reorganize the code a bit so that the SVS-only constructs and FHIR-only constructs are in their own files while the common constructs are in the main class file. This includes reorganization of the tests to more clearly separate out the concerns of the different APIs vs the common CodeService functions. In addition, I've converted much of the promise-handling logic to use async/await.

You can run a quick manual test by running npm install and then node manual-test.js. There are slight differences in output (e.g., no code system versions in the FHIR output), but this is expected as there are differences in the data each API returns (e.g., for this value set, the FHIR API doesn't return a code system version).

Add support for FHIR with little change to overall structure and organization of the code.
- Refactor code to reduce duplication and minimize footprint of different APIs (FHIR vs SVS).
- Use async / await where it makes sense
- Refactor and update tests
@cmoesel cmoesel requested a review from jafeltra October 12, 2023 13:17
Copy link
Collaborator

@jafeltra jafeltra left a comment

Choose a reason for hiding this comment

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

I think the refactor makes a lot of sense and cleans things up nicely! I ran the tests and the manual-test.js script and looked through the diffs, and things all made sense to me. I just left one really small comment, but I suspect there's a reason so I don't think it should hold up my approval.

Comment on lines +91 to +92
// TODO: Throw error instead
throw 'Failed to download value sets since UMLS_API_KEY is not set.';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason you can't throw the error now?

Copy link
Member Author

Choose a reason for hiding this comment

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

This preserves the same user-facing behavior as before. My only concern was that if someone is using this library and expecting it to reject with a string -- and we change it to reject with an error, then their use might break. So changing it to an Error would be a breaking change. But... we reject with errors in a lot of other places, so in the future, it would be more consistent to do that. Basically, we'll do it whenever we next make a breaking change.

@cmoesel cmoesel merged commit 3905094 into master Oct 16, 2023
@cmoesel cmoesel deleted the vsac-fhir branch October 16, 2023 18:13
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.

2 participants