From c0d2f72a8169cc73f83fe45c797fc7b6996afcaf Mon Sep 17 00:00:00 2001 From: Rafael Leite <2132564+leite08@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:37:16 -0700 Subject: [PATCH] fix(core): inbound XCPD includes custodian Ref eng-454 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com> --- .../inbound/xcpd/create/xcpd-response.ts | 16 +++++++++++++ ...he-gateway-v2-inbound-patient-discovery.ts | 24 +++++++++---------- packages/utils/package.json | 2 +- packages/utils/src/saml/mock-ihe-gateway.ts | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts b/packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts index c9f81714c9..d2c21f3704 100644 --- a/packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts +++ b/packages/core/src/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response.ts @@ -151,6 +151,22 @@ function createSubjectAndRegistrationEvent(response: InboundPatientDiscoveryResp }, }, }, + custodian: { + "@_typeCode": "CST", + assignedCustodian: { + "@_typeCode": "CST", + }, + assignedEntity: { + "@_classCode": "ASSIGNED", + id: { + "@_root": METRIPORT_HOME_COMMUNITY_ID_NO_PREFIX, + }, + code: { + "@_code": "NotHealthDataLocator", + "@_codeSystem": "1.3.6.1.4.1.19376.1.2.27.2", + }, + }, + }, }, }; return subject; diff --git a/packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts b/packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts index 658ec40ba3..ec2eff1e6b 100644 --- a/packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts +++ b/packages/lambdas/src/ihe-gateway-v2-inbound-patient-discovery.ts @@ -1,17 +1,18 @@ -import { APIGatewayProxyEventV2 } from "aws-lambda"; +import { analyticsAsync, EventTypes } from "@metriport/core/external/analytics/posthog"; +import { getSecretValue } from "@metriport/core/external/aws/secret-manager"; +import { createInboundXcpdResponse } from "@metriport/core/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response"; +import { processInboundXcpdRequest } from "@metriport/core/external/carequality/ihe-gateway-v2/inbound/xcpd/process/xcpd-request"; +import { processInboundXcpd } from "@metriport/core/external/carequality/pd/process-inbound-pd"; +import { InboundMpiMetriportApi } from "@metriport/core/mpi/inbound-patient-mpi-metriport-api"; +import { getEnvVar, getEnvVarOrFail } from "@metriport/core/util/env-var"; +import { out } from "@metriport/core/util/log"; import { InboundPatientDiscoveryReq, InboundPatientDiscoveryResp, } from "@metriport/ihe-gateway-sdk"; import { errorToString } from "@metriport/shared"; -import { processInboundXcpdRequest } from "@metriport/core/external/carequality/ihe-gateway-v2/inbound/xcpd/process/xcpd-request"; -import { processInboundXcpd } from "@metriport/core/external/carequality/pd/process-inbound-pd"; -import { createInboundXcpdResponse } from "@metriport/core/external/carequality/ihe-gateway-v2/inbound/xcpd/create/xcpd-response"; -import { InboundMpiMetriportApi } from "@metriport/core/mpi/inbound-patient-mpi-metriport-api"; -import { getEnvVarOrFail, getEnvVar } from "@metriport/core/util/env-var"; -import { getSecretValue } from "@metriport/core/external/aws/secret-manager"; -import { analyticsAsync, EventTypes } from "@metriport/core/external/analytics/posthog"; -import { out } from "@metriport/core/util/log"; +import { APIGatewayProxyEventV2 } from "aws-lambda"; +import { capture } from "./shared/capture"; import { getEnvOrFail } from "./shared/env"; const apiUrl = getEnvVarOrFail("API_URL"); @@ -23,8 +24,7 @@ const lambdaName = getEnvOrFail("AWS_LAMBDA_FUNCTION_NAME"); const mpi = new InboundMpiMetriportApi(apiUrl); const { log } = out(`ihe-gateway-v2-inbound-patient-discovery`); -// TODO move to capture.wrapHandler() -export async function handler(event: APIGatewayProxyEventV2) { +export const handler = capture.wrapHandler(async (event: APIGatewayProxyEventV2) => { try { if (!event.body) return buildResponse(400, { message: "The request body is empty" }); @@ -68,7 +68,7 @@ export async function handler(event: APIGatewayProxyEventV2) { log(`${msg}: ${errorToString(error)}`); return buildResponse(500, "Internal Server Error"); } -} +}); function buildResponse(status: number, body: unknown) { return { diff --git a/packages/utils/package.json b/packages/utils/package.json index db61a58570..7ab7befbbf 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -24,7 +24,7 @@ "create-medical-records": "ts-node src/customer-requests/medical-records-create", "get-consolidated": "ts-node src/customer-requests/get-consolidated", "download-docs": "ts-node src/customer-requests/download-docs", - "mock-ihe-gateway": "ts-node src/carequality/mock-ihe-gateway", + "mock-ihe-gateway": "ts-node src/saml/mock-ihe-gateway", "integration-test-and-compare-total-resource-counts": "bash src/fhir-converter/scripts/run_integration_and_compare.sh", "compare-total-resource-counts": "bash src/fhir-converter/scripts/compare_total_resource_counts.sh", "compare-resource-counts-per-file": "bash src/fhir-converter/scripts/compare_resource_counts_per_file.sh", diff --git a/packages/utils/src/saml/mock-ihe-gateway.ts b/packages/utils/src/saml/mock-ihe-gateway.ts index 03ab6f7e5e..b3bc8e4242 100644 --- a/packages/utils/src/saml/mock-ihe-gateway.ts +++ b/packages/utils/src/saml/mock-ihe-gateway.ts @@ -21,7 +21,7 @@ const mpi = new InboundMpiMetriportApi(apiUrl); const app: Application = express(); -app.use(express.raw({ type: "application/soap+xml", limit: "2mb" })); +app.use(express.raw({ type: ["application/soap+xml", "application/xml", "text/xml"] })); app.post("/v1/patient-discovery", async (req: Request, res: Response) => { try {