Commit 1d44d966 by arjun.b

db model added

parent b9569af7
...@@ -3,21 +3,12 @@ from scripts.core.handlers.assign_patient import assign_patient ...@@ -3,21 +3,12 @@ from scripts.core.handlers.assign_patient import assign_patient
class PublishHandler: class PublishHandler:
@staticmethod @staticmethod
def main_handler(): def main_handler(details):
doctors = ['Dr. Smith', 'Dr. Johnson', 'Dr. Brown', "Dr. Arjun B"] doctors = ['Dr. Smith', 'Dr. Johnson', 'Dr. Brown', "Dr. Arjun B"]
i = 1 patient_details = {
while i: "patient_id": details.id,
print("--------Consult a Doctor------\n") "description": details.description,
choice = int(input("Enter your choice:")) "age": details.age,
if choice == 1: "name": details.name
patient_id = input("Enter patient id: ") }
description = input("Enter the description: ") assign_patient(patient_details, doctors)
age = int(input("Enter the age: "))
name = input("Enter the name: ")
patient_details = {
"patient_id": patient_id,
"description": description,
"age": age,
"name": name
}
assign_patient(patient_details, doctors)
from pydantic import BaseModel
class patients(BaseModel):
id: int
description: str
age: int
name: str
import logging import logging
from fastapi import FastAPI from fastapi import FastAPI
from scripts.core.handlers.publisher_handler import PublishHandler from scripts.core.handlers.publisher_handler import PublishHandler
from scripts.model.patients import patients
app = FastAPI() app = FastAPI()
...@@ -11,9 +12,9 @@ def root(): ...@@ -11,9 +12,9 @@ def root():
@app.post("/publish", tags=["assign doctor and publish"]) @app.post("/publish", tags=["assign doctor and publish"])
def publish_data(): def publish_data(details: patients):
try: try:
PublishHandler.main_handler() PublishHandler.main_handler(details)
except Exception as e: except Exception as e:
logging.error(f'assign a doctor and publishing the details failed: {e}') logging.error(f'assign a doctor and publishing the details failed: {e}')
return {"data": "data published"} return {"data": "data published"}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment