File size: 1,320 Bytes
ed0b977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask
from utils.db.db import init_db, mongo
import os
from dotenv import load_dotenv

load_dotenv()

app = Flask(__name__)
app.config["MONGO_URI"] = os.environ.get("MONGO_URI")
if app.config["MONGO_URI"] and "mongodb.net/?" in app.config["MONGO_URI"]:
    app.config["MONGO_URI"] = app.config["MONGO_URI"].replace("mongodb.net/?", "mongodb.net/swiftquery?")

init_db(app)

with app.app_context():
    print("--- Checking Patients ---")
    patients = list(mongo.db.patient.find())
    for p in patients:
        pid = p.get('id')
        sql_id = p.get('sql_id')
        print(f"Patient: Name={p.get('name')}, ID={pid} (Type: {type(pid)}), SQL_ID={sql_id} (Type: {type(sql_id)})")

    print("\n--- Checking Medical History (Sample) ---")
    history = mongo.db.medicalhistory.find_one()
    if history:
        hid = history.get('patient_id')
        print(f"History Record: ID={history.get('id')}, Patient_ID={hid} (Type: {type(hid)})")
    else:
        print("No medical history found.")

    print("\n--- Checking Consultation (Sample) ---")
    consult = mongo.db.consultation.find_one()
    if consult:
        cid = consult.get('patient_id')
        print(f"Consultation Record: ID={consult.get('id')}, Patient_ID={cid} (Type: {type(cid)})")
    else:
        print("No consultations found.")