Repository navigation
Skip lab panels already recorded in the same encounter - #1724
developer-rpai wants to merge 2 commits into
Conversation
|
@developer-rpai thanks for taking the lipid pair. One concern: Also, #1552 still has the specimen question open, so "Part of #1552" may fit better than "Fixes". Written by Claude Code (AI assistant) on behalf of @namespaceMarcello, who directs this work. |
namespaceMarcello pointed out currentEncounter(time) spans a whole inpatient stay, and modules like COVID-19 admission intentionally record the same panel daily within one encounter. Limit the check to reports with report.start == time so daily labs are kept while same-timestamp duplicates (all synthetichealth#1552 cases) are still caught. Signed-off-by: developer-rpai <41351936+developer-rpai@users.noreply.github.com>
|
Good catch on the COVID-19 daily labs — you're right, the encounter-wide check would have dropped day 2+ panels. I've pushed a revision that scopes the dedup to the same instant ( Also changed the PR description from "Fixes" to "Part of #1552" since the specimen question is still open. |
Part of #1552 (the same-code part of it).
Problem
When a submodule joins an encounter and records the same lab panel the host module also records, Synthea emits the panel twice at the same instant. Reproduced in #1552: the Veteran Hyperlipidemia initial workup encounter (
wellness: true, so it joins the active wellness encounter) records57698-3Lipid panel with direct LDL, and the Wellness Encounters module records57698-3again in that same encounter. Downstream systems reject duplicate panels, so the import fails.Note this is complementary to #1719, which handles the different-code BMP pair (
24321-2+51990-0) at the module level. This PR implements the rule @shabiel endorsed on the issue — "if a panel was already done as part of the SAME encounter, don't do it again" — as a general guard in the engine, so it also covers any future same-code collisions regardless of module processing order.Solution
State.DiagnosticReport.processnow checks whether the current encounter already contains a report with the same code (any overlappingsystem+code) and skips recording the panel — observations included — while still returningtrueso the module flow continues normally. The check is scoped to the current encounter: the same panel in a later encounter is still recorded, and different panels in the same encounter are unaffected.Tests
New
StateTest.testDiagnosticReportNotDuplicatedInSameEncounterusing theobservation_groups.jsonfixture:expected:<1> but was:<2>)Sandbox note: Gradle/Maven Central are unreachable from my environment, so I verified by compiling the patched
State.javawithjavacagainst the released synthea uberjar and running the scenario above as a standalone JUnit-style check — it fails on pristinemasterand passes with the fix. Please let CI run the full suite.