This is a report for helping visualize the temporal patterns of EMR events (admits, discharges, and various orders) relative to the admit date of the index visit reported in NSQIP, which throughout this report is set to 0, so that in the plots below, events with negative time values precede the NSQIP admission date, events equal to 0 coincide with it, and events with positive values follow it. Figures 1 and 2 show the overall frequencies for various types of events at various times relative to the index admission. The remaining figures plot patient histories as timelines with the x-axis representing time.
Reproducible Analysis Notice: The script for generating this report can be found in the in the 5c9e3a3 commit of the bokov/nsqip_emr repository master branch. The most current static version of this report can be found on https://rpubs.com/bokov/vispatientevents
The following is a table counting the number of cases where various issues have been observed.
| Issue | N.Cases | |
|---|---|---|
| chk_readmovrlp | Post-NSQIP inpatient admits that happen on or before NSQIP discharge | \(\color{#00FF00}{\text{128}}\) |
| chk_readscovrlp | Post-NSQIP inpatient discharges that happen before their own admit dates | \(\color{#00FF2D}{\text{0}}\) |
| chk_dischovrlp | Pre-NSQIP inpatient discharges that happen on or after NSQIP admit | \(\color{#00FF5A}{\text{7}}\) |
| chk_admitovrlp | Pre-NSQIP inpatient admits that happen after their own discharge dates | \(\color{#00FF87}{\text{0}}\) |
| chk_srgpostdsc | Surgery after NSQIP discharge | \(\color{#00FFB4}{\text{4}}\) |
| chk_missingdsc | Missing NSQIP discharge date | \(\color{#00FFE1}{\text{12}}\) |
| chk_noadm | EMR index admit date missing | \(\color{#00F0FF}{\text{66}}\) |
| chk_nodsc | EMR index discharge date missing | \(\color{#00C3FF}{\text{66}}\) |
| chk_multadm | Non-unique EMR index admit date | \(\color{#0096FF}{\text{0}}\) |
| chk_multdsc | Non-unique EMR index discharge date | \(\color{#0069FF}{\text{0}}\) |
| chk_admearly | EMR admit date before NSQIP admit | \(\color{#003CFF}{\text{128}}\) |
| chk_admlate | EMR admit date after NSQIP admit | \(\color{#000FFF}{\text{364}}\) |
| chk_sumpredsc | More than one pre-NSQIP inpatient discharge | \(\color{#1E00FF}{\text{0}}\) |
| chk_sumpreadm | More than one pre-NSQIP inpatient admit | \(\color{#4B00FF}{\text{0}}\) |
| chk_sumpstdsc | More than one post-NSQIP inpatient discharge | \(\color{#7800FF}{\text{0}}\) |
| chk_sumpstadm | More than one post-NSQIP inpatient admit | \(\color{#A500FF}{\text{0}}\) |
| chk_dsclate | EMR index discharge after NSQIP discharge | \(\color{#D200FF}{\text{82}}\) |
| chk_dscearly | EMR index discharge before NSQIP discharge | \(\color{#FF00FF}{\text{10}}\) |
| CHK_total | Cases with one or more of the above issues | \(\color{FF0000}{\text{680}}\) |
The admission date of the index hospital stay reported in NSQIP was set to 0, for each patient, and the times of all the other events are expressed in days before (negative values) and after (positive values) that admission date.
How are the various types of events distributed in time? If there are certain ranges when few events occur, we could trim those off so the analysis can run faster.
Figure 1: Distribution of Events Relative to NSQIP Admission Date. Based on this we can trim off events past as early as 80 days– most of the action seems to be within that window. Please note that the bars are staggered so they can be visually distinguished, therefore a cluster of bars with no gaps separating them represent the same day. Bars only represent different days if there are gaps between them..
Figure 2: Distribution of Events Relative to NSQIP Admission Date, omitting the most common events (orders).
The plots below are an attempt to visually interpret patterns in patient histories by aligning them horizontally on NSQIP admission and vertically on the timing of the following events, in order of priority: admission date for the index NSQIP stay as recorded in the EMR, the last inpatient discharge before the index NSQIP stay (if any), the NSQIP discharge date (as recorded in NSQIP, if any), the first inpatient admission after the index NSQIP stay, and the number of days between the last pre-NSQIP inpatient discharge (or, if there is none, then the first event of any type) and first post-NSQIP inpatient admission (or, if there is none, then the last event of any type). The reasoning behind this is that if there are prior or subsequent inpatient stays, the events during and beyond them belong to those respective stays and not to the index NSQIP stay.
Figure 3: Patient timelines, grouped by similarity with color/shape coded events superimposed. Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I . There are pulse-like patterns where timelines are longer and longer, then reset back to short timelines. These “pulses” are cases that are tied for everything up to and including NSQIP DischargeDt, so within each DischargeDt they are sorted by last event. Bright red points represent cases where the Sunrise admit date does not match the NSQIP admit date. Orange points are various types of orders that are neither discharges nor admits. Purple points represent surgery start (x) and end (+) times. Since this is on the scale of days, they usually coincide so they look like asterisks, but in a few cases they occur on different days, and distinct x and + symbols can be distinguished. Finally, discharge events (CV3ClientVisit|DischargeDt, cv3Order|DischargeOrder, and NSQIP|DischargeDt) are in various shades of green if they are believed to associated with the index stay. The NSQIP one is a solid dot, while the other two are hollow triangles. Therefore, when they coincide there should be dark green triangles with bright green centers. When they do not coincide, the dark green triangles have a color other than green in their centers. Pre-NSQIP discharges and admits are shades of pink and post-NSQIP discharges and admits are shades of blue. Admits are right-pointing triangles and discharges are left-pointing. For both pre- and post-NSQIP, specifically the inpatient admits and discharges use symbols that are larger than the others and solid instead of empty inside. Note: the actual NSQIP admission date is not directly plotted here because it exists for every case and in this dataset its value is always 0 (i.e. it cannot deviate from itself).
Figure 4: Same data as fig. 3 but now the time-window narrowed to 30 days before or after NSQIP admission date to better see fine detail. Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
From fig. 3 several trends can be noticed. It is common for orders to precede admission. It is rare but possible for the Sunrise admit date to deviate from the date recorded in NSQIP in either direction. When the Sunrise date is earlier than NSQIP’s, it almost always comes before any orders. Sunrise discharge-related dates usually agree with NSQIP’s, but when they deviate the Sunrise dates always come later. Surgeries trend closer to admission than discharge. Usually, from admission to discharge there is a dense stream of orders, close to daily, and they can continue after discharge though with a diminished frequency.
But these timelines can include multiple admissions and discharges to either side of the interval reported in NSQIP. What if the events before the last discharge before the NSQIP index stay and after the first admission after the NSQIP index stay were trimmed off? Will any further trends become noticeable? The results are shown in fig. 5 and fig. 6. Originally there had been 1687647 events and after trimming off the previous and subsequent stay events there were 1686259 events, so a total of 1388 were excluded.
Some outpatient discharges can still be seen in fig. 5 and fig. 6. This may be because when the next inpatient admit coincides with the NSQIP discharge date, those events are counted as not having a post-NSQIP admission, so all subsequent events are included. There are 128 such cases.
Figure 5: Same data as fig. 3 but showing only the events in between the last pre-NSQIP inpatient discharge and first post-NSQIP inpatient admission. In cases where one or both bounds do not exist, those timelines extend to the first or last available event of any type Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
Figure 6: Same data as fig. 5 but now the time-window narrowed to 30 days before or after NSQIP admission date to better see fine detail. Still excluding everything before and after the previous and next inpatient admission. Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
In this section are smaller subsets drawn from the above population for closer review.
Figure 7: All data for 150 randomly selected NSQIP cases, to better see individual events Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
Figure 8: Like fig. 7 but only for +/-30 days from NSQIP admission date..
Figure 9: Just the cases where at least one potential data quality issue was discovered (CHK_total in table I). Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
Figure 10: Like fig. 9 but only for +/-30 days from NSQIP admission date. Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
Figure 11: Cases where the NSQIP admit date disagrees with the EMR (chk_admearly and chk_admlate in table I). Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.
Figure 12: Like fig. 11 but only for +/-30 days from NSQIP admission date. Each horizontal line represents one patient, with the color-coded shapes representing various events during their stay. However, the color of the horizontal lines means something different– it represents what type of discrepancy affects that record. If there are no discrepancies, the line is black, if there are more than one, it is red, and otherwise it is color coded as per table I.