Open daniel-klein opened 5 months ago
@daniel-klein I am thinking of fixing this but running by my fix to everyone first
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
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?
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.