Beispiel #1
0
    def test_get_bed_count_for_icu(self):
        store = self.store
        icu_id = self.add_icu()
        user_id = store.add_user_to_icu(self.admin_user_id, icu_id,
                                        User(name="user"))
        bed_count = store.get_bed_count_for_icu(icu_id)
        self.assertIsNone(bed_count)

        bed_count = BedCount(icu_id=icu_id,
                             n_covid_occ=1,
                             n_covid_free=2,
                             n_ncovid_occ=8,
                             n_ncovid_free=3,
                             n_covid_deaths=4,
                             n_covid_healed=5,
                             n_covid_refused=6,
                             n_covid_transfered=7)
        store.update_bed_count_for_icu(user_id, bed_count)

        bed_count = store.get_bed_count_for_icu(icu_id)
        self.assertEqual(bed_count.n_covid_occ, 1)
        self.assertEqual(bed_count.n_covid_free, 2)
        self.assertEqual(bed_count.n_ncovid_occ, 8)
        self.assertEqual(bed_count.n_ncovid_free, 3)
        self.assertEqual(bed_count.n_covid_deaths, 4)
        self.assertEqual(bed_count.n_covid_healed, 5)
        self.assertEqual(bed_count.n_covid_refused, 6)
        self.assertEqual(bed_count.n_covid_transfered, 7)
        # ICU relationships.
        self.assertEqual(bed_count.icu.name, "icu")

        # Timestamps have second accuracy.
        time.sleep(1.1)

        next_bed_count = BedCount(icu_id=icu_id,
                                  n_covid_occ=7,
                                  n_covid_free=6,
                                  n_ncovid_occ=8,
                                  n_ncovid_free=5,
                                  n_covid_deaths=4,
                                  n_covid_healed=3,
                                  n_covid_refused=2,
                                  n_covid_transfered=1)
        store.update_bed_count_for_icu(user_id, next_bed_count)

        bed_count = store.get_bed_count_for_icu(icu_id)
        self.assertEqual(bed_count.n_covid_occ, 7)
        self.assertEqual(bed_count.n_covid_free, 6)
        self.assertEqual(bed_count.n_ncovid_occ, 8)
        self.assertEqual(bed_count.n_ncovid_free, 5)
        self.assertEqual(bed_count.n_covid_deaths, 4)
        self.assertEqual(bed_count.n_covid_healed, 3)
        self.assertEqual(bed_count.n_covid_refused, 2)
        self.assertEqual(bed_count.n_covid_transfered, 1)
Beispiel #2
0
 def add_icu_with_values(self, region_id, name, now, values):
     icu_id = self.add_icu(name, region_id=region_id)
     for index, value in enumerate(values):
         self.store.update_bed_count_for_icu(
             self.admin_user_id,
             BedCount(icu_id=icu_id,
                      n_covid_occ=value,
                      create_date=add_seconds(now, index)))
     return icu_id
Beispiel #3
0
 def add_icu(region_id, name, values):
     icu_id = store.add_icu(admin_user_id,
                            ICU(name=name, region_id=region_id))
     for index, value in enumerate(values):
         store.update_bed_count_for_icu(
             admin_user_id,
             BedCount(icu_id=icu_id,
                      n_covid_occ=value,
                      create_date=now + timedelta(seconds=index)))
     return icu_id
Beispiel #4
0
 def add_icu(name, dept, city, lat, long, telephone, n_covid_occ,
             n_covid_free, n_ncovid_free, n_covid_deaths, n_covid_healed,
             n_covid_refused, n_covid_transfered):
     icu_id = store.add_icu(
         admin_user_id,
         ICU(name=name,
             region_id=region_id,
             dept=dept,
             city=city,
             lat=lat,
             long=long,
             telephone=telephone))
     store.update_bed_count_for_icu(
         admin_user_id,
         BedCount(icu_id=icu_id,
                  n_covid_occ=n_covid_occ,
                  n_covid_free=n_covid_free,
                  n_ncovid_free=n_ncovid_free,
                  n_covid_deaths=n_covid_deaths,
                  n_covid_healed=n_covid_healed,
                  n_covid_refused=n_covid_refused,
                  n_covid_transfered=n_covid_transfered))
     return icu_id