Skip to content

[NDH-278] Build out OrganizationAffiliation endpoint#270

Merged
IsaacMilarky merged 49 commits intomainfrom
isaacmilarky/NDH-278-build-out-organization-affiliation-endpoint
Feb 3, 2026
Merged

[NDH-278] Build out OrganizationAffiliation endpoint#270
IsaacMilarky merged 49 commits intomainfrom
isaacmilarky/NDH-278-build-out-organization-affiliation-endpoint

Conversation

@IsaacMilarky
Copy link
Collaborator

@IsaacMilarky IsaacMilarky commented Dec 12, 2025

[NDH-278] Build out OrganizationAffiliation endpoint

Jira Ticket #NDH-278

Problem

We currently do not have an endpoint that can query OrganizationAffiliation data. This endpoint returns data that represents the affiliation relationship between clinical organizations and EHR Vendors

Additionally, we need to make it so that EHR Vendors can be queried in the Organization view.

Solution

Add a new view set for OrganizationAffiliation data that has list and retrieve endpoints. Also, create a corresponding serializer class that will create FHIR JSON for the data returned.

Additionally, make it so that EHR Vendors can be queried in the Organization viewset.

Tests also need to be created for all this.

Result

Summary:

  • Register new OrganizationAffiliation viewset
  • Add new class OrganizationAffiliationSerializer
  • Add new OrganizationAffiliation viewset class and create query of the Organization table with all the neccessary data attached or annotated with subqueries
  • Add new helper class FHIROrganizationSource that acts as an interface so that EHRVendor objects can be treated as Organizations for the purpose of serialization
  • Edit the Organization viewset to also query EHRVendors
  • Alter the Organization viewset to apply filtersets manually separately to orgs and ehrvendor objects
  • Add an ehr_vendor_filterset file to apply the same filters that orgs can have to EHRVendors
  • Add each retrieved record as a list of FHIROrganizationSource objects and then sort based on name by default or the param processed by ParamOrderingFilter
  • Edit the OrganizationSerializer to also support EHRVendor data.

Test Plan

make test

…erializer

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
@IsaacMilarky IsaacMilarky marked this pull request as ready for review December 19, 2025 18:45
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Collaborator

@sachin-panayil sachin-panayil left a comment

Choose a reason for hiding this comment

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

the tests pass but im not getting anything back when i hit the API. im assuming its because their isnt proper data in the db for this endpoint? once this is confirmed and playwright tests pass, i can approve. everything else LGTM

Copy link
Contributor

@spopelka-dsac spopelka-dsac left a comment

Choose a reason for hiding this comment

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

It will be easier to assess the rest of the changes once the test fixtures PR is landed, so that this diff isn't so big. I'll provide further comments once that one is merged

IsaacMilarky and others added 4 commits January 6, 2026 13:07
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Contributor

@spopelka-dsac spopelka-dsac left a comment

Choose a reason for hiding this comment

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

@IsaacMilarky As I was digging into this PR review and the FHIR spec in more depth, I realized that I think I was incorrect in suggesting that ehr vendors should be listed as organizations at /Organization...

It seems cleaner and more sensible to represent the ehr vendors solely as references in the organization attribute on OrganizationAffiliation, represented not with a link to their Organization record, but rather like so:

'organization': {
                               'display': <ehr_vendor.name>
                          }

SO I think we should actually strip out the (very awesome) work that you did to display organizations and EHR vendors at /organization and simplify the logic to populate the organization attribute on OrganizationAffiliation as sown above.

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
@IsaacMilarky
Copy link
Collaborator Author

@IsaacMilarky As I was digging into this PR review and the FHIR spec in more depth, I realized that I think I was incorrect in suggesting that ehr vendors should be listed as organizations at /Organization...

It seems cleaner and more sensible to represent the ehr vendors solely as references in the organization attribute on OrganizationAffiliation, represented not with a link to their Organization record, but rather like so:

'organization': {
                               'display': <ehr_vendor.name>
                          }

SO I think we should actually strip out the (very awesome) work that you did to display organizations and EHR vendors at /organization and simplify the logic to populate the organization attribute on OrganizationAffiliation as sown above.

Sounds good. I removed the ehr_vendor stuff and merged main into this branch. The EHR vendor info should already be populated in the organization field as you describe.

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Contributor

@spopelka-dsac spopelka-dsac left a comment

Choose a reason for hiding this comment

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

This is looking really good!! Just a few tweaks

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Contributor

@spopelka-dsac spopelka-dsac left a comment

Choose a reason for hiding this comment

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

Just a couple very minor changes and one note-to-self for later!

Signed-off-by: Isaac Milarsky <imilarsky@gmail.com>
Copy link
Contributor

@spopelka-dsac spopelka-dsac left a comment

Choose a reason for hiding this comment

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

NICE WORK!!!!!

@spopelka-dsac spopelka-dsac enabled auto-merge (squash) February 3, 2026 19:31
@spopelka-dsac
Copy link
Contributor

@IsaacMilarky Spell check FTW (although I would expect the Spellcheck action to fail or otherwise show as not passing; can you please look into that?). Can you please fix the misspelling that was found? https://github.com/CMS-Enterprise/npd/pull/270/changes#diff-ba0f542da241804f1315cde1680bcf5755df8b403860cc55a56089e20b48ed93R293

@IsaacMilarky IsaacMilarky merged commit 6ab7379 into main Feb 3, 2026
12 checks passed
@IsaacMilarky IsaacMilarky deleted the isaacmilarky/NDH-278-build-out-organization-affiliation-endpoint branch February 3, 2026 19:59
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