Skip to content

Commit

Permalink
CNDE-1403: Post-processing integration for LAB100 and LAB101 datamarts (
Browse files Browse the repository at this point in the history
  • Loading branch information
sveselev authored Oct 30, 2024
1 parent 0ea1b11 commit 97bfb50
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public interface PostProcRepository extends JpaRepository<PostProcSp, Long> {

@Procedure("sp_d_labtest_result_postprocessing")
void executeStoredProcForLabTestResult(@Param("observationUids") String observationUids);

@Procedure("sp_lab100_datamart_postprocessing")
void executeStoredProcForLab100Datamart(@Param("observationUids") String observationUids);

@Procedure("sp_lab101_datamart_postprocessing")
void executeStoredProcForLab101Datamart(@Param("observationUids") String observationUids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ protected void processCachedIds() {
postProcRepository::executeStoredProcForLabTest, "sp_d_lab_test_postprocessing");
processTopic(keyTopic, entity.getName(), labIds,
postProcRepository::executeStoredProcForLabTestResult, "sp_d_labtest_result_postprocessing");

processTopic(keyTopic, entity.getName(), labIds,
postProcRepository::executeStoredProcForLab100Datamart, "sp_lab100_datamart_postprocessing");
processTopic(keyTopic, entity.getName(), labIds,
postProcRepository::executeStoredProcForLab101Datamart, "sp_lab101_datamart_postprocessing");
}
break;
default:
Expand Down Expand Up @@ -312,13 +317,14 @@ private String extractValFromMessage(String topic, String payload) {
}
} else if (topic.endsWith(Entity.OBSERVATION.getName())) {
String domainCd = objectMapper.readTree(payload).get(PAYLOAD).path("obs_domain_cd_st_1").asText();
String ctrlCd = objectMapper.readTree(payload).get(PAYLOAD).path("ctrl_cd_display_form").asText();
String ctrlCd = Optional.ofNullable(objectMapper.readTree(payload).get(PAYLOAD).get("ctrl_cd_display_form"))
.filter(node -> !node.isNull()).map(JsonNode::asText).orElse(null);

if (MORB_REPORT.equals(ctrlCd)) {
if ("Order".equals(domainCd)) {
return ctrlCd;
}
} else if (assertMatches(ctrlCd, LAB_REPORT, LAB_REPORT_MORB) &&
} else if (assertMatches(ctrlCd, LAB_REPORT, LAB_REPORT_MORB, null) &&
assertMatches(domainCd, "Order", "Result", "R_Order", "R_Result", "I_Order", "I_Result", "Order_rslt")) {
return LAB_REPORT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ void testPostProcessObservationMorb() {
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"Result\",\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"R_Order\",\"ctrl_cd_display_form\": \"LabReportMorb\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"R_Result\",\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"I_Order\",\"ctrl_cd_display_form\": null}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"I_Result\",\"ctrl_cd_display_form\": null}}'"
})
void testPostProcessObservationLab(String payload) {
String topic = "dummy_observation";
Expand All @@ -250,11 +252,12 @@ void testPostProcessObservationLab(String payload) {
verify(postProcRepositoryMock).executeStoredProcForLabTest(expectedObsIdsString);
verify(postProcRepositoryMock).executeStoredProcForLabTestResult(expectedObsIdsString);
List<ILoggingEvent> logs = listAppender.list;
assertEquals(6, logs.size());
assertEquals(10, logs.size());
assertTrue(logs.get(2).getFormattedMessage().contains("sp_d_lab_test_postprocessing"));
assertTrue(logs.get(3).getMessage().contains(PostProcessingService.SP_EXECUTION_COMPLETED));
assertTrue(logs.get(4).getFormattedMessage().contains("sp_d_labtest_result_postprocessing"));
assertTrue(logs.get(5).getMessage().contains(PostProcessingService.SP_EXECUTION_COMPLETED));
assertTrue(logs.get(6).getFormattedMessage().contains("sp_lab100_datamart_postprocessing"));
assertTrue(logs.get(8).getFormattedMessage().contains("sp_lab101_datamart_postprocessing"));
assertTrue(logs.get(9).getMessage().contains(PostProcessingService.SP_EXECUTION_COMPLETED));
}

@ParameterizedTest
Expand All @@ -263,8 +266,7 @@ void testPostProcessObservationLab(String payload) {
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"Order\",\"ctrl_cd_display_form\": \"NoReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"NoOrderOrResult\",\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": null,\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"C_Result\",\"ctrl_cd_display_form\": \"LabComment\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"Result\",\"ctrl_cd_display_form\": null}}'"
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"C_Result\",\"ctrl_cd_display_form\": \"LabComment\"}}'"
})
void testPostProcessObservationNoReport(String payload) {
String topic = "dummy_observation";
Expand Down Expand Up @@ -406,6 +408,7 @@ void testProduceDatamartTopicWithNoPatient() {

@ParameterizedTest
@CsvSource({
"'{\"payload\":{\"public_health_case_uid\":123,\"rdb_table_name_list\":null}}'",
"'{\"payload\":{\"patient_uid\":123}}'",
"'{\"payload\":{invalid}'"
})
Expand Down

0 comments on commit 97bfb50

Please sign in to comment.