<s> import fluff <EOL> from custom . m4change . constants import BOOKING_FORMS , FOLLOW_UP_FORMS , BOOKING_AND_FOLLOW_UP_FORMS , PNC_CHILD_IMMUNIZATION_AND_REG_HOME_DELIVERED_FORMS , BOOKING_FOLLOW_UP_AND_LAB_RESULTS_FORMS <EOL> from custom . m4change . user_calcs import string_to_numeric <EOL> class AncAntenatalAttendanceCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_AND_FOLLOW_UP_FORMS : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class AncAntenatalVisitBefore20WeeksCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_FORMS and form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) == "<STR_LIT:yes>" : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class AncAntenatalVisitAfter20WeeksCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_FORMS and form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) == "<STR_LIT>" : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class AncAttendanceGreaterEqual4VisitsCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in FOLLOW_UP_FORMS and string_to_numeric ( form . form . get ( "<STR_LIT>" , "<STR_LIT:0>" ) ) >= <NUM_LIT:4> : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class AncSyphilisTestDoneCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_AND_FOLLOW_UP_FORMS and "<STR_LIT>" in form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class AncSyphilisPositiveCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_FOLLOW_UP_AND_LAB_RESULTS_FORMS and form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) == "<STR_LIT>" : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class AncSyphilisCaseTreatedCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_FOLLOW_UP_AND_LAB_RESULTS_FORMS and form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) == "<STR_LIT>" and form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) == "<STR_LIT>" : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PregnantMothersReceivingIpt1Calculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_AND_FOLLOW_UP_FORMS and "<STR_LIT>" in form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PregnantMothersReceivingIpt2Calculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_AND_FOLLOW_UP_FORMS and "<STR_LIT>" in form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PregnantMothersReceivingLlinCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_AND_FOLLOW_UP_FORMS and "<STR_LIT>" in form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PregnantMothersReceivingIfaCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in BOOKING_AND_FOLLOW_UP_FORMS and "<STR_LIT>" in form . form . get ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PostnatalAttendanceCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . xmlns in PNC_CHILD_IMMUNIZATION_AND_REG_HOME_DELIVERED_FORMS : <EOL> pnc_visits = str ( form . form . get ( "<STR_LIT>" , <NUM_LIT:0> ) ) <EOL> if pnc_visits is None or not pnc_visits . isdigit ( ) : <EOL> pnc_visits = <NUM_LIT:0> <EOL> pnc_visits = int ( pnc_visits ) <EOL> yield [ form . received_on . date ( ) , pnc_visits ] <EOL> class PostnatalClinicVisitWithin1DayOfDeliveryCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . form . get ( "<STR_LIT>" , None ) is not None : <EOL> days_after_delivery = ( form . received_on . date ( ) - form . form [ "<STR_LIT>" ] ) . days <EOL> if form . xmlns in PNC_CHILD_IMMUNIZATION_AND_REG_HOME_DELIVERED_FORMS and days_after_delivery <= <NUM_LIT:1> : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PostnatalClinicVisitWithin3DaysOfDeliveryCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . form . get ( "<STR_LIT>" , None ) is not None : <EOL> days_after_delivery = ( form . received_on . date ( ) - form . form [ "<STR_LIT>" ] ) . days <EOL> if form . xmlns in PNC_CHILD_IMMUNIZATION_AND_REG_HOME_DELIVERED_FORMS and days_after_delivery > <NUM_LIT:1> and days_after_delivery <= <NUM_LIT:3> : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] <EOL> class PostnatalClinicVisitGreaterEqual7DaysOfDeliveryCalculator ( fluff . Calculator ) : <EOL> @ fluff . date_emitter <EOL> def total ( self , form ) : <EOL> if form . form . get ( "<STR_LIT>" , None ) is not None : <EOL> days_after_delivery = ( form . received_on . date ( ) - form . form [ "<STR_LIT>" ] ) . days <EOL> if form . xmlns in PNC_CHILD_IMMUNIZATION_AND_REG_HOME_DELIVERED_FORMS and days_after_delivery >= <NUM_LIT:7> : <EOL> yield [ form . received_on . date ( ) , <NUM_LIT:1> ] </s>
