Skip to content

Use $match in Patient Discovery if enabled #736

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

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

robertandremitchell
Copy link
Collaborator

@robertandremitchell robertandremitchell commented Jul 14, 2025

PULL REQUEST

Summary

Adds a $match function to use if the FHIR server supports $match and it is enabled as an alternative patient search method.

As of now, Epic is the only server we have that supports this, which has some different protocols here for us to test: https://fhir.epic.com/Specifications?api=10423

There is a frontend /query method for enabling patient match protocol if the server does support $match (otherwise the checkbox does not render). Toggling the /query checkbox only impacts that specific run of the query. Otherwise, edit the /fhirServers entry.

The frontend of that patientMatchConfiguration is significantly more streamlined in v4 and v5 of $match; we only need onlyCertainMatches to be true for $match to work. If so, we have an optional matchCount param. However, I've found that the count does not seem to be operationalized on Epic so it has not fully been tested. v6 params are still present as some degree of future-proofing but we as of now don't know a partner on v6, which has the onlySingleMatch workflow.

Patient request configuration {
  firstName: 'Hyper',
  lastName: 'Unlucky',
  dob: '1975-12-06',
  mrn: '8692756',
  fhirServer: 'Epic Server',
  phone: '5174251398',
  email: '[email protected]',
  address: {
    street1: '49 Meadow St',
    street2: '',
    city: 'Lansing',
    state: 'MI',
    zip: '48864'
  },
  patientMatchConfiguration: {
    enabled: true,
    onlySingleMatch: false,
    onlyCertainMatches: true,
    matchCount: 10,
    supportsMatch: true
  }
}
makePatientMatchRequest audit action with id f8b49a6a-9987-4dcb-b032-e7c4f489593e and checksum c8a5702f0fc3f7d53e4e0c42cd4fb824ac494eaf209a9652c5fd888c8aa29f5b added to audit table
 POST /query 200 in 365ms
 POST /query 200 in 205ms
 POST /query 200 in 99ms
Patient request configuration {
  firstName: 'hyper',
  lastName: 'unlucky',
  dob: '1975-12-06',
  mrn: '',
  fhirServer: 'Epic Server',
  phone: '',
  email: '[email protected]',
  address: { street1: '', street2: '', city: '', state: '', zip: '' },
  patientMatchConfiguration: {
    enabled: false,
    onlySingleMatch: false,
    onlyCertainMatches: true,
    matchCount: 10,
    supportsMatch: true
  }
}
makePatientDiscoveryRequest audit action with id 6922747a-93a2-48af-b2d4-78f86c594b31 and checksum 637e0b2382d3c80ee5c66ade074d216d019b8e8f7db95590978bb4aec3141fef added to audit table

Related Issue

Fixes #294

Additional Information

Creds to test epic (also available on queryconnector.dev):
Screenshot 2025-07-25 at 10 50 51 AM

To test NoCertainPatientMatch, enter: Hyper, Unlucky, 12-6-1975, [email protected].

Checklist

  • Descriptive Pull Request title
  • Link to relevant issues
  • Provide necessary context for design reviewers
  • Ensure test coverage is above agreed upon threshold
  • Update documentation

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 2.63158% with 74 lines in your changes missing coverage. Please review.

Project coverage is 65.22%. Comparing base (0bbbc71) to head (a89ab64).

Files with missing lines Patch % Lines
src/app/backend/query-execution.ts 3.70% 52 Missing ⚠️
src/app/shared/fhirClient.ts 0.00% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #736      +/-   ##
==========================================
- Coverage   66.02%   65.22%   -0.80%     
==========================================
  Files         118      118              
  Lines        5834     5907      +73     
  Branches     1391     1451      +60     
==========================================
+ Hits         3852     3853       +1     
- Misses       1968     2039      +71     
- Partials       14       15       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robertandremitchell robertandremitchell requested review from fzhao99 and nickclyde and removed request for fzhao99 July 25, 2025 17:41
@robertandremitchell robertandremitchell marked this pull request as ready for review July 25, 2025 17:41
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.

Switch to $match for patient discovery rather than patient search
2 participants