AWS Builder Center
How to Design Patient Portal Audit Logs for Caregiver Access Changes on AWS

How to Design Patient Portal Audit Logs for Caregiver Access Changes on AWS

Design patient portal audit logs on AWS for caregiver access changes and staff approvals. Record who changed access, when it took effect, and how to investigate it later.

Series: Healthcare (8 articles)

  1. …
  2. 5
    How to Design Patient Portal Audit Logs for Caregiver Access Changes on AWS This article
A patient portal audit log should record who changed access, which patient or permission was affected, when the change took effect, and what happened. Use the application to capture the meaning of the action. On AWS, DynamoDB can store the audit event alongside the permission change, while CloudWatch can surface operational failures.
Suppose clinic staff revoke a caregiver’s report access at 2:15 p.m. The caregiver calls at 2:30 p.m. because the report list is empty. Support needs to determine whether the caregiver’s access was intentionally revoked, whether the change applied to the correct account, and whether the portal enforced it. Those questions require an application audit trail.

Which actions belong in the audit trail?

Start with actions a clinic may need to reconstruct during a support or access review.
Action
What the event should capture
Caregiver access granted
Who approved it, the access scope, and its expiry
Caregiver access revoked
Who revoked it, the grant affected, and the effective time
Staff role changed
The old and new roles and the account that approved the change
Report release approved
The staff account and the specific report version released
Request denied after a permission change
The requested action and a reason code such as  GRANT_REVOKED 
Use opaque identifiers for patients, reports, and grants. Restrict access to those identifiers because staff may be able to map them back to people. Keep report content, passwords, access tokens, and download URLs out of the audit event and operational logs.

Write the permission change and audit event together

When a staff member revokes a caregiver grant, Lambda verifies that the staff member can manage access for that clinic. It then submits a DynamoDB transaction that updates the grant and inserts an audit event. Condition the update on the expected grant revision so a stale request cannot silently overwrite a newer decision.
An illustrative record looks like this:
{
"eventType": "CAREGIVER_ACCESS_REVOKED",
"clinicRef": "clinic-42",
"actorRef": "staff-108",
"targetGrantRef": "grant-92",
"previousStatus": "ACTIVE",
"newStatus": "REVOKED",
"effectiveAt": "2026-11-13T08:45:00Z",
"requestId": "req-demo-17"
}
If the audit write fails, the transaction leaves the grant unchanged and the portal can report a failed action. If the browser times out after the transaction succeeds, a retry can use the same operation identifier to locate the original result.

Reconstruct what happened from distinct events

Keep the permission change and later access decisions separate.  CAREGIVER_ACCESS_REVOKED  records a change to a grant.  REPORT_ACCESS_DENIED  records what happened when a request reached the portal. Together they show whether a particular request was denied after revocation.
For the support case, the sequence might be:
  1. 2:15 p.m. Staff revokes grant  grant-92 .
  1. 2:16 p.m. The caregiver refreshes the report list. The portal checks the current grant and denies report access.
  1. 2:30 p.m. Support looks up the grant and confirms the change without opening the patient’s report.
If a presigned download URL had been issued before revocation, the API denial alone would not establish whether that URL was used. Investigate storage access separately where the relevant logging is configured.

Make the audit trail usable in practice

  • Give support staff only the lookup access they need for their clinic.
  • Restrict update and delete permissions on audit records. Use a protected archive if the organization requires tamper-resistant retention.
  • Use CloudWatch to alert on audit-write failures and spikes in denials. Keep detailed records in the restricted audit store.
  • Test a revoked caregiver with an active session, an expired grant, a repeated staff request, and a failed audit write.
A support reviewer should be able to find the exact grant change and its effect on later portal requests using a grant reference and a time range.

Series: Healthcare (8 articles)

  1. …
  2. 5
    How to Design Patient Portal Audit Logs for Caregiver Access Changes on AWS This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article