Skip to content

[WIP] Otr 1007 merge patients#6656

Merged
VladMstv merged 15 commits intodevelopfrom
OTR-1007-move-encounter
Apr 15, 2026
Merged

[WIP] Otr 1007 merge patients#6656
VladMstv merged 15 commits intodevelopfrom
OTR-1007-move-encounter

Conversation

@VladMstv
Copy link
Copy Markdown
Collaborator

@VladMstv VladMstv commented Mar 23, 2026

  • Change patientIds prop type from string[] to [string, string] in PatientsMergeDifference.tsx to enforce the two-patient invariant at compile time

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds end-to-end patient merge capability across the backend (new merge-patients zambda + ops script), shared API types/client wiring, and EHR UI (duplicate detection, merge diff dialog, merged-record banner), with an integration test validating resource transfers.

Changes:

  • Introduces a new MERGE-PATIENTS zambda that transfers visits, clinical resources, patient-level records, billing resources, login phones, and deactivates the duplicate patient.
  • Adds EHR UI flows to detect potential duplicates, launch a merge diff dialog, and show a banner for merged/deactivated patients.
  • Adds a large integration test suite covering merge validations and verifying transfer of key resource types.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/zambdas/test/integration/merge-patients.test.ts New integration test validating merge behavior and transferred resources.
packages/zambdas/src/scripts/transfer-appointment-to-another-patient.ts New ops script for manually merging patient data (with dry-run).
packages/zambdas/src/ehr/merge-patients/index.ts New merge-patients http_auth zambda implementing merge + transfer logic.
packages/zambdas/package.json Adds npm script entry to run the new transfer/merge script.
packages/utils/lib/types/api/patient-account/index.ts Adds MergePatientsInput/Response API types.
config/oystehr-core/zambdas.json Registers MERGE-PATIENTS zambda for deployment/execution.
apps/ehr/src/pages/PatientPage.tsx Shows duplicate warning + merge action; hides main tabs when record is merged.
apps/ehr/src/pages/PatientInformationPage.tsx Adds merged-record banner to patient info page.
apps/ehr/src/hooks/useGetPatient.ts Adds duplicate patient detection + exposes duplicatePatients.
apps/ehr/src/features/visits/shared/hooks/useOystehrAPIClient.ts Wires merge-patients zambda ID into the API client.
apps/ehr/src/features/visits/shared/api/types.ts Adds mergePatientsZambdaID parameter.
apps/ehr/src/features/visits/shared/api/oystehrApi.ts Adds mergePatients() API wrapper and zambda mapping.
apps/ehr/src/components/patients-merge/PatientsMergeDifference.tsx Reworks merge diff UI to build QR from questionnaire and call backend merge.
apps/ehr/src/components/patients-merge/PatientsMergeButton.tsx Simplifies merge initiation UX (prompt for second PID).
apps/ehr/src/components/PatientMergedBanner.tsx New banner to redirect users to surviving patient record.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/zambdas/src/ehr/merge-patients/index.ts
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts
Comment thread apps/ehr/src/components/patients-merge/PatientsMergeDifference.tsx
Comment thread packages/zambdas/src/scripts/transfer-appointment-to-another-patient.ts Outdated
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts
Comment thread apps/ehr/src/hooks/useGetPatient.ts
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts Outdated
@VladMstv VladMstv changed the title [WIP] Otr 1007 move encounter [WIP] Otr 1007 merge patients Mar 26, 2026
…ter transfer, add audit log for merging patients, resolve other copilot comments
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/zambdas/src/ehr/merge-patients/index.ts Outdated
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts Outdated
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts
Comment thread apps/ehr/src/components/patients-merge/PatientsMergeDifference.tsx
Comment thread packages/zambdas/src/ehr/merge-patients/index.ts
VladMstv and others added 2 commits March 30, 2026 13:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Uladzislau <35751502+VladMstv@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Uladzislau <35751502+VladMstv@users.noreply.github.com>
… PatientsMergeDifference

Agent-Logs-Url: https://github.com/masslight/ottehr/sessions/320669e6-6844-4d12-81be-1b313c69e536

Co-authored-by: VladMstv <35751502+VladMstv@users.noreply.github.com>
@VladMstv VladMstv marked this pull request as ready for review April 1, 2026 15:00
@VladMstv VladMstv merged commit 0db678f into develop Apr 15, 2026
29 of 35 checks passed
@VladMstv VladMstv deleted the OTR-1007-move-encounter branch April 15, 2026 21:25
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