Пример #1
0
 def testAtDuration(self):
     inp24hr = [
         inp for inp in encounter.Inpatient24HrEncounters(self._bundle)
     ]
     self.assertLen(inp24hr, 1)
     enc = inp24hr[0]
     at_duration_24_before = encounter.AtDuration(enc, -24)
     at_duration_0 = encounter.AtDuration(enc, 0)
     at_duration_24 = encounter.AtDuration(enc, 24)
     self.assertEqual(at_duration_24_before,
                      datetime(2009, 2, 12, 23, 31, 30))
     self.assertEqual(at_duration_0, datetime(2009, 2, 13, 23, 31, 30))
     self.assertEqual(at_duration_24, datetime(2009, 2, 14, 23, 31, 30))
Пример #2
0
def LengthOfStayRangeAt24Hours(patient, enc):
    """Generate length of stay range labels at 24 hours after admission.

  Args:
    patient: patient proto, needed for label proto.
    enc: encounter, caller needs to do the proper cohort filterings.

  Yields:
    (label_name, value, label_time) tuple.
  """
    label_time = encounter.AtDuration(enc, 24)
    ecounter_length_days = encounter.EncounterLengthDays(enc)
    label_val = None
    for idx in range(len(LOS_BOUNDARIES)):
        if ecounter_length_days <= LOS_BOUNDARIES[idx]:
            if idx == 0:
                label_val = 'less_or_equal_%d' % LOS_BOUNDARIES[idx]
            else:
                label_val = '%d_%d' % (LOS_BOUNDARIES[idx - 1],
                                       LOS_BOUNDARIES[idx])
            break
    if label_val is None:
        label_val = 'above_%d' % LOS_BOUNDARIES[-1]

    yield ComposeLabel(patient, enc, LOS_RANGE_LABEL, label_val, label_time)