Commit 4c92ffa2 authored by Kavindu Randika's avatar Kavindu Randika

Merge branch 'dev-it18141252' into 'master'

disease API

See merge request !4
parents 388cbd21 a50b22a1
from fastapi import FastAPI
from routes.disease import disease
from routes.doctor import doctor
app = FastAPI()
app.include_router(disease)
app.include_router(doctor)
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
......@@ -20,4 +20,4 @@ def doctorGetEntity(item) -> dict:
}
def doctorsEntity(entity) -> list:
return [doctorGetEntity(item) for item in entity]
\ No newline at end of file
return [doctorGetEntity(item) for item in entity]
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