31
31
ProgressionSevereWastingEvent ,
32
32
SevereAcuteMalnutritionDeathEvent ,
33
33
WastingNaturalRecoveryEvent ,
34
- WastingPollingEvent ,
34
+ WastingPollingEvent , UpdateToMAM ,
35
35
)
36
36
37
37
# Path to the resource files used by the disease and intervention methods
@@ -196,7 +196,6 @@ def test_wasting_incidence(tmpdir):
196
196
df = sim .population .props
197
197
under5s = df .loc [df .is_alive & (df ['age_years' ] < 5 )]
198
198
person_id = under5s .index [0 ]
199
- person = df .loc [person_id ]
200
199
assert all (under5s ['un_ever_wasted' ])
201
200
assert all (under5s ['un_WHZ_category' ] == '-3<=WHZ<-2' )
202
201
assert all (under5s ['un_last_wasting_date_of_onset' ] == sim .date )
@@ -242,7 +241,7 @@ def test_report_daly_weights(tmpdir):
242
241
243
242
# Verify diagnosis
244
243
assert df .loc [person_id , 'un_clinical_acute_malnutrition' ] == 'MAM'
245
- assert df .loc [person_id , 'un_am_bilateral_oedema' ] == True
244
+ assert df .loc [person_id , 'un_am_bilateral_oedema' ]
246
245
247
246
# Report daly weight for this individual
248
247
daly_weights_reported = sim .modules ["Wasting" ].report_daly_values ()
@@ -344,7 +343,7 @@ def test_recovery_moderate_wasting(tmpdir):
344
343
345
344
346
345
def test_recovery_severe_wasting_without_complications (tmpdir ):
347
- """ Check natural recovery to MAM by removing death rate for those with severe wasting, and check the onset of
346
+ """ Check recovery to MAM by removing death rate for those with severe wasting, and check the onset of
348
347
symptoms with SAM and revolving of symptoms when recovered to MAM """
349
348
dur = pd .DateOffset (days = 0 )
350
349
popsize = 1000
@@ -372,18 +371,20 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
372
371
# set progress to severe wasting at 100% as well
373
372
wmodule .wasting_models .severe_wasting_progression_lm = LinearModel .multiplicative ()
374
373
374
+ # set complete recovery from wasting to zero. We want those with SAM to recover to MAM
375
+ wmodule .wasting_models .acute_malnutrition_recovery_sam_lm = LinearModel (LinearModelType .MULTIPLICATIVE , 0.0 )
376
+
377
+ # Set death rate at 0% and recovery to MAM at 100%
378
+ wmodule .parameters ['prob_death_after_care' ] = 0.0
379
+ wmodule .parameters ['prob_mam_after_care' ] = 1.0
380
+
375
381
# Run Wasting Polling event to get new incident cases:
376
382
polling = WastingPollingEvent (module = sim .modules ['Wasting' ])
377
383
polling .apply (sim .population )
378
384
379
385
# Check properties of this individual: should now be moderately wasted
380
386
person = df .loc [person_id ]
381
- assert person ['un_ever_wasted' ]
382
387
assert person ['un_WHZ_category' ] == '-3<=WHZ<-2'
383
- assert person ['un_last_wasting_date_of_onset' ] == sim .date
384
- assert pd .isnull (person ['un_acute_malnutrition_tx_start_date' ])
385
- assert pd .isnull (person ['un_am_recovery_date' ])
386
- assert pd .isnull (person ['un_sam_death_date' ])
387
388
388
389
# Check that there is a ProgressionSevereWastingEvent scheduled for this person:
389
390
progression_event_tuple = [event_tuple for event_tuple in sim .find_events_for_person (person_id )
@@ -396,16 +397,14 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
396
397
sim .date = date_of_scheduled_progression
397
398
progression_event .apply (person_id = person_id )
398
399
399
- # Check individuals have symptoms caused by Wasting (SAM only)
400
- assert 0 < len ( sim .modules ['SymptomManager' ].has_what (person_id , sim .modules ['Wasting' ]) )
400
+ # Check this individual has symptom(weight loss) caused by Wasting (SAM only)
401
+ assert 'weight_loss' in sim .modules ['SymptomManager' ].has_what (person_id , sim .modules ['Wasting' ])
401
402
402
- # Check properties of this individual: (should now be severely wasted and without a scheduled death date)
403
+ # Check properties of this individual: (should now be severely wasted, diagnosed as SAM and without a scheduled
404
+ # death date)
403
405
person = df .loc [person_id ]
404
- assert person ['un_ever_wasted' ]
405
406
assert person ['un_WHZ_category' ] == 'WHZ<-3'
406
407
assert person ['un_clinical_acute_malnutrition' ] == 'SAM'
407
- assert pd .isnull (person ['un_acute_malnutrition_tx_start_date' ])
408
- assert pd .isnull (person ['un_am_recovery_date' ])
409
408
assert pd .isnull (person ['un_sam_death_date' ])
410
409
411
410
hsp = HealthSeekingBehaviourPoll (sim .modules ['HealthSeekingBehaviour' ])
@@ -430,11 +429,11 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
430
429
sam_ev .run (squeeze_factor = 0.0 )
431
430
432
431
# check recovery event is scheduled
433
- assert isinstance (sim .find_events_for_person (person_id )[1 ][1 ], ClinicalAcuteMalnutritionRecoveryEvent )
432
+ assert isinstance (sim .find_events_for_person (person_id )[1 ][1 ], UpdateToMAM )
434
433
435
434
# Run the recovery event and check the individual has recovered from SAM:
436
435
sam_recovery_event_tuple = [event_tuple for event_tuple in sim .find_events_for_person (person_id ) if
437
- isinstance (event_tuple [1 ], ClinicalAcuteMalnutritionRecoveryEvent )][0 ]
436
+ isinstance (event_tuple [1 ], UpdateToMAM )][0 ]
438
437
439
438
date_of_scheduled_recovery_to_mam = sam_recovery_event_tuple [0 ]
440
439
sam_recovery_event = sam_recovery_event_tuple [1 ]
@@ -446,8 +445,7 @@ def test_recovery_severe_wasting_without_complications(tmpdir):
446
445
447
446
# Check properties of this individual
448
447
person = df .loc [person_id ]
449
- assert person ['un_WHZ_category' ] == 'WHZ>=-2'
450
- assert (person ['un_am_MUAC_category' ] == '>=125mm' )
448
+ assert person ['un_clinical_acute_malnutrition' ] == 'MAM'
451
449
assert pd .isnull (person ['un_sam_death_date' ])
452
450
453
451
# check they have no symptoms:
@@ -535,7 +533,7 @@ def test_recovery_severe_wasting_with_complications(tmpdir):
535
533
sim .date = date_of_scheduled_recovery_to_mam
536
534
sam_recovery_event .apply (person_id = person_id )
537
535
538
- # Check properties of this individual
536
+ # Check properties of this individual. Should now be well
539
537
person = df .loc [person_id ]
540
538
assert person ['un_WHZ_category' ] == 'WHZ>=-2'
541
539
assert (person ['un_am_MUAC_category' ] == '>=125mm' )
@@ -726,6 +724,8 @@ def test_nat_hist_cure_if_death_scheduled(tmpdir):
726
724
df = sim .population .props
727
725
under5s = df .loc [df .is_alive & (df ['age_years' ] < 5 )]
728
726
person_id = under5s .index [0 ]
727
+ # Let this person have severe wasting
728
+ df .loc [person_id , 'un_WHZ_category' ] = 'WHZ>=-2'
729
729
assert df .loc [person_id , 'un_WHZ_category' ] == 'WHZ>=-2'
730
730
731
731
# Run Wasting Polling event to get new incident cases:
0 commit comments