624 lines
24 KiB
Python
624 lines
24 KiB
Python
# Generated by Django 5.2.6 on 2025-09-19 10:58
|
|
|
|
import django.core.validators
|
|
import django.db.models.deletion
|
|
import uuid
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="DashboardWidget",
|
|
fields=[
|
|
(
|
|
"widget_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=200)),
|
|
("description", models.TextField(blank=True)),
|
|
(
|
|
"widget_type",
|
|
models.CharField(
|
|
choices=[
|
|
("CHART", "Chart Widget"),
|
|
("TABLE", "Table Widget"),
|
|
("METRIC", "Metric Widget"),
|
|
("GAUGE", "Gauge Widget"),
|
|
("MAP", "Map Widget"),
|
|
("TEXT", "Text Widget"),
|
|
("IMAGE", "Image Widget"),
|
|
("IFRAME", "IFrame Widget"),
|
|
("CUSTOM", "Custom Widget"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"chart_type",
|
|
models.CharField(
|
|
blank=True,
|
|
choices=[
|
|
("LINE", "Line Chart"),
|
|
("BAR", "Bar Chart"),
|
|
("PIE", "Pie Chart"),
|
|
("DOUGHNUT", "Doughnut Chart"),
|
|
("AREA", "Area Chart"),
|
|
("SCATTER", "Scatter Plot"),
|
|
("HISTOGRAM", "Histogram"),
|
|
("HEATMAP", "Heat Map"),
|
|
("TREEMAP", "Tree Map"),
|
|
("FUNNEL", "Funnel Chart"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"query_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Query configuration for data source"
|
|
),
|
|
),
|
|
("position_x", models.PositiveIntegerField(default=0)),
|
|
("position_y", models.PositiveIntegerField(default=0)),
|
|
(
|
|
"width",
|
|
models.PositiveIntegerField(
|
|
default=4,
|
|
validators=[
|
|
django.core.validators.MinValueValidator(1),
|
|
django.core.validators.MaxValueValidator(12),
|
|
],
|
|
),
|
|
),
|
|
(
|
|
"height",
|
|
models.PositiveIntegerField(
|
|
default=4,
|
|
validators=[
|
|
django.core.validators.MinValueValidator(1),
|
|
django.core.validators.MaxValueValidator(12),
|
|
],
|
|
),
|
|
),
|
|
(
|
|
"display_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Widget display configuration"
|
|
),
|
|
),
|
|
("color_scheme", models.CharField(default="default", max_length=50)),
|
|
("auto_refresh", models.BooleanField(default=True)),
|
|
(
|
|
"refresh_interval",
|
|
models.PositiveIntegerField(
|
|
default=300, help_text="Refresh interval in seconds"
|
|
),
|
|
),
|
|
("is_active", models.BooleanField(default=True)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
],
|
|
options={
|
|
"db_table": "analytics_dashboard_widget",
|
|
"ordering": ["position_y", "position_x"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="DataSource",
|
|
fields=[
|
|
(
|
|
"source_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=200)),
|
|
("description", models.TextField(blank=True)),
|
|
(
|
|
"source_type",
|
|
models.CharField(
|
|
choices=[
|
|
("DATABASE", "Database Query"),
|
|
("API", "API Endpoint"),
|
|
("FILE", "File Upload"),
|
|
("STREAM", "Real-time Stream"),
|
|
("WEBHOOK", "Webhook"),
|
|
("CUSTOM", "Custom Source"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"connection_type",
|
|
models.CharField(
|
|
choices=[
|
|
("POSTGRESQL", "PostgreSQL"),
|
|
("MYSQL", "MySQL"),
|
|
("SQLITE", "SQLite"),
|
|
("MONGODB", "MongoDB"),
|
|
("REDIS", "Redis"),
|
|
("REST_API", "REST API"),
|
|
("GRAPHQL", "GraphQL"),
|
|
("WEBSOCKET", "WebSocket"),
|
|
("CSV", "CSV File"),
|
|
("JSON", "JSON File"),
|
|
("XML", "XML File"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"connection_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Connection configuration"
|
|
),
|
|
),
|
|
(
|
|
"authentication_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Authentication configuration"
|
|
),
|
|
),
|
|
(
|
|
"query_template",
|
|
models.TextField(
|
|
blank=True, help_text="SQL query or API endpoint template"
|
|
),
|
|
),
|
|
(
|
|
"parameters",
|
|
models.JSONField(default=dict, help_text="Query parameters"),
|
|
),
|
|
(
|
|
"data_transformation",
|
|
models.JSONField(
|
|
default=dict, help_text="Data transformation rules"
|
|
),
|
|
),
|
|
(
|
|
"cache_duration",
|
|
models.PositiveIntegerField(
|
|
default=300, help_text="Cache duration in seconds"
|
|
),
|
|
),
|
|
("is_healthy", models.BooleanField(default=True)),
|
|
("last_health_check", models.DateTimeField(blank=True, null=True)),
|
|
(
|
|
"health_check_interval",
|
|
models.PositiveIntegerField(
|
|
default=300, help_text="Health check interval in seconds"
|
|
),
|
|
),
|
|
("is_active", models.BooleanField(default=True)),
|
|
(
|
|
"last_test_status",
|
|
models.CharField(
|
|
choices=[
|
|
("PENDING", "Pending"),
|
|
("RUNNING", "Running"),
|
|
("SUCCESS", "Success"),
|
|
("FAILURE", "Failure"),
|
|
],
|
|
default="PENDING",
|
|
max_length=20,
|
|
),
|
|
),
|
|
("last_test_start_at", models.DateTimeField(blank=True, null=True)),
|
|
("last_test_end_at", models.DateTimeField(blank=True, null=True)),
|
|
(
|
|
"last_test_duration_seconds",
|
|
models.PositiveIntegerField(blank=True, null=True),
|
|
),
|
|
("last_test_error_message", models.TextField(blank=True)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
],
|
|
options={
|
|
"db_table": "analytics_data_source",
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="MetricDefinition",
|
|
fields=[
|
|
(
|
|
"metric_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=200)),
|
|
("description", models.TextField(blank=True)),
|
|
(
|
|
"metric_type",
|
|
models.CharField(
|
|
choices=[
|
|
("COUNT", "Count"),
|
|
("SUM", "Sum"),
|
|
("AVERAGE", "Average"),
|
|
("PERCENTAGE", "Percentage"),
|
|
("RATIO", "Ratio"),
|
|
("RATE", "Rate"),
|
|
("DURATION", "Duration"),
|
|
("CUSTOM", "Custom Calculation"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"calculation_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Metric calculation configuration"
|
|
),
|
|
),
|
|
(
|
|
"aggregation_period",
|
|
models.CharField(
|
|
choices=[
|
|
("REAL_TIME", "Real-time"),
|
|
("HOURLY", "Hourly"),
|
|
("DAILY", "Daily"),
|
|
("WEEKLY", "Weekly"),
|
|
("MONTHLY", "Monthly"),
|
|
("QUARTERLY", "Quarterly"),
|
|
("YEARLY", "Yearly"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"aggregation_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Aggregation configuration"
|
|
),
|
|
),
|
|
(
|
|
"target_value",
|
|
models.DecimalField(
|
|
blank=True, decimal_places=4, max_digits=15, null=True
|
|
),
|
|
),
|
|
(
|
|
"warning_threshold",
|
|
models.DecimalField(
|
|
blank=True, decimal_places=4, max_digits=15, null=True
|
|
),
|
|
),
|
|
(
|
|
"critical_threshold",
|
|
models.DecimalField(
|
|
blank=True, decimal_places=4, max_digits=15, null=True
|
|
),
|
|
),
|
|
("unit_of_measure", models.CharField(blank=True, max_length=50)),
|
|
(
|
|
"decimal_places",
|
|
models.PositiveIntegerField(
|
|
default=2,
|
|
validators=[django.core.validators.MaxValueValidator(10)],
|
|
),
|
|
),
|
|
("display_format", models.CharField(default="number", max_length=50)),
|
|
("is_active", models.BooleanField(default=True)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
],
|
|
options={
|
|
"db_table": "analytics_metric_definition",
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="MetricValue",
|
|
fields=[
|
|
(
|
|
"value_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("value", models.DecimalField(decimal_places=4, max_digits=15)),
|
|
("period_start", models.DateTimeField()),
|
|
("period_end", models.DateTimeField()),
|
|
(
|
|
"dimensions",
|
|
models.JSONField(
|
|
default=dict,
|
|
help_text="Metric dimensions (e.g., department, provider)",
|
|
),
|
|
),
|
|
(
|
|
"metadata",
|
|
models.JSONField(default=dict, help_text="Additional metadata"),
|
|
),
|
|
(
|
|
"data_quality_score",
|
|
models.DecimalField(
|
|
blank=True,
|
|
decimal_places=2,
|
|
max_digits=5,
|
|
null=True,
|
|
validators=[
|
|
django.core.validators.MinValueValidator(0),
|
|
django.core.validators.MaxValueValidator(100),
|
|
],
|
|
),
|
|
),
|
|
(
|
|
"confidence_level",
|
|
models.DecimalField(
|
|
blank=True,
|
|
decimal_places=2,
|
|
max_digits=5,
|
|
null=True,
|
|
validators=[
|
|
django.core.validators.MinValueValidator(0),
|
|
django.core.validators.MaxValueValidator(100),
|
|
],
|
|
),
|
|
),
|
|
("calculation_timestamp", models.DateTimeField(auto_now_add=True)),
|
|
(
|
|
"calculation_duration_ms",
|
|
models.PositiveIntegerField(blank=True, null=True),
|
|
),
|
|
],
|
|
options={
|
|
"db_table": "analytics_metric_value",
|
|
"ordering": ["-period_start"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="Report",
|
|
fields=[
|
|
(
|
|
"report_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=200)),
|
|
("description", models.TextField(blank=True)),
|
|
(
|
|
"report_type",
|
|
models.CharField(
|
|
choices=[
|
|
("OPERATIONAL", "Operational Report"),
|
|
("FINANCIAL", "Financial Report"),
|
|
("CLINICAL", "Clinical Report"),
|
|
("QUALITY", "Quality Report"),
|
|
("COMPLIANCE", "Compliance Report"),
|
|
("PERFORMANCE", "Performance Report"),
|
|
("CUSTOM", "Custom Report"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"query_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Query configuration for report"
|
|
),
|
|
),
|
|
(
|
|
"output_format",
|
|
models.CharField(
|
|
choices=[
|
|
("PDF", "PDF Document"),
|
|
("EXCEL", "Excel Spreadsheet"),
|
|
("CSV", "CSV File"),
|
|
("JSON", "JSON Data"),
|
|
("HTML", "HTML Page"),
|
|
("EMAIL", "Email Report"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"template_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Report template configuration"
|
|
),
|
|
),
|
|
(
|
|
"schedule_type",
|
|
models.CharField(
|
|
choices=[
|
|
("MANUAL", "Manual Execution"),
|
|
("DAILY", "Daily"),
|
|
("WEEKLY", "Weekly"),
|
|
("MONTHLY", "Monthly"),
|
|
("QUARTERLY", "Quarterly"),
|
|
("YEARLY", "Yearly"),
|
|
("CUSTOM", "Custom Schedule"),
|
|
],
|
|
default="MANUAL",
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"schedule_config",
|
|
models.JSONField(default=dict, help_text="Schedule configuration"),
|
|
),
|
|
("next_execution", models.DateTimeField(blank=True, null=True)),
|
|
(
|
|
"recipients",
|
|
models.JSONField(default=list, help_text="Report recipients"),
|
|
),
|
|
(
|
|
"distribution_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Distribution configuration"
|
|
),
|
|
),
|
|
("is_active", models.BooleanField(default=True)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
],
|
|
options={
|
|
"db_table": "analytics_report",
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="ReportExecution",
|
|
fields=[
|
|
(
|
|
"execution_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
(
|
|
"execution_type",
|
|
models.CharField(
|
|
choices=[
|
|
("MANUAL", "Manual"),
|
|
("SCHEDULED", "Scheduled"),
|
|
("API", "API Triggered"),
|
|
],
|
|
default="MANUAL",
|
|
max_length=20,
|
|
),
|
|
),
|
|
("started_at", models.DateTimeField(auto_now_add=True)),
|
|
("completed_at", models.DateTimeField(blank=True, null=True)),
|
|
(
|
|
"duration_seconds",
|
|
models.PositiveIntegerField(blank=True, null=True),
|
|
),
|
|
(
|
|
"status",
|
|
models.CharField(
|
|
choices=[
|
|
("PENDING", "Pending"),
|
|
("RUNNING", "Running"),
|
|
("COMPLETED", "Completed"),
|
|
("FAILED", "Failed"),
|
|
("CANCELLED", "Cancelled"),
|
|
],
|
|
default="PENDING",
|
|
max_length=20,
|
|
),
|
|
),
|
|
("error_message", models.TextField(blank=True)),
|
|
("output_file_path", models.CharField(blank=True, max_length=500)),
|
|
(
|
|
"output_size_bytes",
|
|
models.PositiveBigIntegerField(blank=True, null=True),
|
|
),
|
|
("record_count", models.PositiveIntegerField(blank=True, null=True)),
|
|
(
|
|
"execution_parameters",
|
|
models.JSONField(default=dict, help_text="Execution parameters"),
|
|
),
|
|
],
|
|
options={
|
|
"db_table": "analytics_report_execution",
|
|
"ordering": ["-started_at"],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name="Dashboard",
|
|
fields=[
|
|
(
|
|
"dashboard_id",
|
|
models.UUIDField(
|
|
default=uuid.uuid4,
|
|
editable=False,
|
|
primary_key=True,
|
|
serialize=False,
|
|
),
|
|
),
|
|
("name", models.CharField(max_length=200)),
|
|
("description", models.TextField(blank=True)),
|
|
(
|
|
"dashboard_type",
|
|
models.CharField(
|
|
choices=[
|
|
("EXECUTIVE", "Executive Dashboard"),
|
|
("CLINICAL", "Clinical Dashboard"),
|
|
("OPERATIONAL", "Operational Dashboard"),
|
|
("FINANCIAL", "Financial Dashboard"),
|
|
("QUALITY", "Quality Dashboard"),
|
|
("PATIENT", "Patient Dashboard"),
|
|
("PROVIDER", "Provider Dashboard"),
|
|
("DEPARTMENT", "Department Dashboard"),
|
|
("CUSTOM", "Custom Dashboard"),
|
|
],
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"layout_config",
|
|
models.JSONField(
|
|
default=dict, help_text="Dashboard layout configuration"
|
|
),
|
|
),
|
|
(
|
|
"refresh_interval",
|
|
models.PositiveIntegerField(
|
|
default=300, help_text="Refresh interval in seconds"
|
|
),
|
|
),
|
|
("is_public", models.BooleanField(default=False)),
|
|
(
|
|
"allowed_roles",
|
|
models.JSONField(
|
|
default=list, help_text="List of allowed user roles"
|
|
),
|
|
),
|
|
("is_active", models.BooleanField(default=True)),
|
|
("is_default", models.BooleanField(default=False)),
|
|
("created_at", models.DateTimeField(auto_now_add=True)),
|
|
("updated_at", models.DateTimeField(auto_now=True)),
|
|
(
|
|
"allowed_users",
|
|
models.ManyToManyField(
|
|
blank=True,
|
|
related_name="accessible_dashboards",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
(
|
|
"created_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"db_table": "analytics_dashboard",
|
|
},
|
|
),
|
|
]
|