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

NIAD-3170: Generating acute MedicationRequest[intent=order] which share the same MedicationRequest[intent=plan] #821

Merged

Conversation

MartinWheelerMT
Copy link
Collaborator

@MartinWheelerMT MartinWheelerMT commented Sep 19, 2024

What

For every MedicationRequest[intent=plan] which is referenced via the basedOn field by multiple MedicationRequest[intent=order]s, the Adaptor will generate N new MedicationRequest[intent=plan], where N is the the total number of MedicationRequest[intent=order]s referencing the MedicationRequest[intent=plan] - 1.

The earliest (measured by the dispenseRequest.validityPeriod.startfield) MedicationRequest[intent=order] will keep its reference to the unmodified MedicationRequest[intent=plan]. For each subsequent Order, its basedOn will get updated to the generated version.

For each MedicationRequest[intent=plan] which is generated, it's fields will be copied from the original MedicationRequest[intent=plan]. With the following modifications:

  • A random UUID is generated for the id field.
  • priorPrescription - Is generated by finding the MedicationRequest[intent=plan]s whos closest but previous in time, using the dispenseRequest.validityPeriod.start field. Note that this field depends on the existance of other [intent=plan] to exist.
  • dispenseRequest.validityPeriod - Is generated by copying same field from over the MedicationRequest[intent=plan]

Why

When EMIS prescriptions are post-dated, multiple prescriptions are generated.
When a post-dated prescription is transferred from EMIS it contains multiple MedicationStatements with ehrSupplyPrescribe which point to a single ehrSupplyAuthorise.
The adaptor until now has had an assumption that each ehrSupplyAuthorise is only referenced by one ehrSupplyPrescribe.
The result of which is that the Adaptor is generating acute medications which don’t match up to a valid GP Connect representation of an acute medication.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Add Test to ensure that the correct number of medication request Orders and Plans are created when multiple supplyPrescribes reference the same supplyAuthorise
Add unit test source XML
Add functionality for the tests above
@MartinWheelerMT MartinWheelerMT changed the title NIAD-3170: Medication Request Orders and Plans not generated correctly NIAD-3170: Generating acute MedicationRequest[intent=order] which share the same MedicationRequest[intent=plan] Sep 19, 2024
Add Test to ensure a new `Plan` is not generated when the original `Plan` is not `Acute` (i.e. `Repeat`).
Update Test from previous commit to ensure that it generates and new `Plan` only when the original `Plan` is `Acute`.
Add / Rename test files for the above tests.
Add Test to ensure that the earliest `Order` references the original `Plan` when a new `Plan` is generated.
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3170-medication-request-order-share-the-same-plan branch from 74562ca to 22c8c22 Compare September 19, 2024 18:05
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3170-medication-request-order-share-the-same-plan branch from 39ebb04 to 028a2b3 Compare September 27, 2024 16:39
…s to point to the duplicated plan

Add functionality for a new id and identified to be updated for the newly generated plan
Add Tests for these
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3170-medication-request-order-share-the-same-plan branch from 028a2b3 to 6f18812 Compare September 27, 2024 16:48
…tion references are updated.

Added test for this functionality
Fix checkstyle issues
@MartinWheelerMT MartinWheelerMT force-pushed the niad-3170-medication-request-order-share-the-same-plan branch from 723e326 to 8b0761b Compare September 27, 2024 18:44
@MartinWheelerMT MartinWheelerMT marked this pull request as ready for review October 1, 2024 09:50
@martin-nhs martin-nhs self-requested a review October 1, 2024 09:53
Refactor large method into smaller parts
@MartinWheelerMT MartinWheelerMT enabled auto-merge (squash) October 1, 2024 14:25
@MartinWheelerMT MartinWheelerMT merged commit 19bb890 into main Oct 2, 2024
1 check passed
@MartinWheelerMT MartinWheelerMT deleted the niad-3170-medication-request-order-share-the-same-plan branch October 2, 2024 08:37
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