diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 841dd2b1a09..dcddd8b26a0 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -52,7 +52,7 @@ jobs: - name: "Get changed files with yaml" id: changed-files-yaml - uses: tj-actions/changed-files@6b2903bdce6310cfbddd87c418f253cf29b2dec9 + uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c with: files_yaml: | frontend: diff --git a/prime-router/docs/observability/azure-events.md b/prime-router/docs/observability/azure-events.md index aa0fc53e3ca..07fcbaaeb6a 100644 --- a/prime-router/docs/observability/azure-events.md +++ b/prime-router/docs/observability/azure-events.md @@ -254,3 +254,34 @@ customEvents | summarize count() by conditionDisplay | order by count_ ``` + +### List of items that were not routed where patient lived in state X +```kql +customEvents +| where name == "ITEM_NOT_ROUTED" +| extend params = parse_json(tostring(customDimensions.params)) +| where params.bundleDigest.patientState contains "X" +``` + +### List of items that failed a filter where patient lived in state X +```kql +customEvents +| where name == "ITEM_FILTER_FAILED" +| extend params = parse_json(tostring(customDimensions.params)) +| where params.bundleDigest.patientState contains "X" +``` + +### Find the original report ID for a report that failed a filter where patient lived in state X +```kql +customEvents +| where name == "REPORT_RECEIVED" +| extend reportId = tostring(customDimensions.childReportId) +| join ( + customEvents + | where name == "ITEM_FILTER_FAILED" + | extend params = parse_json(tostring(customDimensions.params)) + | where params.bundleDigest.patientState contains "X" + | extend submittedReportIds = parse_json(tostring(customDimensions.submittedReportIds)) + | mv-expand submittedReportIds + | project childReportId=tostring(submittedReportIds)) on $left.reportId == $right.childReportId +``` diff --git a/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt b/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt index 26b53b95086..04965dd20cf 100644 --- a/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt +++ b/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt @@ -7,6 +7,7 @@ import ca.uhn.hl7v2.util.Hl7InputStreamMessageStringIterator import ca.uhn.hl7v2.util.Hl7InputStreamMessageStringIterator.ParseFailureError import com.fasterxml.jackson.annotation.JsonProperty import com.google.common.collect.Streams +import fhirengine.engine.CustomFhirPathFunctions import fhirengine.engine.IProcessedItem import fhirengine.engine.ProcessedFHIRItem import fhirengine.engine.ProcessedHL7Item @@ -38,6 +39,7 @@ import gov.cdc.prime.router.azure.observability.event.ReportStreamEventName import gov.cdc.prime.router.azure.observability.event.ReportStreamEventProperties import gov.cdc.prime.router.fhirengine.translation.HL7toFhirTranslator import gov.cdc.prime.router.fhirengine.translation.hl7.FhirTransformer +import gov.cdc.prime.router.fhirengine.translation.hl7.utils.CustomContext import gov.cdc.prime.router.fhirengine.translation.hl7.utils.FhirPathUtils import gov.cdc.prime.router.fhirengine.utils.FhirTranscoder import gov.cdc.prime.router.fhirengine.utils.HL7Reader @@ -232,7 +234,14 @@ class FHIRConverter( actionHistory.trackCreatedReport(routeEvent, report, blobInfo = blobInfo) val bundleDigestExtractor = BundleDigestExtractor( - FhirPathBundleDigestLabResultExtractorStrategy() + FhirPathBundleDigestLabResultExtractorStrategy( + CustomContext( + bundle, + bundle, + mutableMapOf(), + CustomFhirPathFunctions() + ) + ) ) reportEventService.sendItemEvent( ReportStreamEventName.ITEM_ACCEPTED, @@ -241,6 +250,7 @@ class FHIRConverter( ) { parentReportId(queueMessage.reportId) parentItemIndex(itemIndex.toInt() + 1) + trackingId(bundle) params( mapOf( ReportStreamEventProperties.BUNDLE_DIGEST diff --git a/prime-router/src/main/kotlin/fhirengine/engine/FHIRDestinationFilter.kt b/prime-router/src/main/kotlin/fhirengine/engine/FHIRDestinationFilter.kt index 997acd01822..e9368aeec87 100644 --- a/prime-router/src/main/kotlin/fhirengine/engine/FHIRDestinationFilter.kt +++ b/prime-router/src/main/kotlin/fhirengine/engine/FHIRDestinationFilter.kt @@ -234,7 +234,14 @@ class FHIRDestinationFilter( actionHistory.trackCreatedReport(nextEvent, report) val bundleDigestExtractor = BundleDigestExtractor( - FhirPathBundleDigestLabResultExtractorStrategy() + FhirPathBundleDigestLabResultExtractorStrategy( + CustomContext( + bundle, + bundle, + mutableMapOf(), + CustomFhirPathFunctions() + ) + ) ) reportEventService.sendItemEvent( eventName = ReportStreamEventName.ITEM_NOT_ROUTED, @@ -242,6 +249,7 @@ class FHIRDestinationFilter( pipelineStepName = TaskAction.destination_filter ) { parentReportId(queueMessage.reportId) + trackingId(bundle) params( mapOf( ReportStreamEventProperties.BUNDLE_DIGEST diff --git a/prime-router/src/main/kotlin/fhirengine/engine/FHIRReceiverFilter.kt b/prime-router/src/main/kotlin/fhirengine/engine/FHIRReceiverFilter.kt index 809243299d6..a8efac86439 100644 --- a/prime-router/src/main/kotlin/fhirengine/engine/FHIRReceiverFilter.kt +++ b/prime-router/src/main/kotlin/fhirengine/engine/FHIRReceiverFilter.kt @@ -435,7 +435,14 @@ class FHIRReceiverFilter( actionHistory.trackCreatedReport(nextEvent, emptyReport) val bundleDigestExtractor = BundleDigestExtractor( - FhirPathBundleDigestLabResultExtractorStrategy() + FhirPathBundleDigestLabResultExtractorStrategy( + CustomContext( + bundle, + bundle, + mutableMapOf(), + CustomFhirPathFunctions() + ) + ) ) reportEventService.sendItemEvent( eventName = ReportStreamEventName.ITEM_FILTER_FAILED, diff --git a/prime-router/src/test/kotlin/fhirengine/azure/FHIRConverterIntegrationTests.kt b/prime-router/src/test/kotlin/fhirengine/azure/FHIRConverterIntegrationTests.kt index cb995649dc9..92b1bd6bad4 100644 --- a/prime-router/src/test/kotlin/fhirengine/azure/FHIRConverterIntegrationTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/azure/FHIRConverterIntegrationTests.kt @@ -337,7 +337,7 @@ class FHIRConverterIntegrationTests { 1, 2, 2, - null, + "371784", "phd.hl7-elr-no-transform" ) ) @@ -352,7 +352,7 @@ class FHIRConverterIntegrationTests { ) ), patientState = listOf("TX"), - orderingFacilityState = emptyList(), + orderingFacilityState = listOf("FL"), performerState = emptyList(), eventType = "ORU^R01^ORU_R01" ) @@ -491,7 +491,7 @@ class FHIRConverterIntegrationTests { 1, 3, 3, - null, + "1234d1d1-95fe-462c-8ac6-46728dbau8cd", "phd.fhir-elr-no-transform" ) ) diff --git a/prime-router/src/test/kotlin/fhirengine/azure/FHIRDestinationFilterIntegrationTests.kt b/prime-router/src/test/kotlin/fhirengine/azure/FHIRDestinationFilterIntegrationTests.kt index 2863f53857a..48cf6866681 100644 --- a/prime-router/src/test/kotlin/fhirengine/azure/FHIRDestinationFilterIntegrationTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/azure/FHIRDestinationFilterIntegrationTests.kt @@ -411,7 +411,7 @@ class FHIRDestinationFilterIntegrationTests : Logging { 1, 1, 1, - null, + "MT_COCNB_ORU_NBPHELR.1.5348467", "phd.Test Sender" ) ) @@ -422,7 +422,7 @@ class FHIRDestinationFilterIntegrationTests : Logging { eventType = "ORU/ACK - Unsolicited transmission of an observation message", patientState = listOf("CO"), performerState = emptyList(), - orderingFacilityState = emptyList() + orderingFacilityState = listOf("CO") ) ) ) diff --git a/prime-router/src/test/kotlin/fhirengine/azure/FHIRReceiverFilterIntegrationTests.kt b/prime-router/src/test/kotlin/fhirengine/azure/FHIRReceiverFilterIntegrationTests.kt index d798ac838f9..6bef75c0a42 100644 --- a/prime-router/src/test/kotlin/fhirengine/azure/FHIRReceiverFilterIntegrationTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/azure/FHIRReceiverFilterIntegrationTests.kt @@ -398,7 +398,7 @@ class FHIRReceiverFilterIntegrationTests : Logging { eventType = "ORU/ACK - Unsolicited transmission of an observation message", patientState = listOf("CA"), performerState = emptyList(), - orderingFacilityState = emptyList() + orderingFacilityState = listOf("CA") ), ReportStreamEventProperties.RECEIVER_NAME to receiver.fullName ) @@ -566,7 +566,7 @@ class FHIRReceiverFilterIntegrationTests : Logging { eventType = "ORU/ACK - Unsolicited transmission of an observation message", patientState = listOf("CA"), performerState = emptyList(), - orderingFacilityState = emptyList() + orderingFacilityState = listOf("CA") ), ReportStreamEventProperties.RECEIVER_NAME to receiver.fullName ) @@ -747,7 +747,7 @@ class FHIRReceiverFilterIntegrationTests : Logging { eventType = "ORU/ACK - Unsolicited transmission of an observation message", patientState = listOf("CA"), performerState = emptyList(), - orderingFacilityState = emptyList() + orderingFacilityState = listOf("CA") ), ReportStreamEventProperties.RECEIVER_NAME to receiver.fullName ) @@ -1121,7 +1121,7 @@ class FHIRReceiverFilterIntegrationTests : Logging { eventType = "ORU/ACK - Unsolicited transmission of an observation message", patientState = listOf("CO"), performerState = emptyList(), - orderingFacilityState = emptyList() + orderingFacilityState = listOf("CO") ), ReportStreamEventProperties.RECEIVER_NAME to receiver.fullName ) diff --git a/prime-router/src/test/kotlin/fhirengine/engine/FhirDestinationFilterTests.kt b/prime-router/src/test/kotlin/fhirengine/engine/FhirDestinationFilterTests.kt index 1b0e495e076..e998ed25ab2 100644 --- a/prime-router/src/test/kotlin/fhirengine/engine/FhirDestinationFilterTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/engine/FhirDestinationFilterTests.kt @@ -450,7 +450,7 @@ class FhirDestinationFilterTests { 1, 1, 1, - null, + "1234d1d1-95fe-462c-8ac6-46728dba581c", "sendingOrg.sendingOrgClient" ) ) @@ -509,7 +509,7 @@ class FhirDestinationFilterTests { ), patientState = listOf("CA"), performerState = emptyList(), - orderingFacilityState = emptyList(), + orderingFacilityState = listOf("CA"), eventType = "ORU/ACK - Unsolicited transmission of an observation message" ) )