Пример #1
0
def on_going_non_reporting():
    now = datetime.datetime.utcnow()
    date = now - datetime.timedelta(days=21)
    domains = EWSGhanaConfig.get_all_enabled_domains()

    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            try:
                user_location = SQLLocation.objects.get(domain=domain, location_id=user.location._id)
            except AttributeError:
                continue
            if user_location:
                facilities = []
                if user_location.location_type == 'district':
                    facilities = user_location.get_children()
                elif user_location.location_type == 'region':
                    facilities = SQLLocation.objects.filter(domain=domain,
                                                            parent__parent__location_id=user.location._id)
                fac = set()
                for facility in facilities:
                    sp = facility.supply_point_id
                    if sp and not StockTransaction.objects.filter(
                            case_id=sp, type="stockonhand", report__date__gte=date).exists():
                        fac.add(str(facility.name))
                if fac and user.get_verified_number():
                    message = ONGOING_NON_REPORTING % " \n".join(fac)
                    send_sms_to_verified_number(user.get_verified_number(), message)
                    if user.email:
                        email = str(user.email)
                        send_mail('ONGOING NON REPORTING', message, '*****@*****.**', [email])
Пример #2
0
def third_soh_to_super():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        facilities = SQLLocation.objects.filter(
            location_type__name__in=reporting_types(domain))
        users = CommCareUser.by_domain(domain)
        third_soh_process_users_and_facilities(users, facilities)
Пример #3
0
def first_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            role = user.user_data.get('role')
            if role and role != IN_CHARGE_ROLE:
                first_soh_process_user(user)
Пример #4
0
def second_soh_reminder():
    now = datetime.datetime.utcnow()
    date = now - datetime.timedelta(days=DAYS_UNTIL_LATE)
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            second_soh_process_user(user, date)
Пример #5
0
def second_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            roles = user.user_data.get('role')
            if roles and IN_CHARGE_ROLE in roles:
                second_soh_process_user(user)
Пример #6
0
def second_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            roles = user.user_data.get('role')
            if roles and IN_CHARGE_ROLE in roles:
                second_soh_process_user(user)
Пример #7
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            thirteen_days_ago = datetime.datetime.utcnow() - datetime.timedelta(weeks=13)
            if user.location and user.last_login < thirteen_days_ago and user.get_verified_number()\
                    and user.location.location_type.name in ['district', 'region', 'country']:
                    message = WEB_REMINDER % user.name
                    verified_number = user.get_verified_number()
                    send_sms_to_verified_number(verified_number, message)
                    if can_receive_email(user, verified_number):
                        email = str(user.email)
                        send_mail('REMINDER TO VISIT WEBSITE', message, '*****@*****.**', [email])
Пример #8
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            if user.location and user.last_login < datetime.datetime.now() - datetime.timedelta(weeks=13) and\
                    user.get_verified_number() and \
                    (user.location.location_type == 'district' or user.location.location_type == 'region'
                     or user.location.location_type == 'country'):
                    message = WEB_REMINDER % user.name
                    send_sms_to_verified_number(user.get_verified_number(), message)
                    if user.email:
                        email = str(user.email)
                        send_mail('REMINDER TO VISIT WEBSITE', message, '*****@*****.**', [email])
Пример #9
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            thirteen_days_ago = datetime.datetime.utcnow(
            ) - datetime.timedelta(weeks=13)
            if user.location and user.last_login < thirteen_days_ago and user.get_verified_number()\
                    and user.location.location_type.name in ['district', 'region', 'country']:
                message = WEB_REMINDER % user.name
                verified_number = user.get_verified_number()
                send_sms_to_verified_number(verified_number, message)
                if can_receive_email(user, verified_number):
                    email = str(user.email)
                    send_mail('REMINDER TO VISIT WEBSITE', message,
                              '*****@*****.**', [email])
Пример #10
0
def report_reminder():
    sp_ids = set()
    now = datetime.datetime.utcnow()
    date = now - datetime.timedelta(days=7)
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            if user.location:
                sp = SupplyPointCase.get_by_location(user.location)
                if sp and not StockTransaction.objects.filter(
                    case_id=sp._id, type="stockonhand", report__date__gte=date).exists()\
                        and user.get_verified_number():
                    sp_ids.add(sp._id)
                    message = REPORT_REMINDER % (user.name, user.location.name)
                    send_sms_to_verified_number(user.get_verified_number(), message)
                    if user.email:
                        email = str(user.email)
                        send_mail('REPORT REMINDER', message, '*****@*****.**', [email])
Пример #11
0
def urgent_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            try:
                user_location = SQLLocation.objects.get(domain=domain, location_id=user.location._id)
            except AttributeError:
                continue
            if user_location:
                facilities = []
                if user_location.location_type == 'district':
                    facilities = user_location.get_children()
                elif user_location.location_type == 'region':
                    facilities = SQLLocation.objects.filter(domain=domain,
                                                            parent__parent__location_id=user.location._id)
                elif user_location.location_type == 'country':
                    facilities = SQLLocation.objects.filter(domain=domain,
                                                            parent__parent__parent__location_id=user.location._id)
                stocked_out_products = set()
                fac = set()
                no_rep = 0
                for facility in facilities:
                    sp = facility.supply_point_id
                    if sp:
                        stocked_out = StockTransaction.objects.filter(
                            case_id=sp, type="stockonhand", stock_on_hand=0)
                        if stocked_out.exists():
                            no_rep += 1
                            fac.add(str(facility))
                            for product in stocked_out:
                                stocked_out_products.add(
                                    SQLProduct.objects.get(product_id=product.product_id).name)

                if fac and no_rep >= len(facilities) / 2 and user.get_verified_number():
                    message = URGENT_STOCKOUT % (user_location.name, ", ".join(sorted(
                        [str(product) for product in stocked_out_products])))
                    send_sms_to_verified_number(user.get_verified_number(), message)
                    if user.email:
                        email = str(user.email)
                        send_mail('URGENT STOCKOUT', message, '*****@*****.**', [email])
Пример #12
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        VisitWebsiteReminder(domain).send()
Пример #13
0
def stockout_notification_to_web_supers():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        StockoutReminder(domain).send()
Пример #14
0
def second_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        SecondSOHReminder(domain).send()
Пример #15
0
def stockout_notification_to_web_supers():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        StockoutReminder(domain).send()
Пример #16
0
def second_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        SecondSOHReminder(domain).send()
Пример #17
0
def urgent_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        UrgentStockoutAlert(domain).send()
Пример #18
0
def reminder_to_submit_rrirv():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            rrirv_process_user(user)
Пример #19
0
 def _get_logistics_domains(self):
     return ILSGatewayConfig.get_all_enabled_domains() + EWSGhanaConfig.get_all_enabled_domains()
Пример #20
0
def report_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            report_reminder_process_user(user)
Пример #21
0
def on_going_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            on_going_stockout_process_user(user)
Пример #22
0
def stockout_notification_to_web_supers():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            stockout_process_user(user)
Пример #23
0
def on_going_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        OnGoingStockouts(domain).send()
        OnGoingStockoutsRMS(domain).send()
Пример #24
0
def urgent_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        UrgentStockoutAlert(domain)
Пример #25
0
 def _get_logistics_domains(self):
     from custom.ewsghana.models import EWSGhanaConfig
     return ILSGatewayConfig.get_all_enabled_domains(
     ) + EWSGhanaConfig.get_all_enabled_domains()
Пример #26
0
def urgent_non_reporting():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        UrgentNonReporting(domain).send()
Пример #27
0
def third_soh_to_super():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        facilities = SQLLocation.objects.filter(location_type__name__in=reporting_types(domain))
        users = CommCareUser.by_domain(domain)
        third_soh_process_users_and_facilities(users, facilities)
Пример #28
0
def first_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        FirstSOHReminder(domain).send()
Пример #29
0
def stockout_notification_to_web_supers():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            stockout_process_user(user)
Пример #30
0
def third_soh_to_super():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        ThirdSOHReminder(domain).send()
Пример #31
0
def reminder_to_submit_rrirv():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            rrirv_process_user(user)
Пример #32
0
def reminder_to_submit_rrirv():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        RRIRVReminder(domain).send()
Пример #33
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            visit_website_process_user(user)
Пример #34
0
def third_soh_to_super():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        ThirdSOHReminder(domain).send()
Пример #35
0
def urgent_non_reporting():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            urgent_non_reporting_process_user(user)
Пример #36
0
def reminder_to_submit_rrirv():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        RRIRVReminder(domain).send()
Пример #37
0
def report_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            report_reminder_process_user(user)
Пример #38
0
def on_going_non_reporting():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        OnGoingNonReporting(domain).send()
Пример #39
0
def on_going_non_reporting():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        OnGoingNonReporting(domain).send()
Пример #40
0
def urgent_non_reporting():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        UrgentNonReporting(domain)
Пример #41
0
def on_going_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        OnGoingStockouts(domain).send()
        OnGoingStockoutsRMS(domain).send()
Пример #42
0
def first_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        FirstSOHReminder(domain).send()
Пример #43
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            visit_website_process_user(user)
Пример #44
0
 def _get_logistics_domains(self):
     from custom.ewsghana.models import EWSGhanaConfig
     return ILSGatewayConfig.get_all_enabled_domains() + EWSGhanaConfig.get_all_enabled_domains()
Пример #45
0
def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        VisitWebsiteReminder(domain).send()
Пример #46
0
def on_going_stockout():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            on_going_stockout_process_user(user)
Пример #47
0
def urgent_non_reporting():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            urgent_non_reporting_process_user(user)