Spaces:
Sleeping
Sleeping
Update api_server.py
Browse files- api_server.py +6 -6
api_server.py
CHANGED
|
@@ -211,12 +211,12 @@ def create_patient(data: PatientCreate, db: Session = Depends(get_db)):
|
|
| 211 |
|
| 212 |
|
| 213 |
@app.get("/patients")
|
| 214 |
-
def list_patients(db: Session = Depends(get_db
|
| 215 |
return db.query(Patient).all()
|
| 216 |
|
| 217 |
|
| 218 |
@app.get("/patients/{patient_id}")
|
| 219 |
-
def get_patient(patient_id: int, db: Session = Depends(get_db
|
| 220 |
patient = db.query(Patient).filter(Patient.id == patient_id).first()
|
| 221 |
if not patient:
|
| 222 |
raise HTTPException(status_code=404, detail="找不到病患")
|
|
@@ -226,7 +226,7 @@ def get_patient(patient_id: int, db: Session = Depends(get_db())):
|
|
| 226 |
# 7. 護士 API
|
| 227 |
# =================================================================
|
| 228 |
@app.post("/nurses")
|
| 229 |
-
def create_nurse(data: NurseCreate, db: Session = Depends(get_db
|
| 230 |
nurse = Nurse(**data.dict())
|
| 231 |
db.add(nurse)
|
| 232 |
db.commit()
|
|
@@ -235,14 +235,14 @@ def create_nurse(data: NurseCreate, db: Session = Depends(get_db())):
|
|
| 235 |
|
| 236 |
|
| 237 |
@app.get("/nurses")
|
| 238 |
-
def list_nurses(db: Session = Depends(get_db
|
| 239 |
return db.query(Nurse).all()
|
| 240 |
|
| 241 |
# =================================================================
|
| 242 |
# 8. 護理紀錄 API
|
| 243 |
# =================================================================
|
| 244 |
@app.post("/records")
|
| 245 |
-
def create_record(data: RecordCreate, db: Session = Depends(get_db
|
| 246 |
record = Record(**data.dict())
|
| 247 |
db.add(record)
|
| 248 |
db.commit()
|
|
@@ -251,5 +251,5 @@ def create_record(data: RecordCreate, db: Session = Depends(get_db())):
|
|
| 251 |
|
| 252 |
|
| 253 |
@app.get("/records/{patient_id}")
|
| 254 |
-
def list_records(patient_id: int, db: Session = Depends(get_db
|
| 255 |
return db.query(Record).filter(Record.patient_id == patient_id).all()
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
@app.get("/patients")
|
| 214 |
+
def list_patients(db: Session = Depends(get_db)):
|
| 215 |
return db.query(Patient).all()
|
| 216 |
|
| 217 |
|
| 218 |
@app.get("/patients/{patient_id}")
|
| 219 |
+
def get_patient(patient_id: int, db: Session = Depends(get_db)):
|
| 220 |
patient = db.query(Patient).filter(Patient.id == patient_id).first()
|
| 221 |
if not patient:
|
| 222 |
raise HTTPException(status_code=404, detail="找不到病患")
|
|
|
|
| 226 |
# 7. 護士 API
|
| 227 |
# =================================================================
|
| 228 |
@app.post("/nurses")
|
| 229 |
+
def create_nurse(data: NurseCreate, db: Session = Depends(get_db)):
|
| 230 |
nurse = Nurse(**data.dict())
|
| 231 |
db.add(nurse)
|
| 232 |
db.commit()
|
|
|
|
| 235 |
|
| 236 |
|
| 237 |
@app.get("/nurses")
|
| 238 |
+
def list_nurses(db: Session = Depends(get_db)):
|
| 239 |
return db.query(Nurse).all()
|
| 240 |
|
| 241 |
# =================================================================
|
| 242 |
# 8. 護理紀錄 API
|
| 243 |
# =================================================================
|
| 244 |
@app.post("/records")
|
| 245 |
+
def create_record(data: RecordCreate, db: Session = Depends(get_db)):
|
| 246 |
record = Record(**data.dict())
|
| 247 |
db.add(record)
|
| 248 |
db.commit()
|
|
|
|
| 251 |
|
| 252 |
|
| 253 |
@app.get("/records/{patient_id}")
|
| 254 |
+
def list_records(patient_id: int, db: Session = Depends(get_db)):
|
| 255 |
return db.query(Record).filter(Record.patient_id == patient_id).all()
|