From 8a39da4e91f34817b7fd60cb09e37726a17bc58b Mon Sep 17 00:00:00 2001 From: TynerGjs <132295567+TynerGjs@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:51:26 -0500 Subject: [PATCH] - Added logs when MDM candidate search parameters are not defined and candidate search limit is exceeded. (#5446) - fixed extra indentation for example survivorship rule in quickstart.md --- ...ing-extra-logs-to-mdm-candidate-search-parameter.yaml | 4 ++++ .../ca/uhn/fhir/jpa/mdm/broker/MdmMessageHandler.java | 9 ++++++--- .../jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java | 3 ++- .../ca/uhn/fhir/jpa/mdm/svc/MdmCandidateSearchSvcIT.java | 2 +- .../ca/uhn/fhir/mdm/rules/config/MdmRuleValidator.java | 5 ++++- 5 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5445-adding-extra-logs-to-mdm-candidate-search-parameter.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5445-adding-extra-logs-to-mdm-candidate-search-parameter.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5445-adding-extra-logs-to-mdm-candidate-search-parameter.yaml new file mode 100644 index 00000000000..8c5542712aa --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5445-adding-extra-logs-to-mdm-candidate-search-parameter.yaml @@ -0,0 +1,4 @@ +--- +type: fix +issue: 5445 +title: "Added warnings when MDM candidate search parameters are not defined and candidate search limit is exceeded." diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/broker/MdmMessageHandler.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/broker/MdmMessageHandler.java index fd829d2eb3c..32d51dec50d 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/broker/MdmMessageHandler.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/broker/MdmMessageHandler.java @@ -87,9 +87,6 @@ public class MdmMessageHandler implements MessageHandler { if (toProcess) { matchMdmAndUpdateLinks(sourceResource, msg); } - } catch (TooManyCandidatesException e) { - ourLog.error(e.getMessage(), e); - // skip this one with an error message and continue processing } catch (Exception e) { ourLog.error("Failed to handle MDM Matching Resource:", e); throw e; @@ -123,6 +120,12 @@ public class MdmMessageHandler implements MessageHandler { ourLog.trace("Not processing modified message for {}", theMsg.getOperationType()); } } catch (Exception e) { + if (e instanceof TooManyCandidatesException) { + ourLog.debug( + "Failed to handle MDM Matching for resource: {} since candidate matches exceeded the " + + "candidate search limit", + theSourceResource.getIdElement()); + } log(mdmContext, "Failure during MDM processing: " + e.getMessage(), e); mdmContext.addTransactionLogMessage(e.getMessage()); } finally { diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java index aafdff442c6..e3a7a5e72d5 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java @@ -159,7 +159,8 @@ public class MdmCandidateSearchSvc { myCandidateSearcher.search(theResourceType, resourceCriteria, theRequestPartitionId); if (!bundleProvider.isPresent()) { throw new TooManyCandidatesException(Msg.code(762) + "More than " + myMdmSettings.getCandidateSearchLimit() - + " candidate matches found for " + resourceCriteria + ". Aborting mdm matching."); + + " candidate matches found for " + resourceCriteria + ". Aborting mdm matching. Updating the " + + "candidate search parameters is strongly recommended for better performance of MDM."); } List resources = bundleProvider.get().getAllResources(); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmCandidateSearchSvcIT.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmCandidateSearchSvcIT.java index f27af6f4e6f..ad3487528f5 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmCandidateSearchSvcIT.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmCandidateSearchSvcIT.java @@ -149,7 +149,7 @@ public class MdmCandidateSearchSvcIT extends BaseMdmR4Test { myMdmCandidateSearchSvc.findCandidates("Patient", newJane, RequestPartitionId.allPartitions()); fail(); } catch (TooManyCandidatesException e) { - assertEquals("HAPI-0762: More than 3 candidate matches found for Patient?identifier=http%3A%2F%2Fa.tv%2F%7CID.JANE.123&active=true. Aborting mdm matching.", e.getMessage()); + assertEquals("HAPI-0762: More than 3 candidate matches found for Patient?identifier=http%3A%2F%2Fa.tv%2F%7CID.JANE.123&active=true. Aborting mdm matching. Updating the candidate search parameters is strongly recommended for better performance of MDM.", e.getMessage()); } } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/rules/config/MdmRuleValidator.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/rules/config/MdmRuleValidator.java index 3189d149783..83340958397 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/rules/config/MdmRuleValidator.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/rules/config/MdmRuleValidator.java @@ -136,7 +136,10 @@ public class MdmRuleValidator implements IMdmRuleValidator { private void validateSearchParams(MdmRulesJson theMdmRulesJson) { ourLog.info("Validating search parameters {}", theMdmRulesJson.getCandidateSearchParams()); - + if (theMdmRulesJson.getCandidateSearchParams().isEmpty()) { + ourLog.warn("No candidate search parameter was found. Defining candidate search parameter is strongly " + + "recommended for better performance of MDM"); + } for (MdmResourceSearchParamJson searchParams : theMdmRulesJson.getCandidateSearchParams()) { searchParams .iterator()