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

fix(api): added patient matching on the outbound pd response #1743

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

RamilGaripov
Copy link
Contributor

@RamilGaripov RamilGaripov commented Mar 8, 2024

refs. metriport/metriport-internal#1350

Description

  • When PD completes, we check that the patient information from the gateways matches what we have on file for the CX patient entry to avoid cross-polination of patient data

Testing

  • Local
    • Tested this with Innovar and Epic:
      Results:
      - Innovar returns a patient with different demos -> no match and we don't DQ them
      - Epic returns correct demos -> match and successful DQ
    • Test with the other test partners
  • Production
    • ⚠️ Run a DQ for a real patient and see if the schemas work as expected

Release Plan

  • Release NPM packages
  • Merge this

@RamilGaripov RamilGaripov marked this pull request as ready for review March 8, 2024 02:03
Comment on lines +75 to +76
const results = await Promise.all(
pdResults.map(async pd => {
Copy link
Member

Choose a reason for hiding this comment

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

How may entries we might have on pdResults? We should probably use executeAsynchronously and limit to <20 queries to the DB in parallel?

baseErrorResponseSchema,
externalGatewayPatientSchema,
XCPDGatewaySchema,
} from "../shared";

// TODO: Test that this schema is correct for the patientResource in the IHE response
Copy link
Member

Choose a reason for hiding this comment

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

Is this a left-over or are you still testing this?

I was going to ask about name, to make sure the array is always present, but we should test all fields yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I was still testing it. Fixed in this PR - https://github.com/metriport/metriport/pull/1747/files

Comment on lines +102 to +103
if (!firstName || !lastName || !dob || !genderAtBirth) return;
if (!addresses.length) return;
Copy link
Member

Choose a reason for hiding this comment

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

If there's no address we don't want to store/use what we have?

And I'm assuming the other fields are required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, all those fields are required for patient matching

Comment on lines +92 to +98
return {
patientId: id,
systemId: system,
oid: pd.gateway.oid,
url,
id: pd.gateway.id,
};
Copy link
Member

Choose a reason for hiding this comment

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

We talked about storing the patient demographics returned w/ the link here, no? Or was it on the response table?

@RamilGaripov RamilGaripov marked this pull request as draft March 8, 2024 05:08
@@ -90,3 +91,44 @@ export interface Patient extends BaseDomain, PatientCreate {}
export function getStatesFromAddresses(patient: Patient): USState[] {
return patient.data.address.map(getState);
}

export function patientDataFromResource(patientResource: PatientResource): PatientData | undefined {
Copy link
Member

Choose a reason for hiding this comment

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

Only noticed this now: this function works w/ a type from the SDK, so in theory it should not be on the domain layer - reference.

A way to look into this is:

  • if something on the domain imports something from other places, then the domain depends on those;
  • the domain should have the least external dependencies as possible;
  • we can have folders for these external dependencies (its fine for them to depend on the domain).

We could store it on a folder like ./external/ihe-sdk/... or ./external/ihe/...

jonahkaye added a commit that referenced this pull request May 16, 2024
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.

None yet

2 participants