Skip to content

Index a patient profile at the first observation period when the person has no records - #2593

Merged
chrisknoll merged 1 commit into
OHDSI:masterfrom
DG47:fix/person-profile-index-without-records
Nov 13, 2026
Merged

chrisknoll merged 1 commit into
OHDSI:masterfrom
DG47:fix/person-profile-index-without-records

Conversation

@DG47

@DG47 DG47 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #2592

getPersonProfile takes day 0 from the requested cohort's start date, or else from the person's earliest record. A person with observation periods but no clinical records has neither when the profile is opened without a cohort, or for a cohort the person is not in. For example, an enrollee with coverage but no claims. The index date stayed null, and computing the observation period offsets threw

java.lang.NullPointerException: Cannot invoke "java.time.temporal.Temporal.until(...)" because "temporal1Inclusive" is null

so the endpoint returned a server error instead of the profile.

Change

  • PersonService.getPersonProfile: when there is no cohort entry and no record, fall back to the earliest observation period start date. This is the "initial date of observation" the endpoint's documentation already describes. Profiles that have a cohort entry or any record are indexed exactly as before.

OHDSI/Atlas#2121 asks whether the no-cohort index should always be the observation period start. This PR doesn't settle that; it only covers the case that currently crashes.

Tests

  • New PersonServiceProfileTest (embedded Postgres, small CDM schema) calls getPersonProfile for:

    • a person with two observation periods and no records, without a cohort and with a cohort the person is not in. Both tests fail on master with the NullPointerException; with the fix, the profile has day 0 at the first observation period and the age at index from that year.
    • a cohort member with a record, which checks that the cohort-start index and the record and observation period offsets are unchanged.

    The test stubs the source repository and JDBC template on a spy and calls getPersonProfile directly, so @PreAuthorize isn't exercised.

mvn -DskipUnitTests=false -DskipITtests=true -Dtest='PersonService*Test' test
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0

mvn -DskipUnitTests=false -DskipITtests=true test
Tests run: 172, Failures: 0, Errors: 0, Skipped: 5

…on has no records

getPersonProfile takes day 0 from the requested cohort's start date, or
else from the person's earliest record. A person with observation periods
but no clinical records (an enrollee without claims, or a profile opened
for a cohort the person is not in) had neither, so the index date stayed
null and computing the observation period offsets threw a
NullPointerException, returning a server error instead of the profile.

Fall back to the earliest observation period start, as the endpoint's
documentation describes, so these profiles load with their observation
periods and age at index.
@chrisknoll
chrisknoll merged commit 8e7f290 into OHDSI:master Nov 13, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Patient profile returns a server error for a person with observation periods but no clinical records

2 participants