Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engagement/jessica/15896 radx mars deidentify #16192

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9c06530
Removing AOEs and updating condition filter to include RSV
JessicaWNava Aug 20, 2024
1dad44f
Merging changes
JessicaWNava Aug 20, 2024
d9a10fe
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Aug 22, 2024
2152c10
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Aug 28, 2024
f72074c
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Aug 29, 2024
e6cebab
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Sep 4, 2024
aee1237
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Sep 4, 2024
468a6bf
Added the ability to specify the receiver settings for the fhirdata c…
JessicaWNava Sep 5, 2024
d4bc0ea
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Sep 6, 2024
dacd169
Made the receiver schema optional if the receiver is specified.
JessicaWNava Sep 6, 2024
56e1c19
Checking the receiver for their format and using it. if applicable. A…
JessicaWNava Sep 9, 2024
c10e62b
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Sep 9, 2024
5edf297
Merge branch 'master' of https://github.com/CDCgov/prime-reportstream
JessicaWNava Sep 11, 2024
5ff2c70
Merging changes from master
JessicaWNava Sep 11, 2024
5ce9d21
Merging changes from master
JessicaWNava Sep 11, 2024
080d9a9
Adding in validation for filters as well as applying those filters to…
JessicaWNava Sep 12, 2024
56d0453
Doing cleanupas well as tested that conditions are removed
JessicaWNava Sep 13, 2024
ecfbc92
Missed removing the conditions in branching logic. Fixing how the fil…
JessicaWNava Sep 17, 2024
00b18e0
Updated the code to handle returning all of the filter errors at once…
JessicaWNava Sep 17, 2024
25b59ac
Doing cleanup, adding tests
JessicaWNava Sep 18, 2024
507f2dd
Got the API working
JessicaWNava Sep 19, 2024
211a64c
Merging changes from master
JessicaWNava Sep 19, 2024
72847d4
Merge branch 'engagement/jessica/15542-evaluate-filters' into engagem…
JessicaWNava Sep 19, 2024
f158641
Trying to get the warnings and errors working
JessicaWNava Sep 30, 2024
8e44e56
Working on a different route
JessicaWNava Oct 1, 2024
e917886
As far as I can get with changes and have the message still work
JessicaWNava Oct 2, 2024
c5a874d
As far as I can get with changes and have the message still work
JessicaWNava Oct 2, 2024
16facbf
Cleanup
JessicaWNava Oct 2, 2024
79de95a
Merging master
JessicaWNava Oct 2, 2024
5984564
Added errors and warnings to constructor
victor-chaparro Oct 2, 2024
504ae1f
Changing errors and warnings
JessicaWNava Oct 2, 2024
c5d7496
Fixing the unit tests
JessicaWNava Oct 2, 2024
5a0e68a
Rolling back mistaken changes
JessicaWNava Oct 2, 2024
4fa357f
Addressing PR feedback and testing when what is returned is a bundle …
JessicaWNava Oct 3, 2024
1b1d56e
Fixing bugs from when running the cli
JessicaWNava Oct 3, 2024
01d607e
Making requested changes
JessicaWNava Oct 4, 2024
cdbcd88
Updating the radx mars deidentification transform
JessicaWNava Oct 8, 2024
4b68448
More changes
JessicaWNava Oct 9, 2024
35130c0
Updating the correct file this time
JessicaWNava Oct 10, 2024
4d18a79
Merge branch 'master' into engagement/jessica/15896-radx-mars-deidentify
JessicaWNava Oct 10, 2024
2b6aa08
Updating the integration test and fixing an error
JessicaWNava Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions prime-router/docs/api/reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,51 @@ paths:
$ref: '#/components/schemas/Report'
'500':
description: Internal Server Error
/reports/testing/test:
post:
summary: Evaluates a message based off of the receiver settings specified. Returns any errors, filtering, or the message.
security:
- OAuth2: [ system_admin ]
parameters:
- in: query
name: receiverName
description: The name of the receiver to look for in the current environment's settings
schema:
type: string
required: true
example: full-elr
- in: query
name: organizationName
description: The name of the organization to look for the receiver in the current environment's settings
required: true
schema:
type: string
example: me-phd
- in: query
name: senderSchema
description: The path to the sender schema
required: false
schema:
type: string
example: classpath:/metadata/fhir_transforms/senders/SimpleReport/simple-report-sender-transform.yml
requestBody:
description: The message to process
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Report'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Report'
'400':
description: Error with one or more filters or finding the receiver.
'500':
description: Internal Server Error
/reports/download:
get:
summary: Downloads a message based on the report id
Expand Down
71 changes: 70 additions & 1 deletion prime-router/src/main/kotlin/azure/ReportFunction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gov.cdc.prime.router.azure
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.github.ajalt.clikt.core.CliktError
import com.google.common.net.HttpHeaders
import com.microsoft.azure.functions.HttpMethod
import com.microsoft.azure.functions.HttpRequestMessage
Expand All @@ -23,7 +24,6 @@ import gov.cdc.prime.router.Sender
import gov.cdc.prime.router.Sender.ProcessingType
import gov.cdc.prime.router.SubmissionReceiver
import gov.cdc.prime.router.UniversalPipelineReceiver
import gov.cdc.prime.router.azure.BlobAccess.Companion.defaultBlobMetadata
import gov.cdc.prime.router.azure.BlobAccess.Companion.getBlobContainer
import gov.cdc.prime.router.azure.db.enums.TaskAction
import gov.cdc.prime.router.azure.db.tables.pojos.ReportFile
Expand All @@ -32,6 +32,7 @@ import gov.cdc.prime.router.azure.observability.event.ReportStreamEventName
import gov.cdc.prime.router.azure.observability.event.ReportStreamEventProperties
import gov.cdc.prime.router.azure.observability.event.ReportStreamEventService
import gov.cdc.prime.router.cli.PIIRemovalCommands
import gov.cdc.prime.router.cli.ProcessFhirCommands
import gov.cdc.prime.router.common.AzureHttpUtils.getSenderIP
import gov.cdc.prime.router.common.Environment
import gov.cdc.prime.router.common.JacksonMapperUtilities
Expand All @@ -43,6 +44,7 @@ import gov.cdc.prime.router.tokens.authenticationFailure
import gov.cdc.prime.router.tokens.authorizationFailure
import kotlinx.serialization.json.Json
import org.apache.logging.log4j.kotlin.Logging
import java.io.File
import java.nio.charset.StandardCharsets
import java.util.UUID

Expand Down Expand Up @@ -120,6 +122,73 @@ class ReportFunction(
return HttpUtilities.unauthorizedResponse(request)
}

/**
* Run a message through the fhirdata cli
*
* @see ../../../docs/api/reports.yml
*/
@FunctionName("processFhirDataRequest")
fun processFhirDataRequest(
@HttpTrigger(
name = "processFhirDataRequest",
methods = [HttpMethod.POST],
authLevel = AuthorizationLevel.ANONYMOUS,
route = "reports/testing/test"
) request: HttpRequestMessage<String?>,
): HttpResponseMessage {
val claims = AuthenticatedClaims.authenticate(request)
if (claims != null && claims.authorized(setOf(Scope.primeAdminScope))) {
val receiverName = request.queryParameters["receiverName"]
val organizationName = request.queryParameters["organizationName"]
val senderSchema = request.queryParameters["senderSchema"]
if (receiverName.isNullOrBlank()) {
return HttpUtilities.badRequestResponse(
request,
"The receiver name is required"
)
}
if (organizationName.isNullOrBlank()) {
return HttpUtilities.badRequestResponse(
request,
"The organization name is required"
)
}
if (request.body.isNullOrBlank()) {
return HttpUtilities.badRequestResponse(
request,
"A message to process must be included in the body"
)
}
val file = File("filename.fhir")
file.createNewFile()
file.bufferedWriter().use { out ->
out.write(request.body)
}

try {
val result = ProcessFhirCommands().processFhirDataRequest(
file,
Environment.get().envName,
receiverName,
organizationName,
senderSchema,
false
)
file.delete()
return HttpUtilities.okResponse(
request,
ObjectMapper().writeValueAsString(
result
)
)
} catch (exception: CliktError) {
file.delete()
return HttpUtilities.badRequestResponse(request, "${exception.message}")
}
}
return HttpUtilities.unauthorizedResponse(request)
}

/**
* Moved the logic to a separate function for testing purposes
*/
Expand Down
Loading
Loading