def get_post_consumption_page(request): facility_list = user_management_views.get_facilities_by_user( request).values('id') query_health_commodity_balance = master_data_models.HealthCommodityBalance.objects.filter( location__in=facility_list, health_commodity__is_active=True).order_by('health_commodity') table = PostConsumptionTable(query_health_commodity_balance) # RequestConfig(request, paginate={'per_page': 25}).configure(table) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] locations = user_management_views.get_parent_child_relationship(request) return render( request, 'MasterDataManagement/PostConsumptionFromELIMS.html', { 'table': table, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items, 'locations': locations })
def get_new_mappings_page(request): query_categories = HealthCommoditiesCategory.objects.filter(is_active=True) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] return render( request, 'MasterDataManagement/NewMappings.html', { 'query_categories': query_categories, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items })
def get_units_page(request): table = UnitsTable(Unit.objects.filter(is_active=True)) form = UnitForm() # RequestConfig(request, paginate={'per_page': 25}).configure(table) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] return render( request, 'MasterDataManagement/Units.html', { 'table': table, 'form': form, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items })
def get_health_commodity_categories_page(request): table = HealthCommodityCategoriesTable( HealthCommoditiesCategory.objects.filter(is_active=True)) form = HealthCommodityCategoryForm() # RequestConfig(request, paginate={'per_page': 25}).configure(table) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] return render( request, 'MasterDataManagement/HealthCommodityCategories.html', { 'table': table, 'form': form, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items })
def get_post_stock_on_hand_page(request): facility_list = user_management_views.get_facilities_by_user( request).values('id') table = PostStockBalanceTable( HealthCommodityBalance.objects.filter(quantity_available__isnull=True, health_commodity__is_active=True, location__in=facility_list)) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] return render( request, 'MasterDataManagement/PostStockOnHand.html', { 'table': table, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items })
def get_location_page(request): table = LocationTable( Location.objects.filter(is_active=True).order_by('id')) form_locations = LocationForm() # RequestConfig(request, paginate={'per_page': 25}).configure(table) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] return render( request, 'MasterDataManagement/LocationManagement.html', { 'table': table, 'form_locations': form_locations, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items })
def get_unmanaged_commodities_by_facility(request, item_pk): # For district level query_health_commodity_balance_by_facility = master_data_models.HealthCommodityBalance.objects.filter( location=item_pk, health_commodity__is_active=True).order_by('health_commodity') unmanaged_commodities_by_facility = query_health_commodity_balance_by_facility.values( 'health_commodity') query_unmanaged_health_commodities_by_facility = HealthCommodity.objects.exclude( Q(id__in=unmanaged_commodities_by_facility)) query_categories = HealthCommoditiesCategory.objects.filter(is_active=True) table_unmanaged_commodities = ManageHealthCommoditiesTable( query_unmanaged_health_commodities_by_facility) form_elims = eLIMSLogin() notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] locations = master_data_models.Location.objects.filter( parent=request.user.profile.location_id) return render( request, 'MasterDataManagement/UnmanagedHealthCommodities.html', { 'table_unmanaged_commodities': table_unmanaged_commodities, 'query_categories': query_categories, 'form': form_elims, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items, 'locations': locations, 'item_pk': item_pk })
def get_health_commodities_page(request): table = HealthCommoditiesTable( HealthCommodity.objects.filter(is_active=True)) form = HealthCommodityForm() form_mapping = HealthCommodityBalanceForm( initial={"location": request.user.profile.location}) # RequestConfig(request, paginate={'per_page': 25}).configure(table) notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] return render( request, 'MasterDataManagement/HealthCommodities.html', { 'table': table, 'form': form, 'form_mapping': form_mapping, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items })
def get_commodity_facility_mappings_page(request): facility_list = user_management_views.get_facilities_by_user( request).values('id') query_health_commodity_balance = master_data_models.HealthCommodityBalance.objects.filter( location__in=facility_list, health_commodity__is_active=True).order_by('health_commodity') unmanaged_commodities = query_health_commodity_balance.values( 'health_commodity') query_unmanaged_health_commodities = HealthCommodity.objects.exclude( Q(id__in=unmanaged_commodities)) query_categories = HealthCommoditiesCategory.objects.filter(is_active=True) table_managed_commodities = HealthCommodityBalanceTable( query_health_commodity_balance) table_unmanaged_commodities = ManageHealthCommoditiesTable( query_unmanaged_health_commodities) form_elims = eLIMSLogin() notifications = flow_management_views.get_dashboard_notification_count( request) unread_messages = notifications[0] scheduled_items = notifications[1] location_id = request.user.profile.location_id query_locations = master_data_models.Location.objects.all() children = [] facility_ids = [] for x in query_locations: if x.parent_id == location_id: if len((user_management_views.get_children_recursively(x.id))) > 0: children.append( user_management_views.get_children_recursively(x.id)) else: facility_ids.append(x.id) for y in children: for z in y: facility_ids.append(z['id']) locations = master_data_models.Location.objects.filter(id__in=facility_ids) return render( request, 'MasterDataManagement/CommodityFacilityMappings.html', { 'table_managed_commodities': table_managed_commodities, 'table_unmanaged_commodities': table_unmanaged_commodities, 'query_categories': query_categories, 'form': form_elims, 'unread_messages': unread_messages, 'scheduled_items': scheduled_items, 'locations': locations })