synthetichealth / synthea

Synthetic Patient Population Simulator
https://synthetichealth.github.io/synthea
Apache License 2.0
2.15k stars 645 forks source link

CCDA "vital signs organizer" effectiveTime does not match component entries #995

Open ytitov opened 2 years ago

ytitov commented 2 years ago

Hello, we are using this tool to generate some test data and have come across some unexpected behavior when it comes to vital signs. It appears that the "effectiveTime" of the "Vital Signs Organizer" is set to the date of when the extract was run, yet the vital signs components (example: heart rate or height) are set to completely different dates. I noticed this when I was doing some integration testing and spoke with our team that deals with this. Is this a bug? Or am I interpreting this incorrectly? I wanted to ask here and get some clarification whether this is in fact a bug. Here is a sample pulled from a generated file:

    <entry typeCode="DRIV">
      <organizer classCode="CLUSTER" moodCode="EVN">
        <templateId root="2.16.840.1.113883.10.20.22.4.26" extension="2015-08-01"/>
        <!-- Vital signs organizer template -->
        <id root="50379072-a427-e6a4-314e-f6418235cfa4"/>
        <code code="46680005" codeSystem="2.16.840.1.113883.6.96" displayName="Vital signs" codeSystemName="SNOMED CT">
          <translation code="74728-7" displayName="Vital signs, weight, height, head circumference, oximetry, BMI, and BSA panel" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" />
        </code>
        <statusCode code="completed"/>
        <effectiveTime value="20210724100654"/>
        <component>
          <observation classCode="OBS" moodCode="EVN">
            <templateId root="2.16.840.1.113883.10.20.22.4.27" extension="2014-06-09"/>
            <!-- Result observation template -->
            <id root="e388fe0e-0633-bf44-9309-cd50d7365c2d"/>
        <code  code="8302-2" codeSystem="2.16.840.1.113883.6.1" displayName="Body Height">
          <originalText><reference value="#observations-desc-1"/></originalText>
        </code>
            <text>
              <reference value="#observations-desc-1"/>
            </text>
            <statusCode code="completed"/>
            <effectiveTime value="20111119100654"/>
            <value xsi:type="PQ" value="164.3" unit="cm"/>
          </observation>
        </component>

Screenshot with offending values highlighted: image

If someone could point out what I am missing, that would be most helpful!

jawalonoski commented 2 years ago

Is it a bug? I don't know. Someone who is an expert in C-CDA should tell me if that is incorrect.

I can tell you that it is behaving as designed (perhaps incorrectly).

The component observation time, in your screenshot 20111119100654, is the time the observation was made.

The organizer time, in your screenshot 20210724100654, is the time the C-CDA document was created and exported by the organization (in all cases, this will just happen to coincide when Synthea was run).

Here is what I see from the C-CDA specification (local PDF copy, I don't have an online link):

From

3.107Vital Signs Organizer (V3)
[organizer: identifier urn:hl7ii:2.16.840.1.113883.10.20.22.4.26:2015-08-01 (open)]

Constraints:

7. SHALL contain exactly one [1..1] effectiveTime (CONF:1198-7288).
Note: The effectiveTime may be a timestamp or an interval that spans the effectiveTimes of the contained vital signs observations.

It would probably better to have an interval, but I'm not sure if it is a "bug" or not.

We'd be happy to take a pull request if someone wants to create an interval timestamp on the vital signs template, which would be this: https://github.com/synthetichealth/synthea/blob/master/src/main/resources/templates/ccda/vital_signs.ftl

ytitov commented 2 years ago

As it stands now, when we import any CCDAs we use the vital signs organizer section to group the vital signs. I don't believe the current template represents a practical situation as it stands now, even if it is technically allowed. I'd be more than happy to update the template and create a pull request. I'm not familiar with the template file format, so @jawalonoski if you have any pointers to some documentation, I'm very willing to give it a shot. Thanks!

jawalonoski commented 2 years ago

The template format is Apache FreeMarker. https://freemarker.apache.org