Prior Authorization Status as of a Cutoff Time in Pandas
Last updated: November 29, 2026
Quick Overview
Given a requests DataFrame (pa_id, member_id, submitted_at) and a status_updates DataFrame (pa_id, status, updated_at), return each prior authorization's latest status as of a given timestamp, the hours to decision for approved or denied cases, and hours open for undecided ones.
CVS Health
November 29, 20260
0
0 solved
Given a requests DataFrame (pa_id, member_id, submitted_at) and a status_updates DataFrame (pa_id, status, updated_at), return each prior authorization's latest status as of a given timestamp, the hours to decision for approved or denied cases, and hours open for undecided ones.
CVS Caremark and Aetna process large volumes of prior authorization requests, and turnaround time against regulatory deadlines is closely monitored. The interviewer checks point in time correctness: no update after the cutoff may leak into the answer.
What the Interviewer Expects
- Filters updates to those at or before the cutoff before picking the latest
- Picks the latest status per request deterministically
- Left joins so requests with no update still appear
- Computes turnaround only for terminal statuses
- Excludes requests submitted after the cutoff
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you use merge_asof for many cutoffs, such as a daily snapshot table?
- How would you report the share of urgent requests decided within 72 hours?
- What if two updates share the same timestamp?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
Statuses: PENDING_INFO, IN_REVIEW, APPROVED, DENIED. A request with no updates yet is SUBMITTED. Timestamps are naive UTC. Terminal statuses are APPROVED and DENIED. The cutoff simulates "what did the...
Approach
Filter updates to updated_at <= as_of, sort, and keep the last row per pa_id. Left merge onto requests submitted by the cutoff. Fill missing status with SUBMITTED. Hours to decision = decision tim...