gaard-api 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gaard_api-0.1.1/MANIFEST.in +2 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/PKG-INFO +11 -3
- {gaard_api-0.1.0 → gaard_api-0.1.1}/README.md +10 -2
- {gaard_api-0.1.0 → gaard_api-0.1.1}/pyproject.toml +10 -2
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/database.py +0 -29
- gaard_api-0.1.1/src/gaard_api/example_data/__init__.py +1 -0
- gaard_api-0.1.1/src/gaard_api/example_data/medical_poc/__init__.py +1 -0
- gaard_api-0.1.1/src/gaard_api/example_data/medical_poc/schema.sql +140 -0
- gaard_api-0.1.1/src/gaard_api/example_data/medical_poc/seed.sql +635 -0
- gaard_api-0.1.1/src/gaard_api/example_database.py +135 -0
- gaard_api-0.1.1/src/gaard_api/server_cli.py +62 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api.egg-info/PKG-INFO +11 -3
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api.egg-info/SOURCES.txt +6 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/tests/test_admin_api.py +23 -15
- gaard_api-0.1.1/tests/test_server_cli.py +111 -0
- gaard_api-0.1.0/src/gaard_api/server_cli.py +0 -25
- gaard_api-0.1.0/tests/test_server_cli.py +0 -20
- {gaard_api-0.1.0 → gaard_api-0.1.1}/setup.cfg +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/defaults.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/models.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/prompt_runtime.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/security.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin/services.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin-web/assets/main.js +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin-web/assets/styles.css +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin-web/index.html +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/admin-web/src/main.ts +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/api/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/api/v1/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/api/v1/admin.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/api/v1/prompts.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/api/v1/query.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/api/v1/schema.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/cli.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/cli_commands.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/core/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/core/error_handlers.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/core/schema_cache.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/core/settings.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/dependencies/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/main.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/schemas/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api/services/__init__.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api.egg-info/dependency_links.txt +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api.egg-info/entry_points.txt +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api.egg-info/requires.txt +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/src/gaard_api.egg-info/top_level.txt +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/tests/test_error_handlers.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/tests/test_investigation_error_messages.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/tests/test_prompt_runtime.py +0 -0
- {gaard_api-0.1.0 → gaard_api-0.1.1}/tests/test_settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gaard-api
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: GAARD backend web services providing admin interface
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -34,11 +34,19 @@ For more informacion see https://github.com/pkroliszewski/gaard
|
|
|
34
34
|
After installation, start it with:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
+
gaard-core install-example-database
|
|
37
38
|
gaard-core start
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
`gaard-core install-example-database` creates the bundled Medical POC SQLite
|
|
42
|
+
database at `examples/medical-poc/demo.db` in the current working directory,
|
|
43
|
+
registers it as the active `default` datasource in `metadata.db`, and matches
|
|
44
|
+
the default datasource URL. Use
|
|
45
|
+
`gaard-core install-example-database --output /path/to/demo.db` to place it
|
|
46
|
+
elsewhere; the command prints the SQLite datasource URL saved in metadata.
|
|
47
|
+
|
|
48
|
+
`gaard-core start` accepts `--host`, `--port`, and `--reload`. By default the
|
|
49
|
+
API is available at `http://localhost:8000` and the admin application at
|
|
42
50
|
`http://localhost:8000/admin`.
|
|
43
51
|
|
|
44
52
|
`gaard-api start` is an alias. `gaard admin` remains available for compatibility.
|
|
@@ -13,11 +13,19 @@ For more informacion see https://github.com/pkroliszewski/gaard
|
|
|
13
13
|
After installation, start it with:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
+
gaard-core install-example-database
|
|
16
17
|
gaard-core start
|
|
17
18
|
```
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
`gaard-core install-example-database` creates the bundled Medical POC SQLite
|
|
21
|
+
database at `examples/medical-poc/demo.db` in the current working directory,
|
|
22
|
+
registers it as the active `default` datasource in `metadata.db`, and matches
|
|
23
|
+
the default datasource URL. Use
|
|
24
|
+
`gaard-core install-example-database --output /path/to/demo.db` to place it
|
|
25
|
+
elsewhere; the command prints the SQLite datasource URL saved in metadata.
|
|
26
|
+
|
|
27
|
+
`gaard-core start` accepts `--host`, `--port`, and `--reload`. By default the
|
|
28
|
+
API is available at `http://localhost:8000` and the admin application at
|
|
21
29
|
`http://localhost:8000/admin`.
|
|
22
30
|
|
|
23
31
|
`gaard-api start` is an alias. `gaard admin` remains available for compatibility.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gaard-api"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = "GAARD backend web services providing admin interface"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -44,7 +44,7 @@ gaard-core = "gaard_api.server_cli:main"
|
|
|
44
44
|
admin = "gaard_api.cli_commands:register"
|
|
45
45
|
|
|
46
46
|
[tool.setuptools]
|
|
47
|
-
include-package-data =
|
|
47
|
+
include-package-data = false
|
|
48
48
|
|
|
49
49
|
[tool.setuptools.packages.find]
|
|
50
50
|
where = ["src"]
|
|
@@ -52,6 +52,14 @@ where = ["src"]
|
|
|
52
52
|
[tool.setuptools.package-data]
|
|
53
53
|
gaard_api = [
|
|
54
54
|
"admin-web/**/*",
|
|
55
|
+
"example_data/medical_poc/*.sql",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.exclude-package-data]
|
|
59
|
+
gaard_api = [
|
|
60
|
+
"**/__pycache__/*",
|
|
61
|
+
"**/*.pyc",
|
|
62
|
+
"**/*.pyo",
|
|
55
63
|
]
|
|
56
64
|
|
|
57
65
|
[tool.ruff]
|
|
@@ -190,22 +190,6 @@ def seed_prompts(session: Session) -> None:
|
|
|
190
190
|
def seed_datasource_connectors(session: Session) -> None:
|
|
191
191
|
migrate_postgres_sql_dialect(session)
|
|
192
192
|
|
|
193
|
-
default_connector = session.scalar(
|
|
194
|
-
select(DatasourceConnector).where(DatasourceConnector.connector_key == "default")
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
if default_connector is None:
|
|
198
|
-
session.add(
|
|
199
|
-
DatasourceConnector(
|
|
200
|
-
connector_key="default",
|
|
201
|
-
name="Medical POC SQLite",
|
|
202
|
-
database_type="sqlite",
|
|
203
|
-
database_url=settings.gaard_datasource_url,
|
|
204
|
-
sql_dialect=settings.gaard_sql_dialect,
|
|
205
|
-
active=True,
|
|
206
|
-
)
|
|
207
|
-
)
|
|
208
|
-
|
|
209
193
|
metadata_connector = session.scalar(
|
|
210
194
|
select(DatasourceConnector).where(DatasourceConnector.connector_key == "metadata-db")
|
|
211
195
|
)
|
|
@@ -230,19 +214,6 @@ def seed_datasource_connectors(session: Session) -> None:
|
|
|
230
214
|
metadata_connector.active = False
|
|
231
215
|
metadata_connector.updated_by = "system"
|
|
232
216
|
|
|
233
|
-
active_user_connector = session.scalar(
|
|
234
|
-
select(DatasourceConnector).where(
|
|
235
|
-
DatasourceConnector.connector_key != "metadata-db",
|
|
236
|
-
DatasourceConnector.active.is_(True),
|
|
237
|
-
)
|
|
238
|
-
)
|
|
239
|
-
default_connector = session.scalar(
|
|
240
|
-
select(DatasourceConnector).where(DatasourceConnector.connector_key == "default")
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
if active_user_connector is None and default_connector is not None:
|
|
244
|
-
default_connector.active = True
|
|
245
|
-
|
|
246
217
|
|
|
247
218
|
def infer_datasource_type(database_url: str) -> tuple[str, str]:
|
|
248
219
|
if database_url.startswith("sqlite"):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Packaged GAARD example data."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Medical POC SQLite example data."""
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
PRAGMA foreign_keys = OFF;
|
|
2
|
+
|
|
3
|
+
DROP TABLE IF EXISTS payments;
|
|
4
|
+
DROP TABLE IF EXISTS lab_results;
|
|
5
|
+
DROP TABLE IF EXISTS prescriptions;
|
|
6
|
+
DROP TABLE IF EXISTS appointment_procedures;
|
|
7
|
+
DROP TABLE IF EXISTS appointment_diagnoses;
|
|
8
|
+
DROP TABLE IF EXISTS medical_procedures;
|
|
9
|
+
DROP TABLE IF EXISTS diagnoses;
|
|
10
|
+
DROP TABLE IF EXISTS appointments;
|
|
11
|
+
DROP TABLE IF EXISTS doctors;
|
|
12
|
+
DROP TABLE IF EXISTS patients;
|
|
13
|
+
|
|
14
|
+
CREATE TABLE patients (
|
|
15
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
16
|
+
first_name TEXT NOT NULL,
|
|
17
|
+
last_name TEXT NOT NULL,
|
|
18
|
+
status TEXT NOT NULL,
|
|
19
|
+
sex TEXT NOT NULL,
|
|
20
|
+
birth_date TEXT,
|
|
21
|
+
city TEXT NOT NULL,
|
|
22
|
+
phone TEXT,
|
|
23
|
+
email TEXT,
|
|
24
|
+
insurance_provider TEXT NOT NULL,
|
|
25
|
+
risk_group TEXT NOT NULL,
|
|
26
|
+
created_at TEXT NOT NULL
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE doctors (
|
|
30
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
31
|
+
first_name TEXT NOT NULL,
|
|
32
|
+
last_name TEXT NOT NULL,
|
|
33
|
+
specialization TEXT NOT NULL,
|
|
34
|
+
license_number TEXT NOT NULL UNIQUE,
|
|
35
|
+
clinic_location TEXT NOT NULL,
|
|
36
|
+
room TEXT NOT NULL,
|
|
37
|
+
hire_date TEXT NOT NULL,
|
|
38
|
+
active INTEGER NOT NULL
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE TABLE appointments (
|
|
42
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
43
|
+
patient_id INTEGER NOT NULL,
|
|
44
|
+
doctor_id INTEGER NOT NULL,
|
|
45
|
+
appointment_date TEXT NOT NULL,
|
|
46
|
+
appointment_time TEXT NOT NULL,
|
|
47
|
+
duration_minutes INTEGER NOT NULL,
|
|
48
|
+
status TEXT NOT NULL,
|
|
49
|
+
visit_type TEXT NOT NULL,
|
|
50
|
+
priority TEXT NOT NULL,
|
|
51
|
+
reason TEXT NOT NULL,
|
|
52
|
+
check_in_at TEXT,
|
|
53
|
+
notes TEXT,
|
|
54
|
+
FOREIGN KEY (patient_id) REFERENCES patients(id),
|
|
55
|
+
FOREIGN KEY (doctor_id) REFERENCES doctors(id)
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE TABLE diagnoses (
|
|
59
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
60
|
+
icd10_code TEXT NOT NULL UNIQUE,
|
|
61
|
+
name TEXT NOT NULL,
|
|
62
|
+
category TEXT NOT NULL,
|
|
63
|
+
chronic INTEGER NOT NULL
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
CREATE TABLE appointment_diagnoses (
|
|
67
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
68
|
+
appointment_id INTEGER NOT NULL,
|
|
69
|
+
diagnosis_id INTEGER NOT NULL,
|
|
70
|
+
is_primary INTEGER NOT NULL,
|
|
71
|
+
notes TEXT,
|
|
72
|
+
FOREIGN KEY (appointment_id) REFERENCES appointments(id),
|
|
73
|
+
FOREIGN KEY (diagnosis_id) REFERENCES diagnoses(id)
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
CREATE TABLE medical_procedures (
|
|
77
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
78
|
+
procedure_code TEXT NOT NULL UNIQUE,
|
|
79
|
+
name TEXT NOT NULL,
|
|
80
|
+
specialization TEXT NOT NULL,
|
|
81
|
+
base_price REAL NOT NULL
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
CREATE TABLE appointment_procedures (
|
|
85
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
86
|
+
appointment_id INTEGER NOT NULL,
|
|
87
|
+
procedure_id INTEGER NOT NULL,
|
|
88
|
+
quantity INTEGER NOT NULL,
|
|
89
|
+
price REAL NOT NULL,
|
|
90
|
+
result_summary TEXT,
|
|
91
|
+
FOREIGN KEY (appointment_id) REFERENCES appointments(id),
|
|
92
|
+
FOREIGN KEY (procedure_id) REFERENCES medical_procedures(id)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
CREATE TABLE prescriptions (
|
|
96
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
97
|
+
appointment_id INTEGER NOT NULL,
|
|
98
|
+
medication_name TEXT NOT NULL,
|
|
99
|
+
dosage TEXT NOT NULL,
|
|
100
|
+
frequency TEXT NOT NULL,
|
|
101
|
+
days_supply INTEGER NOT NULL,
|
|
102
|
+
issued_at TEXT NOT NULL,
|
|
103
|
+
FOREIGN KEY (appointment_id) REFERENCES appointments(id)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
CREATE TABLE lab_results (
|
|
107
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
108
|
+
appointment_id INTEGER NOT NULL,
|
|
109
|
+
test_name TEXT NOT NULL,
|
|
110
|
+
result_value REAL NOT NULL,
|
|
111
|
+
unit TEXT NOT NULL,
|
|
112
|
+
reference_range TEXT NOT NULL,
|
|
113
|
+
abnormal_flag TEXT NOT NULL,
|
|
114
|
+
resulted_at TEXT NOT NULL,
|
|
115
|
+
FOREIGN KEY (appointment_id) REFERENCES appointments(id)
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
CREATE TABLE payments (
|
|
119
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
120
|
+
appointment_id INTEGER NOT NULL,
|
|
121
|
+
payer_type TEXT NOT NULL,
|
|
122
|
+
amount REAL NOT NULL,
|
|
123
|
+
currency TEXT NOT NULL,
|
|
124
|
+
status TEXT NOT NULL,
|
|
125
|
+
payment_method TEXT,
|
|
126
|
+
paid_at TEXT,
|
|
127
|
+
FOREIGN KEY (appointment_id) REFERENCES appointments(id)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
CREATE INDEX idx_patients_status ON patients(status);
|
|
131
|
+
CREATE INDEX idx_patients_city ON patients(city);
|
|
132
|
+
CREATE INDEX idx_doctors_specialization ON doctors(specialization);
|
|
133
|
+
CREATE INDEX idx_appointments_date ON appointments(appointment_date);
|
|
134
|
+
CREATE INDEX idx_appointments_patient ON appointments(patient_id);
|
|
135
|
+
CREATE INDEX idx_appointments_doctor ON appointments(doctor_id);
|
|
136
|
+
CREATE INDEX idx_appointment_diagnoses_appointment ON appointment_diagnoses(appointment_id);
|
|
137
|
+
CREATE INDEX idx_appointment_procedures_appointment ON appointment_procedures(appointment_id);
|
|
138
|
+
CREATE INDEX idx_payments_status ON payments(status);
|
|
139
|
+
|
|
140
|
+
PRAGMA foreign_keys = ON;
|