1284 lines
43 KiB
HTML
1284 lines
43 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Quality Measurements{% endblock %}
|
|
|
|
{% block css %}
|
|
<link href="{% static 'plugins/datatables.net-bs5/css/dataTables.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'plugins/datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'plugins/datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<style>
|
|
.page-header-section {
|
|
background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
|
|
color: white;
|
|
border-radius: 0.5rem;
|
|
padding: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.stats-cards {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
text-align: center;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.stat-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 3px;
|
|
background: var(--card-color);
|
|
}
|
|
|
|
.stat-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto 1rem;
|
|
color: white;
|
|
font-size: 1.25rem;
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 2rem;
|
|
font-weight: bold;
|
|
color: #495057;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.stat-label {
|
|
color: #6c757d;
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.stat-trend {
|
|
font-size: 0.75rem;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.trend-up { color: #28a745; }
|
|
.trend-down { color: #dc3545; }
|
|
.trend-stable { color: #6c757d; }
|
|
|
|
.filters-section {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.filter-row {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
align-items: end;
|
|
}
|
|
|
|
.measurements-table-section {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.section-header {
|
|
background: #f8f9fa;
|
|
border-bottom: 1px solid #dee2e6;
|
|
padding: 1rem 1.5rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
}
|
|
|
|
.measurement-card {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1rem;
|
|
transition: all 0.2s;
|
|
cursor: pointer;
|
|
position: relative;
|
|
}
|
|
|
|
.measurement-card:hover {
|
|
border-color: #28a745;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.measurement-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 4px;
|
|
background: var(--measurement-color);
|
|
border-radius: 0.5rem 0 0 0.5rem;
|
|
}
|
|
|
|
.measurement-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: start;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.measurement-title {
|
|
font-size: 1.25rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.measurement-id {
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.measurement-badges {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.category-badge {
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.category-clinical { background: #e3f2fd; color: #1976d2; }
|
|
.category-operational { background: #e8f5e8; color: #2e7d32; }
|
|
.category-financial { background: #fff3e0; color: #f57c00; }
|
|
.category-safety { background: #ffebee; color: #d32f2f; }
|
|
.category-satisfaction { background: #f3e5f5; color: #7b1fa2; }
|
|
|
|
.frequency-badge {
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.frequency-daily { background: #e8f5e8; color: #2e7d32; }
|
|
.frequency-weekly { background: #e3f2fd; color: #1976d2; }
|
|
.frequency-monthly { background: #fff3e0; color: #f57c00; }
|
|
.frequency-quarterly { background: #f3e5f5; color: #7b1fa2; }
|
|
.frequency-annually { background: #ffebee; color: #d32f2f; }
|
|
|
|
.measurement-description {
|
|
color: #6c757d;
|
|
margin-bottom: 1rem;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.measurement-meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.meta-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.meta-icon {
|
|
color: #28a745;
|
|
width: 16px;
|
|
}
|
|
|
|
.measurement-metrics {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
padding: 1rem;
|
|
background: #f8f9fa;
|
|
border-radius: 0.375rem;
|
|
}
|
|
|
|
.metric-item {
|
|
text-align: center;
|
|
}
|
|
|
|
.metric-value {
|
|
font-size: 1.5rem;
|
|
font-weight: bold;
|
|
color: #28a745;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.metric-label {
|
|
font-size: 0.75rem;
|
|
color: #6c757d;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.metric-trend {
|
|
font-size: 0.75rem;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.measurement-chart {
|
|
height: 100px;
|
|
background: #f8f9fa;
|
|
border-radius: 0.375rem;
|
|
margin-bottom: 1rem;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #6c757d;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.measurement-actions {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
justify-content: end;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.btn-action {
|
|
padding: 0.375rem 0.75rem;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.25rem;
|
|
background: white;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
text-decoration: none;
|
|
color: #495057;
|
|
}
|
|
|
|
.btn-action:hover {
|
|
border-color: #28a745;
|
|
color: #28a745;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-primary-action {
|
|
background: #28a745;
|
|
border-color: #28a745;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary-action:hover {
|
|
background: #218838;
|
|
border-color: #218838;
|
|
color: white;
|
|
}
|
|
|
|
.quick-filters {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.quick-filter {
|
|
padding: 0.5rem 1rem;
|
|
border: 1px solid #dee2e6;
|
|
background: white;
|
|
border-radius: 0.25rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
text-decoration: none;
|
|
color: #495057;
|
|
}
|
|
|
|
.quick-filter:hover, .quick-filter.active {
|
|
background: #28a745;
|
|
color: white;
|
|
border-color: #28a745;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.target-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.target-bar {
|
|
flex: 1;
|
|
height: 8px;
|
|
background: #e9ecef;
|
|
border-radius: 4px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.target-progress {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #28a745, #20c997);
|
|
border-radius: 4px;
|
|
transition: width 0.3s ease;
|
|
}
|
|
|
|
.target-marker {
|
|
position: absolute;
|
|
top: -2px;
|
|
bottom: -2px;
|
|
width: 2px;
|
|
background: #dc3545;
|
|
border-radius: 1px;
|
|
}
|
|
|
|
.target-text {
|
|
font-size: 0.75rem;
|
|
color: #6c757d;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.view-toggle {
|
|
display: flex;
|
|
gap: 0.25rem;
|
|
background: #f8f9fa;
|
|
border-radius: 0.25rem;
|
|
padding: 0.25rem;
|
|
}
|
|
|
|
.toggle-btn {
|
|
padding: 0.5rem 1rem;
|
|
border: none;
|
|
background: transparent;
|
|
border-radius: 0.25rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.toggle-btn.active {
|
|
background: white;
|
|
color: #28a745;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.bulk-actions {
|
|
background: #f8f9fa;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
padding: 1rem;
|
|
margin-bottom: 1rem;
|
|
display: none;
|
|
}
|
|
|
|
.bulk-actions.show {
|
|
display: block;
|
|
}
|
|
|
|
.measurement-alerts {
|
|
margin-top: 1rem;
|
|
padding: 1rem;
|
|
background: #fff3cd;
|
|
border-radius: 0.375rem;
|
|
border-left: 4px solid #ffc107;
|
|
}
|
|
|
|
.measurement-alerts h6 {
|
|
color: #856404;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
|
|
.alert-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 0.875rem;
|
|
color: #856404;
|
|
}
|
|
|
|
.alert-icon {
|
|
width: 16px;
|
|
height: 16px;
|
|
border-radius: 50%;
|
|
background: #ffc107;
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 0.75rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.page-header-section {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.stats-cards {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.filter-row {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.measurement-header {
|
|
flex-direction: column;
|
|
align-items: start;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.measurement-meta {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.measurement-metrics {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.measurement-actions {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.quick-filters {
|
|
justify-content: center;
|
|
}
|
|
}
|
|
|
|
@media print {
|
|
.filters-section, .bulk-actions, .measurement-actions {
|
|
display: none !important;
|
|
}
|
|
|
|
.section-header {
|
|
background: none;
|
|
border-bottom: 2px solid #000;
|
|
color: #000;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content" class="app-content">
|
|
<!-- Page Header -->
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'quality:dashboard' %}">Quality</a></li>
|
|
<li class="breadcrumb-item active">Measurements</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">
|
|
<i class="fas fa-chart-line me-2"></i>Quality Measurements
|
|
</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<button type="button" class="btn btn-outline-secondary me-2" onclick="exportMeasurements()">
|
|
<i class="fas fa-download me-1"></i>Export
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info me-2" onclick="importMeasurements()">
|
|
<i class="fas fa-upload me-1"></i>Import
|
|
</button>
|
|
<a href="{% url 'quality:measurement_create' %}" class="btn btn-success">
|
|
<i class="fas fa-plus me-1"></i>New Measurement
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Statistics Cards -->
|
|
<div class="stats-cards">
|
|
<div class="stat-card" style="--card-color: #28a745;">
|
|
<div class="stat-icon" style="background: #28a745;">
|
|
<i class="fas fa-chart-line"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.total_measurements|default:0 }}</div>
|
|
<div class="stat-label">Total Measurements</div>
|
|
<div class="stat-trend trend-up">
|
|
<i class="fas fa-arrow-up me-1"></i>+5.2% this month
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #17a2b8;">
|
|
<div class="stat-icon" style="background: #17a2b8;">
|
|
<i class="fas fa-play"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.active_measurements|default:0 }}</div>
|
|
<div class="stat-label">Active</div>
|
|
<div class="stat-trend trend-stable">
|
|
<i class="fas fa-minus me-1"></i>No change
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #ffc107;">
|
|
<div class="stat-icon" style="background: #ffc107;">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.below_target|default:0 }}</div>
|
|
<div class="stat-label">Below Target</div>
|
|
<div class="stat-trend trend-down">
|
|
<i class="fas fa-arrow-down me-1"></i>-2.1% this week
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #dc3545;">
|
|
<div class="stat-icon" style="background: #dc3545;">
|
|
<i class="fas fa-clock"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.overdue_measurements|default:0 }}</div>
|
|
<div class="stat-label">Overdue</div>
|
|
<div class="stat-trend trend-up">
|
|
<i class="fas fa-arrow-up me-1"></i>+1 this week
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #6f42c1;">
|
|
<div class="stat-icon" style="background: #6f42c1;">
|
|
<i class="fas fa-bullseye"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.target_achieved|default:0 }}%</div>
|
|
<div class="stat-label">Target Achievement</div>
|
|
<div class="stat-trend trend-up">
|
|
<i class="fas fa-arrow-up me-1"></i>+3.5% this month
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Filters -->
|
|
<div class="quick-filters">
|
|
<a href="?category=all" class="quick-filter {% if not request.GET.category or request.GET.category == 'all' %}active{% endif %}">
|
|
<i class="fas fa-list me-1"></i>All Measurements
|
|
</a>
|
|
<a href="?category=clinical" class="quick-filter {% if request.GET.category == 'clinical' %}active{% endif %}">
|
|
<i class="fas fa-user-md me-1"></i>Clinical
|
|
</a>
|
|
<a href="?category=operational" class="quick-filter {% if request.GET.category == 'operational' %}active{% endif %}">
|
|
<i class="fas fa-cogs me-1"></i>Operational
|
|
</a>
|
|
<a href="?category=safety" class="quick-filter {% if request.GET.category == 'safety' %}active{% endif %}">
|
|
<i class="fas fa-shield-alt me-1"></i>Safety
|
|
</a>
|
|
<a href="?status=below_target" class="quick-filter {% if request.GET.status == 'below_target' %}active{% endif %}">
|
|
<i class="fas fa-exclamation-triangle me-1"></i>Below Target
|
|
</a>
|
|
<a href="?status=overdue" class="quick-filter {% if request.GET.status == 'overdue' %}active{% endif %}">
|
|
<i class="fas fa-clock me-1"></i>Overdue
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Filters Section -->
|
|
<div class="filters-section">
|
|
<h6 class="mb-3">
|
|
<i class="fas fa-filter me-2"></i>Advanced Filters
|
|
</h6>
|
|
|
|
<form method="get" id="filter-form">
|
|
<div class="filter-row">
|
|
<div>
|
|
<label class="form-label">Search Measurements</label>
|
|
<input type="text" class="form-control" name="search"
|
|
value="{{ request.GET.search }}" placeholder="Search measurements...">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Category</label>
|
|
<select class="form-select" name="category">
|
|
<option value="">All Categories</option>
|
|
<option value="clinical" {% if request.GET.category == 'clinical' %}selected{% endif %}>Clinical Quality</option>
|
|
<option value="operational" {% if request.GET.category == 'operational' %}selected{% endif %}>Operational</option>
|
|
<option value="financial" {% if request.GET.category == 'financial' %}selected{% endif %}>Financial</option>
|
|
<option value="safety" {% if request.GET.category == 'safety' %}selected{% endif %}>Safety</option>
|
|
<option value="satisfaction" {% if request.GET.category == 'satisfaction' %}selected{% endif %}>Patient Satisfaction</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Frequency</label>
|
|
<select class="form-select" name="frequency">
|
|
<option value="">All Frequencies</option>
|
|
<option value="daily" {% if request.GET.frequency == 'daily' %}selected{% endif %}>Daily</option>
|
|
<option value="weekly" {% if request.GET.frequency == 'weekly' %}selected{% endif %}>Weekly</option>
|
|
<option value="monthly" {% if request.GET.frequency == 'monthly' %}selected{% endif %}>Monthly</option>
|
|
<option value="quarterly" {% if request.GET.frequency == 'quarterly' %}selected{% endif %}>Quarterly</option>
|
|
<option value="annually" {% if request.GET.frequency == 'annually' %}selected{% endif %}>Annually</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Department</label>
|
|
<select class="form-select" name="department">
|
|
<option value="">All Departments</option>
|
|
{% for dept in departments %}
|
|
<option value="{{ dept.id }}" {% if request.GET.department == dept.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ dept.name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Status</label>
|
|
<select class="form-select" name="status">
|
|
<option value="">All Statuses</option>
|
|
<option value="active" {% if request.GET.status == 'active' %}selected{% endif %}>Active</option>
|
|
<option value="below_target" {% if request.GET.status == 'below_target' %}selected{% endif %}>Below Target</option>
|
|
<option value="overdue" {% if request.GET.status == 'overdue' %}selected{% endif %}>Overdue</option>
|
|
<option value="inactive" {% if request.GET.status == 'inactive' %}selected{% endif %}>Inactive</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fas fa-search me-1"></i>Filter
|
|
</button>
|
|
<a href="{% url 'quality:measurement_list' %}" class="btn btn-outline-secondary ms-2">
|
|
<i class="fas fa-times me-1"></i>Clear
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Bulk Actions -->
|
|
<div class="bulk-actions" id="bulk-actions">
|
|
<div class="d-flex align-items-center justify-content-between">
|
|
<div>
|
|
<span id="selected-count">0</span> measurements selected
|
|
</div>
|
|
<div>
|
|
<button type="button" class="btn btn-outline-primary btn-sm me-2" onclick="bulkExport()">
|
|
<i class="fas fa-download me-1"></i>Export Selected
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info btn-sm me-2" onclick="bulkUpdate()">
|
|
<i class="fas fa-edit me-1"></i>Update Status
|
|
</button>
|
|
<button type="button" class="btn btn-outline-success btn-sm me-2" onclick="bulkRecalculate()">
|
|
<i class="fas fa-calculator me-1"></i>Recalculate
|
|
</button>
|
|
<button type="button" class="btn btn-outline-danger btn-sm" onclick="bulkDeactivate()">
|
|
<i class="fas fa-pause me-1"></i>Deactivate Selected
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Measurements Section -->
|
|
<div class="measurements-table-section">
|
|
<div class="section-header">
|
|
<div>
|
|
<i class="fas fa-chart-line me-2"></i>Quality Measurements ({{ measurements|length }})
|
|
</div>
|
|
<div class="d-flex align-items-center gap-2">
|
|
<div class="view-toggle">
|
|
<button type="button" class="toggle-btn active" onclick="setView('cards')" data-view="cards">
|
|
<i class="fas fa-th-large"></i>
|
|
</button>
|
|
<button type="button" class="toggle-btn" onclick="setView('table')" data-view="table">
|
|
<i class="fas fa-table"></i>
|
|
</button>
|
|
</div>
|
|
<div class="form-check form-switch">
|
|
<input class="form-check-input" type="checkbox" id="select-all">
|
|
<label class="form-check-label" for="select-all">Select All</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="p-3" id="measurements-container">
|
|
{% for measurement in measurements %}
|
|
<div class="measurement-card" style="--measurement-color: {% if measurement.category == 'clinical' %}#1976d2{% elif measurement.category == 'operational' %}#2e7d32{% elif measurement.category == 'financial' %}#f57c00{% elif measurement.category == 'safety' %}#d32f2f{% else %}#7b1fa2{% endif %};" onclick="viewMeasurement({{ measurement.id }})">
|
|
<div class="form-check position-absolute" style="top: 1rem; left: 1rem;">
|
|
<input class="form-check-input measurement-checkbox" type="checkbox" value="{{ measurement.id }}" onclick="event.stopPropagation();">
|
|
</div>
|
|
|
|
<div class="measurement-header">
|
|
<div>
|
|
<div class="measurement-title">{{ measurement.name }}</div>
|
|
<div class="measurement-id">ID: {{ measurement.measurement_id|default:measurement.id }}</div>
|
|
</div>
|
|
<div class="measurement-badges">
|
|
<span class="category-badge category-{{ measurement.category|lower }}">
|
|
{{ measurement.get_category_display }}
|
|
</span>
|
|
<span class="frequency-badge frequency-{{ measurement.frequency|lower }}">
|
|
{{ measurement.get_frequency_display }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="measurement-description">
|
|
{{ measurement.description|truncatechars:200 }}
|
|
</div>
|
|
|
|
<div class="measurement-meta">
|
|
<div class="meta-item">
|
|
<i class="fas fa-building meta-icon"></i>
|
|
<span>{{ measurement.department.name|default:"No Department" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-user meta-icon"></i>
|
|
<span>{{ measurement.owner.get_full_name|default:"No Owner" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-calendar-alt meta-icon"></i>
|
|
<span>{{ measurement.created_at|date:"M d, Y"|default:"Not set" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-calendar-check meta-icon"></i>
|
|
<span>Next: {{ measurement.next_measurement_date|date:"M d, Y"|default:"Not scheduled" }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="measurement-metrics">
|
|
<div class="metric-item">
|
|
<div class="metric-value">{{ measurement.current_value|default:"-" }}</div>
|
|
<div class="metric-label">Current</div>
|
|
<div class="metric-trend trend-{% if measurement.trend == 'up' %}up{% elif measurement.trend == 'down' %}down{% else %}stable{% endif %}">
|
|
<i class="fas fa-arrow-{% if measurement.trend == 'up' %}up{% elif measurement.trend == 'down' %}down{% else %}right{% endif %} me-1"></i>
|
|
{{ measurement.trend_percentage|default:"0" }}%
|
|
</div>
|
|
</div>
|
|
|
|
<div class="metric-item">
|
|
<div class="metric-value">{{ measurement.target_value|default:"-" }}</div>
|
|
<div class="metric-label">Target</div>
|
|
</div>
|
|
|
|
<div class="metric-item">
|
|
<div class="metric-value">{{ measurement.benchmark|default:"-" }}</div>
|
|
<div class="metric-label">Benchmark</div>
|
|
</div>
|
|
|
|
<div class="metric-item">
|
|
<div class="metric-value">{{ measurement.achievement_percentage|default:0 }}%</div>
|
|
<div class="metric-label">Achievement</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if measurement.target_value %}
|
|
<div class="target-indicator">
|
|
<div class="target-text">Progress:</div>
|
|
<div class="target-bar">
|
|
<div class="target-progress" style="width: {{ measurement.achievement_percentage|default:0 }}%;"></div>
|
|
<div class="target-marker" style="left: 100%;"></div>
|
|
</div>
|
|
<div class="target-text">{{ measurement.achievement_percentage|default:0 }}%</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="measurement-chart">
|
|
<i class="fas fa-chart-area me-2"></i>
|
|
Trend chart placeholder - {{ measurement.data_points.count|default:0 }} data points
|
|
</div>
|
|
|
|
{% if measurement.alerts.exists %}
|
|
<div class="measurement-alerts">
|
|
<h6><i class="fas fa-exclamation-triangle me-2"></i>Active Alerts</h6>
|
|
{% for alert in measurement.alerts.all|slice:":3" %}
|
|
<div class="alert-item">
|
|
<div class="alert-icon">
|
|
<i class="fas fa-exclamation"></i>
|
|
</div>
|
|
<span>{{ alert.message|truncatechars:60 }}</span>
|
|
</div>
|
|
{% endfor %}
|
|
{% if measurement.alerts.count > 3 %}
|
|
<div class="text-muted">+{{ measurement.alerts.count|add:"-3" }} more alerts</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="measurement-actions">
|
|
<a href="{% url 'quality:measurement_detail' measurement.id %}" class="btn-action" onclick="event.stopPropagation();">
|
|
<i class="fas fa-eye me-1"></i>View
|
|
</a>
|
|
{% if measurement.can_edit %}
|
|
<a href="{% url 'quality:measurement_edit' measurement.id %}" class="btn-action" onclick="event.stopPropagation();">
|
|
<i class="fas fa-edit me-1"></i>Edit
|
|
</a>
|
|
{% endif %}
|
|
<button type="button" class="btn-action" onclick="event.stopPropagation(); recordMeasurement({{ measurement.id }});">
|
|
<i class="fas fa-plus me-1"></i>Record Data
|
|
</button>
|
|
<button type="button" class="btn-primary-action" onclick="event.stopPropagation(); viewTrends({{ measurement.id }});">
|
|
<i class="fas fa-chart-line me-1"></i>Trends
|
|
</button>
|
|
<button type="button" class="btn-action" onclick="event.stopPropagation(); generateReport({{ measurement.id }});">
|
|
<i class="fas fa-file-alt me-1"></i>Report
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="text-center py-5">
|
|
<div class="text-muted">
|
|
<i class="fas fa-chart-line fa-3x mb-3"></i>
|
|
<h5>No Quality Measurements Found</h5>
|
|
<p>No measurements match your current filters.</p>
|
|
<a href="{% url 'quality:measurement_create' %}" class="btn btn-success">
|
|
<i class="fas fa-plus me-1"></i>Create First Measurement
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if is_paginated %}
|
|
<div class="d-flex justify-content-between align-items-center p-3">
|
|
<div class="text-muted">
|
|
Showing {{ measurements|length }} of {{ total_measurements }} measurements
|
|
</div>
|
|
|
|
<nav aria-label="Measurements pagination">
|
|
<ul class="pagination pagination-sm mb-0">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{{ request.GET.urlencode }}">First</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{{ request.GET.urlencode }}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
<li class="page-item active">
|
|
<span class="page-link">{{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
|
|
</li>
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.next_page_number }}{{ request.GET.urlencode }}">Next</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{{ request.GET.urlencode }}">Last</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Record Data Modal -->
|
|
<div class="modal fade" id="recordDataModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="fas fa-plus me-2"></i>Record Measurement Data
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Measurement Value</label>
|
|
<input type="number" class="form-control" id="measurement-value"
|
|
placeholder="Enter measurement value" step="0.01">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Measurement Date</label>
|
|
<input type="date" class="form-control" id="measurement-date"
|
|
value="{{ today|date:'Y-m-d' }}">
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Notes</label>
|
|
<textarea class="form-control" id="measurement-notes" rows="3"
|
|
placeholder="Optional notes about this measurement..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-success" onclick="saveMeasurementData()">
|
|
<i class="fas fa-save me-1"></i>Record Data
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bulk Update Modal -->
|
|
<div class="modal fade" id="bulkUpdateModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="fas fa-edit me-2"></i>Bulk Update Measurements
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Update Action</label>
|
|
<select class="form-select" id="bulk-action">
|
|
<option value="">Select Action</option>
|
|
<option value="activate">Activate</option>
|
|
<option value="deactivate">Deactivate</option>
|
|
<option value="recalculate">Recalculate Targets</option>
|
|
<option value="reset">Reset Data</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Reason</label>
|
|
<textarea class="form-control" id="bulk-reason" rows="3"
|
|
placeholder="Please provide a reason for this bulk update..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-primary" onclick="confirmBulkUpdate()">
|
|
<i class="fas fa-check me-1"></i>Update Selected
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script src="{% static 'plugins/datatables.net/js/dataTables.min.js' %}"></script>
|
|
<script src="{% static 'plugins/datatables.net-bs5/js/dataTables.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'plugins/datatables.net-responsive-bs5/js/responsive.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'plugins/datatables.net-buttons-bs5/js/buttons.bootstrap5.min.js' %}"></script>
|
|
|
|
<script>
|
|
let selectedMeasurements = [];
|
|
let currentMeasurementId = null;
|
|
|
|
$(document).ready(function() {
|
|
// Handle select all checkbox
|
|
$('#select-all').change(function() {
|
|
$('.measurement-checkbox').prop('checked', this.checked);
|
|
updateBulkActions();
|
|
});
|
|
|
|
// Handle individual checkboxes
|
|
$('.measurement-checkbox').change(function() {
|
|
updateBulkActions();
|
|
|
|
// Update select all checkbox
|
|
const totalCheckboxes = $('.measurement-checkbox').length;
|
|
const checkedCheckboxes = $('.measurement-checkbox:checked').length;
|
|
$('#select-all').prop('checked', totalCheckboxes === checkedCheckboxes);
|
|
});
|
|
});
|
|
|
|
function updateBulkActions() {
|
|
const selectedCount = $('.measurement-checkbox:checked').length;
|
|
$('#selected-count').text(selectedCount);
|
|
|
|
if (selectedCount > 0) {
|
|
$('#bulk-actions').addClass('show');
|
|
} else {
|
|
$('#bulk-actions').removeClass('show');
|
|
}
|
|
|
|
selectedMeasurements = $('.measurement-checkbox:checked').map(function() {
|
|
return this.value;
|
|
}).get();
|
|
}
|
|
|
|
function setView(viewType) {
|
|
$('.toggle-btn').removeClass('active');
|
|
$(`[data-view="${viewType}"]`).addClass('active');
|
|
|
|
// In a real implementation, this would switch between card and table views
|
|
if (viewType === 'table') {
|
|
// Convert to table view
|
|
showAlert('Table view activated', 'info');
|
|
} else {
|
|
// Convert to card view
|
|
showAlert('Card view activated', 'info');
|
|
}
|
|
}
|
|
|
|
function viewMeasurement(measurementId) {
|
|
window.location.href = `/quality/measurements/${measurementId}/`;
|
|
}
|
|
|
|
function recordMeasurement(measurementId) {
|
|
currentMeasurementId = measurementId;
|
|
new bootstrap.Modal(document.getElementById('recordDataModal')).show();
|
|
}
|
|
|
|
function saveMeasurementData() {
|
|
const value = document.getElementById('measurement-value').value;
|
|
const date = document.getElementById('measurement-date').value;
|
|
const notes = document.getElementById('measurement-notes').value;
|
|
|
|
if (!value) {
|
|
showAlert('Please enter a measurement value', 'warning');
|
|
return;
|
|
}
|
|
|
|
fetch(`/quality/measurements/${currentMeasurementId}/record-data/`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
value: value,
|
|
date: date,
|
|
notes: notes
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert('Measurement data recorded successfully', 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error recording measurement data', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error recording measurement data', 'danger');
|
|
});
|
|
|
|
bootstrap.Modal.getInstance(document.getElementById('recordDataModal')).hide();
|
|
}
|
|
|
|
function viewTrends(measurementId) {
|
|
window.open(`/quality/measurements/${measurementId}/trends/`, '_blank');
|
|
}
|
|
|
|
function generateReport(measurementId) {
|
|
window.open(`/quality/measurements/${measurementId}/report/`, '_blank');
|
|
}
|
|
|
|
function exportMeasurements() {
|
|
const selectedMeasurements = $('.measurement-checkbox:checked').map(function() {
|
|
return this.value;
|
|
}).get();
|
|
|
|
let url = '/quality/measurements/export/';
|
|
if (selectedMeasurements.length > 0) {
|
|
url += '?measurements=' + selectedMeasurements.join(',');
|
|
}
|
|
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
function importMeasurements() {
|
|
// Create file input for importing measurements
|
|
const input = document.createElement('input');
|
|
input.type = 'file';
|
|
input.accept = '.csv,.xlsx';
|
|
input.onchange = function(e) {
|
|
const file = e.target.files[0];
|
|
if (file) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
|
|
fetch('/quality/measurements/import/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
},
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.imported_count} measurements imported successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error importing measurements: ' + (data.error || 'Unknown error'), 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error importing measurements', 'danger');
|
|
});
|
|
}
|
|
};
|
|
input.click();
|
|
}
|
|
|
|
function bulkExport() {
|
|
if (selectedMeasurements.length === 0) {
|
|
showAlert('Please select measurements to export', 'warning');
|
|
return;
|
|
}
|
|
|
|
const url = '/quality/measurements/export/?measurements=' + selectedMeasurements.join(',');
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
function bulkUpdate() {
|
|
if (selectedMeasurements.length === 0) {
|
|
showAlert('Please select measurements to update', 'warning');
|
|
return;
|
|
}
|
|
|
|
new bootstrap.Modal(document.getElementById('bulkUpdateModal')).show();
|
|
}
|
|
|
|
function confirmBulkUpdate() {
|
|
const action = document.getElementById('bulk-action').value;
|
|
const reason = document.getElementById('bulk-reason').value;
|
|
|
|
if (!action) {
|
|
showAlert('Please select an action', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (!reason.trim()) {
|
|
showAlert('Please provide a reason for this update', 'warning');
|
|
return;
|
|
}
|
|
|
|
fetch('/quality/measurements/bulk-update/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
measurement_ids: selectedMeasurements,
|
|
action: action,
|
|
reason: reason
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.updated_count} measurements updated successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error updating measurements', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error updating measurements', 'danger');
|
|
});
|
|
|
|
bootstrap.Modal.getInstance(document.getElementById('bulkUpdateModal')).hide();
|
|
}
|
|
|
|
function bulkRecalculate() {
|
|
if (selectedMeasurements.length === 0) {
|
|
showAlert('Please select measurements to recalculate', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (confirm(`Recalculate targets for ${selectedMeasurements.length} selected measurements?`)) {
|
|
fetch('/quality/measurements/bulk-recalculate/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
measurement_ids: selectedMeasurements
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.recalculated_count} measurements recalculated successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error recalculating measurements', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error recalculating measurements', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function bulkDeactivate() {
|
|
if (selectedMeasurements.length === 0) {
|
|
showAlert('Please select measurements to deactivate', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (confirm(`Deactivate ${selectedMeasurements.length} selected measurements?`)) {
|
|
fetch('/quality/measurements/bulk-deactivate/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
measurement_ids: selectedMeasurements
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.deactivated_count} measurements deactivated successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error deactivating measurements', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error deactivating measurements', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function showAlert(message, type) {
|
|
const alertDiv = document.createElement('div');
|
|
alertDiv.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
|
|
alertDiv.style.cssText = 'top: 20px; right: 20px; z-index: 1060; min-width: 300px;';
|
|
alertDiv.innerHTML = `
|
|
${message}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
`;
|
|
|
|
document.body.appendChild(alertDiv);
|
|
|
|
setTimeout(() => {
|
|
if (alertDiv.parentNode) {
|
|
alertDiv.remove();
|
|
}
|
|
}, 5000);
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|