Skip to content

Commit

Permalink
Update original MedicationStatement lastIssueDate for multiple acute med
Browse files Browse the repository at this point in the history
When an accute med has multiple issues, we generate individual plan/statement
for each order.

This updates the original statements lastIssueDate to correspond to the
date on its corresponding MedicationRequest[order].

Previously the lastIssueDate was the most recent date of all the orders.
  • Loading branch information
adrianclay committed Oct 11, 2024
1 parent 6456f68 commit 81cf50f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ private void generateResourcesForMultipleOrdersLinkedToASingleAcutePlan(ArrayLis
resources.add(duplicatedPlan);
resources.add(duplicatedMedicationStatement);
}

final var originalMedicationStatement = getMedicationStatementByPlanId(medicationStatements, plan.getId());
originalMedicationStatement.getExtensionByUrl(MEDICATION_STATEMENT_LAST_ISSUE_DATE_URL).setValue(
orders.get(0).getDispenseRequest().getValidityPeriod().getStartElement()
);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,19 @@ void expectGeneratedMedicationStatementLastIssueDateExtensionSetToValidityPeriod
.isEqualTo(latestOrder.getDispenseRequest().getValidityPeriod().getStartElement());
}

@Test
void expectOriginalMedicationStatementLastIssueDateExtensionSetToValidityPeriodStart() {
var resources = medicationRequestMapper
.mapResources(ehrExtract, (Patient) new Patient().setId(PATIENT_ID), List.of(), PRACTISE_CODE
);

var earliestOrder = getMedicationRequestById(resources, EARLIEST_ORDER_ID);
var originalMedicationStatement = getMedicationStatementById(resources, INITIAL_MEDICATION_STATEMENT_ID);

assertThat(originalMedicationStatement.getExtensionByUrl(MEDICATION_STATEMENT_LAST_ISSUE_DATE_URL).getValue())
.isEqualTo(earliestOrder.getDispenseRequest().getValidityPeriod().getStartElement());
}

@Test
void expectOriginalMedicationStatementUnchangedPropertiesAreCopiedToGeneratedMedicationStatement() {
var resources = medicationRequestMapper
Expand Down

0 comments on commit 81cf50f

Please sign in to comment.