Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 11 additions & 14 deletions packages/getMyPrescriptions/src/getMyPrescriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ async function eventHandler(
): Promise<LambdaResult> {
const traceIDs: TraceIDs = logTraceIds(headers)
const spineClient = params.spineClient
const applicationName = headers["nhsd-application-name"] ?? "unknown"
const correlationId = headers["nhsd-correlation-id"] ?? crypto.randomUUID()

checkSpineCertificateConfiguration(spineClient)
Expand All @@ -93,7 +92,7 @@ async function eventHandler(

const response = await makeSpinePrescriptionCall(spineClient, headers, params)
const searchsetBundle: Bundle = response.data
logPrescriptionResponse(searchsetBundle, traceIDs, headers, applicationName)
logPrescriptionResponse(searchsetBundle, traceIDs, headers)

const statusUpdateData = includeStatusUpdateData ? buildStatusUpdateData(logger, searchsetBundle) : undefined

Expand Down Expand Up @@ -130,8 +129,7 @@ function logTraceIds(headers: EventHeaders) {
return traceIDs
}

function logPrescriptionResponse(searchsetBundle: Bundle,
traceIDs: TraceIDs, headers: EventHeaders, applicationName: string) {
function logPrescriptionResponse(searchsetBundle: Bundle, traceIDs: TraceIDs, headers: EventHeaders) {
searchsetBundle.id = traceIDs["x-request-id"] || "unknown"

const operationOutcomes = isolateOperationOutcome(searchsetBundle)
Expand All @@ -140,16 +138,15 @@ function logPrescriptionResponse(searchsetBundle: Bundle,
})

const ODSCodes = extractOdsCodes(logger, searchsetBundle)
logger.info(
"Processing PfP get prescriptions request for patient. "
+ "They have these relevant ODS codes, and the PfP request was made via this apigee application.",
{
ODSCodes,
actorNhsNumber: headers[NHS_LOGIN_HEADER],
subjectNhsNumber: headers["nhsNumber"],
applicationName
}
)
logger.info("Get prescriptions for patient response.", {
ODSCodes,
actorNhsNumber: headers[NHS_LOGIN_HEADER],
subjectNhsNumber: headers["nhsNumber"],
applicationName: headers["nhsd-application-name"] ?? "unknown",
applicationId: headers["nhsd-application-id"] ?? "unknown",
proxygenAppName: headers["developer.app.name"] ?? "unknown",
proxygenAppId: headers["developer.app.id"] ?? "unknown"
})
}

async function makeSpinePrescriptionCall(spineClient: SpineClient, headers: EventHeaders, params: HandlerParams) {
Expand Down
3 changes: 1 addition & 2 deletions packages/getMyPrescriptions/src/statusUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export function buildStatusUpdateData(logger: Logger, searchsetBundle: Bundle):
logger.info(`Building status update data for prescription ${prescriptionID}.`)

if (allItemsApprovedOrCancelled) {
logger.info(`All items for prescription ${prescriptionID} are 'Prescriber Approved' or ' Prescriber Cancelled'.`)
logger.info(`Ignoring prescription.`)
logger.info(`No update of prescription ${prescriptionID} as all 'Prescriber Approved' or 'Prescriber Cancelled'.`)
return
}

Expand Down
Loading