def setUp(self): self._test_data_dir = os.path.join(absltest.get_default_test_srcdir(), _TESTDATA_PATH) self._enc = resources_pb2.Encounter() with open(os.path.join(self._test_data_dir, 'encounter_1.pbtxt')) as f: text_format.Parse(f.read(), self._enc) self._bundle = resources_pb2.Bundle() self._bundle.entry.add().resource.encounter.CopyFrom(self._enc) self._synthea_enc = resources_pb2.Encounter() with open(os.path.join(self._test_data_dir, 'encounter_synthea.pbtxt')) as f: text_format.Parse(f.read(), self._synthea_enc) self._synthea_bundle = resources_pb2.Bundle() self._synthea_bundle.entry.add().resource.encounter.CopyFrom( self._synthea_enc)
def testLengthOfStayRangeAt24HoursLT24Hours(self): enc = resources_pb2.Encounter() enc.CopyFrom(self._enc) enc.period.end.value_us = 1234567891000000 with self.assertRaises(AssertionError): _ = [l for l in label.LengthOfStayRangeAt24Hours( self._patient, enc)]
def setUp(self): self._test_data_dir = os.path.join(absltest.get_default_test_srcdir(), _TESTDATA_PATH) self._enc = resources_pb2.Encounter() with open(os.path.join(self._test_data_dir, 'encounter_1.pbtxt')) as f: text_format.Parse(f.read(), self._enc) self._patient = resources_pb2.Patient() self._patient.id.value = 'Patient/1' self._expected_label = google_extensions_pb2.EventLabel() with open(os.path.join(self._test_data_dir, 'label_1.pbtxt')) as f: text_format.Parse(f.read(), self._expected_label)
def testLengthOfStayRangeAt24Hours(self, end_us, label_val): enc = resources_pb2.Encounter() enc.CopyFrom(self._enc) enc.period.end.value_us = end_us labels = [l for l in label.LengthOfStayRangeAt24Hours( self._patient, enc)] expected_label = label.ComposeLabel( self._patient, self._enc, label.LOS_RANGE_LABEL, label_val, # 24 hours after admission datetime.datetime(2009, 2, 14, 23, 31, 30)) self.assertEqual([expected_label], labels)
def setUp(self): self._test_data_dir = os.path.join(absltest.get_default_test_srcdir(), _TESTDATA_PATH) enc = resources_pb2.Encounter() with open(os.path.join(self._test_data_dir, 'encounter_1.pbtxt')) as f: text_format.Parse(f.read(), enc) patient = resources_pb2.Patient() patient.id.value = 'Patient/1' self._bundle = resources_pb2.Bundle() self._bundle.entry.add().resource.encounter.CopyFrom(enc) self._bundle.entry.add().resource.patient.CopyFrom(patient) self._expected_label = label.ComposeLabel( patient, enc, label.LOS_RANGE_LABEL, 'above_14', # 24 hours after admission datetime.datetime(2009, 2, 14, 23, 31, 30))