def testOnSyntheaBundle(self): inp24hr = [ inp for inp in encounter.Inpatient24HrEncounters( bundle=self._synthea_bundle, for_synthea=True) ] self.assertLen(inp24hr, 1) self.assertEqual(id(inp24hr[0]), id(self._synthea_bundle.entry[0].resource.encounter))
def testOnBundle(self): inp24hr = [ inp for inp in encounter.Inpatient24HrEncounters(self._bundle) ] self.assertLen(inp24hr, 1) # make sure we are not creating new copies of encounter. self.assertEqual(id(inp24hr[0]), id(self._bundle.entry[0].resource.encounter))
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))
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))
def process(self, bundle): """Iterate through bundle and yield label. Args: bundle: input stu3.Bundle proto Yields: stu3.EventLabel proto. """ patient = encounter.GetPatient(bundle) if patient is not None: # Cohort: inpatient encounter > 24 hours. for enc in encounter.Inpatient24HrEncounters(bundle): for one_label in label.LengthOfStayRangeAt24Hours( patient, enc): yield one_label
def process( self, bundle: resources_pb2.Bundle ) -> Iterator[google_extensions_pb2.EventLabel]: """Iterate through bundle and yield label. Args: bundle: input stu3.Bundle proto Yields: stu3.EventLabel proto. """ patient = encounter.GetPatient(bundle) if patient is not None: # Cohort: inpatient encounter > 24 hours. for enc in encounter.Inpatient24HrEncounters( bundle, self._for_synthea): for one_label in label.LengthOfStayRangeAt24Hours( patient, enc): yield one_label