Coding HIV in obstetric patients is not just about assigning a diagnosis — it’s about understanding sequencing, symptom status, and documentation requirements. The key concept?
When HIV complicates pregnancy, childbirth, or the puerperium, the coding rules change.
This guide will walk you step-by-step through:
When to assign O98.7
When to assign B20
When to assign Z21
Proper sequencing rules
Common exam traps and audit risks
Let’s simplify it.

Step 1: Always Start with O98.7 in Obstetric HIV Cases
When an obstetric patient is identified as having HIV infection during pregnancy, childbirth, or the puerperium, you must assign a code from subcategory:
O98.7 – Human immunodeficiency virus [HIV] disease complicating pregnancy, childbirth and the puerperium
This code is used when HIV affects the pregnancy in any way.
Important:
O98.7 is sequenced as the principal diagnosis in these cases.
Why?
Because the pregnancy is the focus of care, and the HIV condition is complicating that pregnancy.
But here’s where coders make mistakes…
O98.7 is never coded alone.
Step 2: Determine Whether the Patient Has HIV Disease or Asymptomatic HIV
After assigning O98.7, the next step depends on documentation.
You must determine:
Does the patient have HIV disease (AIDS or HIV-related illness)?
Or are they simply HIV positive without symptoms?
This distinction determines whether you assign B20 or Z21.
Scenario 1: HIV Disease (Symptomatic or AIDS)
If documentation indicates:
AIDS
HIV disease
HIV-related illness
History of opportunistic infections due to HIV
You must assign:
B20 – Human immunodeficiency virus [HIV] disease
In obstetric cases, sequencing would be:
O98.7 (principal)
B20 (additional code)
Even if the patient is not currently symptomatic but has a past confirmed diagnosis of HIV disease, B20 continues to be used. Once a patient is diagnosed with HIV disease, they are always coded to B20 in future encounters.
Key rule:
HIV disease does not revert back to asymptomatic status.
Example
A pregnant patient with known AIDS presents for routine prenatal care.
Correct coding:
O98.7
B20
Not B20 alone. Not Z21.
Scenario 2: Asymptomatic HIV Positive Patient
If the patient:
Tests positive for HIV
Has no symptoms
Has no history of HIV-related illness
Has never been diagnosed with AIDS
You assign:
Z21 – Asymptomatic human immunodeficiency virus [HIV] infection status
In obstetric cases, sequencing would be:
O98.7
Z21
This is where many coders accidentally assign B20 — and that is incorrect.
Z21 is used only when the patient is HIV positive but has never developed HIV-related illness.
Why Not Use B20 for Asymptomatic Patients?
Because B20 represents HIV disease.
The ICD-10-CM guidelines clearly state that B20 is assigned only when there is documentation of:
AIDS
HIV illness
HIV-related condition
If documentation only says “HIV positive” without symptoms, you must use Z21.
Using B20 incorrectly can:
Overstate severity of illness
Impact DRG assignment
Trigger payer audits
Cause exam failure for coding students
Accuracy matters.
Sequencing Rules: What Comes First?
In obstetric cases:
O98.7 is sequenced first.
Why?
Because Chapter 15 (Pregnancy, Childbirth and the Puerperium) guidelines state that codes from this chapter take sequencing priority when the condition complicates pregnancy.
Even if HIV is severe, the pregnancy complication code is listed first.
So your structure always looks like:
O98.7
B20 (if HIV disease)
ORZ21 (if asymptomatic HIV)
Common Exam Traps for Medical Coders
Let’s address the mistakes that appear frequently in CPC, CCS, and other certification exams.
Trap 1: Assigning B20 Alone
Incorrect.
In obstetric cases, O98.7 must be reported first.
Trap 2: Assigning Z21 When Patient Has AIDS History
Incorrect.
Once a patient has had HIV disease, they remain B20 for all future encounters.
You never go back to Z21.
Trap 3: Ignoring Documentation Language
If provider documents:
“HIV positive” → likely Z21 (if no history)
“AIDS” → B20
“HIV disease” → B20
“HIV with candidiasis” → B20
Always read carefully.
Real-World Coding Scenario Practice
Let’s test your understanding.
Case 1:
Pregnant patient newly diagnosed with HIV. No symptoms. No history of HIV-related illness.
Correct coding:
O98.7
Z21
Case 2:
Pregnant patient with history of Kaposi’s sarcoma due to HIV presents for delivery.
Correct coding:
O98.7
B20
Because there is documented HIV disease history.
Case 3:
Pregnant patient admitted for management of HIV-related pneumonia.
Correct coding:
O98.7
B20
additional code for pneumonia if required
Again, O98.7 first.
Why This Distinction Matters in DRG and Reimbursement
Incorrect use of B20 may:
Increase risk adjustment scoring
Change MS-DRG grouping
Trigger insurance review
Lead to compliance issues
As coders, our responsibility is precise code assignment based on documentation — not assumptions.
Documentation Tips for Coders
If documentation is unclear, consider querying when:
It says “HIV” without specifying disease vs. asymptomatic
There is mention of past infection but unclear status
There are opportunistic infections but no clear linkage
Never assume disease if it’s not documented.
Quick Reference Summary
Pregnant patient + HIV?
Step 1: Assign O98.7
Step 2: Determine status
If HIV disease → add B20
If asymptomatic → add Z21
That’s the entire rule simplified.
Final Takeaway for Medical Coders
HIV coding alone requires attention. Obstetric HIV coding requires precision.
Remember:
O98.7 always comes first in pregnancy cases.
B20 is used only when HIV disease is documented.
Z21 is used only for asymptomatic HIV positive patients.
Once a patient has HIV disease, they remain B20 permanently.
Mastering this concept will help you:
Avoid exam mistakes
Reduce audit risk
Strengthen compliance knowledge
Improve coding confidence
If you’re preparing for CPC, CCS, or working in OB inpatient coding, this is a high-yield guideline you must know cold.




