Skip to content

Commit

Permalink
Fix test event survey data after AOE correction (#7904)
Browse files Browse the repository at this point in the history
* Fix test event correction constructor

* Add aoe corrections test
  • Loading branch information
mpbrown authored Jul 11, 2024
1 parent 7c52cdc commit 748b999
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public TestEvent(
this.patientData = event.getPatientData();
this.providerData = event.getProviderData();
this.order = order;
this.surveyData = event.getSurveyData();
this.surveyData = order.getAskOnEntrySurvey().getSurvey();
setDateTestedBackdate(order.getDateTestedBackdate());
this.priorCorrectedTestEventId = event.getInternalId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,53 @@ void correctionsTest() {
verify(testEventReportingService, times(0)).report(e);
}

@Test
@WithSimpleReportOrgAdminUser
void aoeCorrectionsTest() {
Organization org = _organizationService.getCurrentOrganization();
Facility facility = _organizationService.getFacilities(org).get(0);
facility.setDefaultDeviceTypeSpecimenType(
_dataFactory.getGenericDevice(), _dataFactory.getGenericSpecimen());
Person p = _dataFactory.createFullPerson(org);
AskOnEntrySurvey survey =
new AskOnEntrySurvey("77386006", null, Map.of("fake", true), false, null, null);
TestOrder order = _dataFactory.createTestOrder(p, facility, survey);
TestEvent testEvent = _dataFactory.createTestEvent(order);

// pregnancy marked as Yes on test event
assertEquals("77386006", testEvent.getSurveyData().getPregnancy());

String reasonMsg = "Testing AOE correction " + LocalDateTime.now();
TestEvent originalEvent = _service.markAsCorrection(testEvent.getInternalId(), reasonMsg);
TestOrder updatedOrder = originalEvent.getTestOrder();

// now mark pregnancy as No
_service.updateAoeQuestions(p.getInternalId(), "60001007", null, null, null, null, null);
assertEquals("60001007", updatedOrder.getAskOnEntrySurvey().getSurvey().getPregnancy());

assertEquals(TestCorrectionStatus.CORRECTED, updatedOrder.getCorrectionStatus());
assertEquals(reasonMsg, updatedOrder.getReasonForCorrection());
assertEquals(testEvent.getInternalId(), updatedOrder.getTestEvent().getInternalId());
assertEquals(OrderStatus.PENDING, updatedOrder.getOrderStatus());

List<MultiplexResultInput> results =
originalEvent.getResults().stream()
.map(r -> new MultiplexResultInput(r.getDisease().getName(), r.getTestResult()))
.toList();

// submit queue item
AddTestResultResponse response =
_service.addMultiplexResult(
facility.getDefaultDeviceType().getInternalId(),
facility.getDefaultSpecimenType().getInternalId(),
results,
p.getInternalId(),
originalEvent.getDateTested());

// pregnancy is marked as No on test event
assertEquals("60001007", response.getTestOrder().getTestEvent().getSurveyData().getPregnancy());
}

@Test
@WithSimpleReportOrgAdminUser
void markAsErrorTest_backwardCompatible() {
Expand Down

0 comments on commit 748b999

Please sign in to comment.