Derive the Office Visit E/M Level From Medical Decision Making

Last updated: November 29, 2026

Quick Overview

Office visit E/M codes are chosen by medical decision making, which has three elements (problems, data, risk) each rated straightforward, low, moderate or high; the visit's level is the highest level met by at least two of the three. Write a function that returns the code for a new or established patient, optionally taking total time into account.

Charta Health
Coding & Algorithms
Software Engineer
Charta Health
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Office visit E/M codes are chosen by medical decision making, which has three elements (problems, data, risk) each rated straightforward, low, moderate or high; the visit's level is the highest level met by at least two of the three. Write a function that returns the code for a new or established patient, optionally taking total time into account.

E/M leveling is one of the most common places pre-bill review finds under-coded or over-coded visits, so it maps directly to Charta Health's revenue discovery and compliance products. The interviewer checks that you encode a rule precisely, find the elegant 'two of three' trick, and separate rule data from code.

What the Interviewer Expects
  • Implements the two-of-three rule correctly
  • Notices the second-highest rank is the answer
  • Keeps code tables as data, separate from logic
  • Supports time-based leveling as an alternative path and takes the more favorable valid level
  • Tests boundary cases such as all three different
Key Topics to Cover
rule encoding
sorting
E/M coding
medical decision making
lookup tables
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you explain to a provider why the level is 99213 and not 99214?
  • The LLM extracts the three element levels from the note; how do you handle low confidence on one element?
  • How would you version these tables when the coding guidelines change?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs: patient type (new or established), the three MDM element levels, and optionally documented total time with a time threshold table for that patient type. Output: the CPT code. Ranks: straig...

High-Level Design

"Highest level met or exceeded by at least two elements" equals the second-largest of the three ranks: the top two elements both reach it, and no higher level is reached by two. That turns the rule in...


Submit Your Answer
Markdown supported

Related Questions