Skip to content

Commit 3e11fa1

Browse files
Final Release: Gemini Summaries & RAGAS Eval
1 parent 84cb0f4 commit 3e11fa1

392 files changed

Lines changed: 4050 additions & 24181 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/auth.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
import hashlib
3+
import json
4+
import secrets
5+
from pathlib import Path
6+
from typing import Dict, Any, Optional
7+
8+
# Path to the auth database
9+
AUTH_DB_PATH = Path("data/auth.json")
10+
11+
def _load_db() -> Dict[str, Any]:
12+
if not AUTH_DB_PATH.exists():
13+
return {}
14+
try:
15+
return json.loads(AUTH_DB_PATH.read_text(encoding="utf-8"))
16+
except Exception:
17+
return {}
18+
19+
def _save_db(db: Dict[str, Any]) -> None:
20+
# ensure parent dir exists
21+
AUTH_DB_PATH.parent.mkdir(parents=True, exist_ok=True)
22+
AUTH_DB_PATH.write_text(json.dumps(db, indent=2), encoding="utf-8")
23+
24+
def _hash_password(password: str, salt: str) -> str:
25+
"""Hash password using PBKDF2-HMAC-SHA256."""
26+
return hashlib.pbkdf2_hmac(
27+
'sha256',
28+
password.encode('utf-8'),
29+
salt.encode('utf-8'),
30+
100000
31+
).hex()
32+
33+
def user_exists(username: str) -> bool:
34+
db = _load_db()
35+
return username in db
36+
37+
def has_password(username: str) -> bool:
38+
"""Check if a registered user has a password set."""
39+
db = _load_db()
40+
user = db.get(username)
41+
if not user:
42+
return False
43+
return bool(user.get("password_hash"))
44+
45+
def register_user(username: str, password: str) -> bool:
46+
"""Register a new user or set password for existing user without one."""
47+
db = _load_db()
48+
49+
# Generate Salt
50+
salt = secrets.token_hex(16)
51+
pw_hash = _hash_password(password, salt)
52+
53+
payload = {
54+
"password_hash": pw_hash,
55+
"salt": salt,
56+
"created_at": db.get(username, {}).get("created_at") # preserve or None
57+
}
58+
59+
# Update DB
60+
db[username] = payload
61+
_save_db(db)
62+
return True
63+
64+
def verify_credentials(username: str, password: str) -> bool:
65+
db = _load_db()
66+
user = db.get(username)
67+
if not user:
68+
return False
69+
70+
stored_hash = user.get("password_hash")
71+
salt = user.get("salt")
72+
73+
if not stored_hash or not salt:
74+
return False
75+
76+
check_hash = _hash_password(password, salt)
77+
return secrets.compare_digest(stored_hash, check_hash)
78+
79+
def get_user_status(username: str) -> str:
80+
"""Return status: 'unknown', 'migrate_required', 'active'."""
81+
db = _load_db()
82+
83+
if username not in db:
84+
# Check if session folder exists (Existing user but not in auth DB yet)
85+
# This is for "Legacy Users" like Founder who exist on disk but not in auth.json
86+
from backend.session import session_dir
87+
if session_dir(username).exists():
88+
return "migrate_required"
89+
return "unknown"
90+
91+
user = db.get(username)
92+
if not user.get("password_hash"):
93+
return "migrate_required"
94+
95+
return "active"

backend/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _get_bool(env_var: str, default: bool) -> bool:
1313
return value.strip().lower() in {"1", "true", "yes", "on"}
1414

1515

16-
USE_ELASTIC: Final[bool] = _get_bool("USE_ELASTIC", False)
16+
USE_ELASTIC: Final[bool] = False # _get_bool("USE_ELASTIC", False)
1717
USE_VERTEX: Final[bool] = _get_bool("USE_VERTEX", False)
1818

1919
ELASTIC_URL: Final[str] = os.getenv("ELASTIC_URL", "http://localhost:9200")

backend/data/cpt_codes_2024.csv

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
cpt,description,allowed_amount
2+
99202,"Office/outpatient visit, new patient, 15-29 min",73.40
3+
99203,"Office/outpatient visit, new patient, 30-44 min",113.00
4+
99204,"Office/outpatient visit, new patient, 45-59 min",167.00
5+
99205,"Office/outpatient visit, new patient, 60-74 min",220.00
6+
99211,"Office/outpatient visit, est patient, minimal problems",23.00
7+
99212,"Office/outpatient visit, est patient, 10-19 min",56.00
8+
99213,"Office/outpatient visit, est patient, 20-29 min",92.05
9+
99214,"Office/outpatient visit, est patient, 30-39 min",129.80
10+
99215,"Office/outpatient visit, est patient, 40-54 min",183.00
11+
G2211,"Visit complex inherent to E/M",16.05
12+
36415,"Collection of venous blood by venipuncture",3.00
13+
80053,"Comprehensive metabolic panel",11.20
14+
85025,"Blood count; complete (CBC), automated",8.50
15+
80061,"Lipid panel",10.50
16+
84443,"Thyroid stimulating hormone (TSH)",18.00
17+
93000,"Electrocardiogram, routine ECG with at least 12 leads",15.50
18+
71046,"Radiologic examination, chest; 2 views",30.15
19+
73030,"Radiologic examination, shoulder; complete, min 2 views",28.32
20+
97110,"Therapeutic procedure, 1 or more areas, each 15 min; exercises",26.50
21+
97140,"Manual therapy techniques (eg, mobilization/manipulation)",24.00
22+
90834,"Psychotherapy, 45 minutes with patient",105.00
23+
90837,"Psychotherapy, 60 minutes with patient",155.00
24+
99283,"Emergency department visit, moderate severity",185.00
25+
99284,"Emergency department visit, high severity",310.00
26+
99285,"Emergency department visit, high severity, threat to function",480.00
27+
10060,"Incision and drainage of abscess",120.00
28+
17000,"Destruction of premalignant lesions (eg, actinic keratoses)",80.00
29+
17110,"Destruction of benign lesions up to 14",110.00
30+
20610,"Arthrocentesis, aspiration and/or injection, major joint",75.00
31+
27447,"Arthroplasty, knee, condyle and plateau (Total Knee)",1400.00
32+
27130,"Arthroplasty, acetabular and proximal femoral (Total Hip)",1350.00
33+
45378,"Colonoscopy, flexible; diagnostic",240.00
34+
43239,"EGD upper GI endoscopy, biopsy",280.00
35+
66984,"Extracapsular cataract removal with insertion of IOL",600.00
36+
K0001,"Standard wheelchair",45.00
37+
E0570,"Nebulizer, with compressor",30.00
38+
J7613,"Albuterol, inhalation solution, fda-approved final product",0.15
39+
J1100,"Injection, dexamethasone sodium phosphate, 1 mg",0.10
40+
J3301,"Injection, triamcinolone acetonide, not otherwise specified, 10 mg",2.50
41+
90471,"Immunization administration",25.00
42+
90677,"Pneumococcal conjugate vaccine, 20 valent",260.00
43+
90715,"Tetanus, diphtheria toxoids and acellular pertussis vaccine",45.00
44+
J0171,"Injection, Adrenalin, 0.1 mg",0.80
45+
A0427,"Ambulance service, advanced life support, emergency transport",450.00
46+
A0425,"Ground mileage, per statute mile",8.50
47+
10061,"Incision and drainage of abscess; complicated or multiple",285.00
48+
11042,"Debridement, subcutaneous tissue; first 20 sq cm",140.00
49+
11730,"Avulsion of nail plate, partial or complete, simple; single",95.00
50+
12001,"Simple repair of superficial wounds of scalp, neck, axillae, ext genitalia, trunk/extremities",130.00
51+
17004,"Destruction of premalignant lesions, 15 or more lesions",170.00
52+
17260,"Destruction, malignant lesion (eg, laser surgery, electrosurgery, cryosurgery)",115.00
53+
20550,"Injection(s); single tendon sheath, or ligament, aponeurosis",55.00
54+
20605,"Arthrocentesis, aspiration and/or injection, intermediate joint or bursa",50.00
55+
27445,"Arthroplasty, knee, hinge prothesis",1600.00
56+
29881,"Arthroscopy, knee, surgical; with meniscectomy",600.00
57+
31231,"Nasal endoscopy, diagnostic, unilateral or bilateral",190.00
58+
43235,"Upper gastrointestinal endoscopy including esophagus, stomach, and either the duodenum",350.00
59+
45380,"Colonoscopy, flexible; with biopsy, single or multiple",480.00
60+
45385,"Colonoscopy, flexible; with removal of tumor(s), polyp(s), or other lesion(s)",520.00
61+
59400,"Routine obstetric care including antepartum care, vaginal delivery",2100.00
62+
59510,"Routine obstetric care including antepartum care, cesarean delivery",2400.00
63+
64483,"Injection(s), anesthetic agent and/or steroid, transforaminal epidural",310.00
64+
66982,"Extracapsular cataract removal with insertion of intraocular lens prosthesis",750.00
65+
67028,"Intravitreal injection of a pharmacologic agent",100.00
66+
70450,"CT head or brain; without contrast material",140.00
67+
70553,"MRI brain stem; without contrast material followed by contrast",320.00
68+
71045,"Radiologic examination, chest; single view",25.00
69+
72148,"MRI lumbar spine; without contrast material",290.00
70+
73721,"MRI joint of lower extremity; without contrast material",280.00
71+
74176,"CT abdomen and pelvis; without contrast material",310.00
72+
76700,"Ultrasound, abdominal, real time with image documentation; complete",130.00
73+
73502,"Radiologic examination, hip, unilateral; with pelvis",35.00
74+
80048,"Basic metabolic panel (Calcium, total)",9.50
75+
80305,"Drug test(s), presumptive, any number of drug classes, optical observation",12.00
76+
81001,"Urinalysis, by dip stick or tablet reagent; automated",3.50
77+
82306,"Vitamin D; 25 hydroxy, includes fraction(s), if performed",35.00
78+
83036,"Hemoglobin; glycosylated (A1C)",11.00
79+
84153,"Prostate specific antigen (PSA); total",22.00
80+
84439,"Thyroxine; free",10.50
81+
85018,"Blood count; hemoglobin",2.50
82+
85610,"Prothrombin time",4.50
83+
87086,"Culture, bacterial; quantitative colony count, urine",9.00
84+
87804,"Infectious agent antigen detection by immunoassay with direct optical observation; Influenza",14.00
85+
87880,"Infectious agent antigen detection by immunoassay with direct optical observation; Strep A",14.00
86+
90791,"Psychiatric diagnostic evaluation",145.00
87+
90853,"Group psychotherapy (other than of a multiple-family group)",30.00
88+
92004,"Ophthalmological services: medical examination and evaluation",140.00
89+
92014,"Ophthalmological services: medical examination and evaluation, est patient",110.00
90+
93306,"Echocardiography, transthoracic, real-time with image documentation",210.00
91+
94010,"Spirometry, including graphic record, total and timed vital capacity",35.00
92+
94640,"Pressurized or nonpressurized inhalation treatment for acute airway obstruction",18.00
93+
95810,"Polysomnography; age 6 years or older, sleep staging with 4 or more params",650.00
94+
96360,"Intravenous infusion, hydration; initial, 31 minutes to 1 hour",45.00
95+
96372,"Therapeutic, prophylactic, or diagnostic injection (specify substance or drug)",20.00
96+
97112,"Therapeutic procedure, 1 or more areas, each 15 min; neuromuscular reeducation",28.00
97+
97530,"Therapeutic activities, direct (one-on-one) patient contact",30.00
98+
98941,"Chiropractic manipulative treatment (CMT); spinal, 3-4 regions",35.00
99+
99281,"Emergency department visit, low severity",25.00
100+
99282,"Emergency department visit, low to moderate severity",45.00
101+
A0428,"Ambulance service, basic life support, non-emergency transport",220.00
102+
G0402,"Initial preventive physical examination; face-to-face visit",130.00
103+
G0438,"Annual wellness visit; includes a personalized prevention plan of service (PPS), initial visit",135.00
104+
G0439,"Annual wellness visit, includes a personalized prevention plan of service (PPS), subsequent visit",95.00

0 commit comments

Comments
 (0)