cqframework / cqframework/clinical-reasoning

Unexpected during evaluation

Open
#274 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
49
Forks
43
Avg merge
2d 19h
Merged PRs (30d)
13

Description

Given the following library:

library Queries

using QICore version '4.1.1'

include FHIRHelpers version '4.1.000'

parameter "Measurement Period" Interval<DateTime> default Interval[@2023-01-01T00:00:00.0Z, @2023-12-31T23:59:59.999Z]

context Patient

define "Blood Pressure Observations":
  ["Observation Blood Pressure Profile"]

define "Encounters With Blood Pressure":
  [Encounter] E
    with ["Observation Blood Pressure Profile"] O
      such that O.effective during E.period

define "Encounter-1 Period":
  singleton from (
    [Encounter] E
        where E.id = 'Encounter-1'
        return E.period
  )

define "Observation Blood Pressure Effective":
  singleton from (
    ["Observation Blood Pressure Profile"] O
      return O.effective
  )

define "Is During":
  "Observation Blood Pressure Effective" during "Encounter-1 Period"

define "On Or After Start Of":
  "Observation Blood Pressure Effective" on or after start "Encounter-1 Period"

define "On Or Before End Of":
  "Observation Blood Pressure Effective" on or before end "Encounter-1 Period"

And the following Encounter and Observation resources:

{
    "resourceType": "Encounter",
    "id": "Encounter-1",
    "meta": {
        "profile": [
          "http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter"
        ]
    },
    "subject": {
      "reference": "Patient/example"
    },
    "status": "finished",
    "class": {
      "code": "AMB",
      "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
      "display": "ambulatory"
    },
    "type": [
      {
        "coding": [
          {
            "code": "3391000175108",
            "system": "http://snomed.info/sct",
            "display": "Office visit for pediatric care and assessment (procedure)"
          }
        ]
      }
    ],
    "period": {
      "start": "2023-01-10T10:00:00.000Z",
      "end": "2023-01-10T11:00:00.000Z"
    }
  }
{
  "resourceType": "Observation",
  "id": "blood-pressure",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/StructureDefinition/bp"
    ]
  },
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: blood-pressure</p><p><b>meta</b>: </p><p><b>status</b>: final</p><p><b>category</b>: Vital Signs <span style=\"background: LightGoldenRodYellow\">(Details : {http://terminology.hl7.org/CodeSystem/observation-category code 'vital-signs' = 'Vital Signs', given as 'Vital Signs'})</span></p><p><b>code</b>: Blood pressure systolic and diastolic <span style=\"background: LightGoldenRodYellow\">(Details : {LOINC code '85354-9' = 'Blood pressure panel with all children optional', given as 'Blood pressure panel with all children optional'})</span></p><p><b>subject</b>: <a href=\"Patient-example.html\">Amy Shaw. Generated Summary: id: example; Medical Record Number = 1032702 (USUAL); active; Amy V. Shaw ; ph: 555-555-5555(HOME), amy.shaw@example.com; gender: female; birthDate: 2007-02-20</a></p><p><b>encounter</b>: GP Visit</p><p><b>effective</b>: 02/07/1999 12:00:00 AM</p><blockquote><p><b>component</b></p><p><b>code</b>: Systolic blood pressure <span style=\"background: LightGoldenRodYellow\">(Details : {LOINC code '8480-6' = 'Systolic blood pressure', given as 'Systolic blood pressure'})</span></p><p><b>value</b>: 109 mmHg<span style=\"background: LightGoldenRodYellow\"> (Details: UCUM code mm[Hg] = 'mm[Hg]')</span></p></blockquote><blockquote><p><b>component</b></p><p><b>code</b>: Diastolic blood pressure <span style=\"background: LightGoldenRodYellow\">(Details : {LOINC code '8462-4' = 'Diastolic blood pressure', given as 'Diastolic blood pressure'})</span></p><p><b>value</b>: 44 mmHg<span style=\"background: LightGoldenRodYellow\"> (Details: UCUM code mm[Hg] = 'mm[Hg]')</span></p></blockquote></div>"
  },
  "status": "final",
  "category": [
    {
      "coding": [
        {
          "system": "http://terminology.hl7.org/CodeSystem/observation-category",
          "code": "vital-signs",
          "display": "Vital Signs"
        }
      ],
      "text": "Vital Signs"
    }
  ],
  "code": {
    "coding": [
      {
        "system": "http://loinc.org",
        "code": "85354-9",
        "display": "Blood pressure panel with all children optional"
      }
    ],
    "text": "Blood pressure systolic and diastolic"
  },
  "subject": {
    "reference": "Patient/example",
    "display": "Amy Shaw"
  },
  "encounter": {
    "display": "GP Visit"
  },
  "effectiveDateTime": "2023-01-10T10:10Z",
  "component": [
    {
      "code": {
        "coding": [
          {
            "system": "http://loinc.org",
            "code": "8480-6",
            "display": "Systolic blood pressure"
          }
        ],
        "text": "Systolic blood pressure"
      },
      "valueQuantity": {
        "value": 109,
        "unit": "mmHg",
        "system": "http://unitsofmeasure.org",
        "code": "mm[Hg]"
      }
    },
    {
      "code": {
        "coding": [
          {
            "system": "http://loinc.org",
            "code": "8462-4",
            "display": "Diastolic blood pressure"
          }
        ],
        "text": "Diastolic blood pressure"
      },
      "valueQuantity": {
        "value": 44,
        "unit": "mmHg",
        "system": "http://unitsofmeasure.org",
        "code": "mm[Hg]"
      }
    }
  ]
}

The result of the "Is During" expression should be true, but is returning null

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the CQL evaluation using the library and Encounter and Observation resources in the issue. Trace the evaluation of the "Is During" expression and its temporal interval comparison; done means it returns true rather than null for the supplied dates.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.