starsimhub / starsim

Starsim disease modeling framework
http://starsim.org
MIT License
15 stars 9 forks source link

Infant outcomes for maternal deaths #529

Open daniel-klein opened 5 months ago

daniel-klein commented 5 months ago

If using Pregnancy and the mother dies, the unborn baby should also likely die unless sufficiently close to delivery.

This issue came up when trying to link newborns to mothers at birth through the maternal net. If the mother dies, the edge in MaternalNet is removed, but the baby is born nonetheless.

devclinton commented 5 months ago

@daniel-klein I am thinking of fixing this but running by my fix to everyone first

  1. Update Pregnancy class under demographics by a. add logic for is_near_delivery as a utility funciton. SOmething like(assuming we would want to parameterize that window)

      def is_near_delivery(self, uid):
            """ Check if the unborn baby is sufficiently close to delivery """
           return self.ti_delivery[uid] - self.sim.ti <= self.pars.delivery_window

    b. add handle_matnernal_deaths here that takes a list of maternal death uids, gets the unborn uids.

    def handle_maternal_deaths(self, maternal_deaths):
        """ Handle the death of pregnant women """
        unborn_inds = self.sim.people.mother_net.edges.p2[np.isin(self.sim.people.mother_net.edges.p1, maternal_deaths)]
        edges_to_remove = []
        for unborn in unborn_inds:
            if not self.is_near_delivery(unborn):
                self.sim.people.request_death(unborn)
                edges_to_remove.append(unborn)
        self.sim.people.request_death(maternal_deaths)
    
        mother_edges = np.isin(maternal_net.edges.p1, maternal_deaths)
        unborn_baby_edges = np.isin(maternal_net.edges.p2, edges_to_remove)
        maternal_net.remove_edges(unborn_baby_edges | mother_edges)
        return
  2. Update MaternalNet to have utility function(s) to take the edges we want to remove from pregnancy

    What I am unsure of, is this the right approach? Is pregnancy demographics the right place to handle the logic?