Skip to content

Commit

Permalink
feat(ihe): use sub req id for storing dr resposnes
Browse files Browse the repository at this point in the history
Refs: #1667
Signed-off-by: Jonah Kaye <[email protected]>
  • Loading branch information
jonahkaye committed Jun 21, 2024
1 parent d5ecf28 commit e2d12b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ it("should construct the correct file path for type 'dr' with index", async () =
const requestId = "requestId";
const oid = "oid";
const timestamp = "2024-05-01T00:00:00";
const index = 1;
const key = buildIheResponseKey({
type: "dr",
cxId,
patientId,
requestId,
oid,
timestamp,
index,
subRequestId: "subRequestId",
});
expect(key).toEqual(`${cxId}/${patientId}/dr/${requestId}_2024-05-01/${oid}_1.xml`);
expect(key).toEqual(`${cxId}/${patientId}/dr/${requestId}_2024-05-01/${oid}_subRequestId.xml`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ export async function storeDrResponse({
response,
outboundRequest,
gateway,
index,
subRequestId,
}: {
response: Buffer;
outboundRequest: OutboundDocumentRetrievalReq;
gateway: XCAGateway;
index: number;
subRequestId?: string | undefined;
}) {
try {
if (!bucket) {
Expand All @@ -114,7 +114,7 @@ export async function storeDrResponse({
requestId,
oid: gateway.homeCommunityId,
timestamp,
index,
subRequestId,
});
await s3Utils.uploadFile({ bucket, key, file: response, contentType: "application/xml" });
} catch (error) {
Expand All @@ -129,17 +129,17 @@ export function buildIheResponseKey({
requestId,
oid,
timestamp,
index,
subRequestId,
}: {
type: "xcpd" | "dq" | "dr";
cxId: string;
patientId: string;
requestId: string;
oid: string;
timestamp: string;
index?: number;
subRequestId?: string | undefined;
}) {
const date = dayjs(timestamp).format("YYYY-MM-DD");
const indexPart = index ? `_${index}` : "";
return `${cxId}/${patientId}/${type}/${requestId}_${date}/${oid}${indexPart}.xml`;
const subRequestIdPart = subRequestId ? `_${subRequestId}` : "";
return `${cxId}/${patientId}/${type}/${requestId}_${date}/${oid}${subRequestIdPart}.xml`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function sendSignedDrRequest({
response: rawResponse,
outboundRequest: request.outboundRequest,
gateway: request.gateway,
index,
subRequestId: request.outboundRequest.subRequestId,
});
return {
gateway: request.gateway,
Expand Down

0 comments on commit e2d12b4

Please sign in to comment.