Esempio n. 1
0
 def testEncounterLengthDays(self):
     inp24hr = [
         inp for inp in encounter.Inpatient24HrEncounters(self._bundle)
     ]
     self.assertLen(inp24hr, 1)
     enc = inp24hr[0]
     self.assertEqual(12860, int(encounter.EncounterLengthDays(enc)))
     self.assertLess(12860.0, encounter.EncounterLengthDays(enc))
Esempio n. 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)