Commit ae38eee7 authored by Kavindu Randika's avatar Kavindu Randika

disease API

parent 7db21ddf
from fastapi import FastAPI
from routes.disease import disease
app = FastAPI()
app.include_router(disease)
from pydantic import BaseModel
class Disease(BaseModel):
name: str
description: str
\ No newline at end of file
from fastapi import APIRouter
from config.db import conn
from os import error
from models.disease import Disease
from schemas.disease import diseaseEntity, diseasesEntity
disease = APIRouter()
@disease.post('/api/disease')
async def create_disease(disease: Disease):
try:
conn.skinDiseaseDB.disease.insert_one(dict(disease))
return {"success": True}
except error:
return {"success": False, "msg": error}
def diseaseEntity(item) -> dict:
return {
"id":str(item["id"]),
"name": item["name"],
"description": item["description"],
}
def diseasesEntity(entity) -> list:
return [diseaseEntity(item) for item in entity]
\ No newline at end of file
from pydantic import BaseModel
from typing import List
from models.isAvailable import IsAvailable
class Doctor(BaseModel):
name: str
phone: str
IsAvailable: List[IsAvailable]
\ No newline at end of file
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