Commit 4f75f520 authored by Hansi rathnayaka's avatar Hansi rathnayaka

API modification

parent 9ecdd57a
from pydantic import BaseModel
class IsAvailable(BaseModel):
class Availability(BaseModel):
day: str
availability: str
\ No newline at end of file
availableTime: str
\ No newline at end of file
from pydantic import BaseModel
from typing import List
from typing import Optional
from models.isAvailable import IsAvailable
from models.availability import Availability
class Doctor(BaseModel):
id: str
title: str
name: str
phone: str
isAvailable: Optional[List[IsAvailable]] = []
\ No newline at end of file
email: str
permitNo: str
address: str
availability: Optional[List[Availability]] = []
\ No newline at end of file
from typing import List
from models.isAvailable import IsAvailable
from models.availability import Availability
from re import A
import re
from os import error
from bson.objectid import ObjectId
from schemas.doctor import doctorEntity, doctorsEntity
from schemas.availability import availableEntity, availablesEntity
from schemas.availability import availabilityEntity, availabilitiesEntity
from fastapi import APIRouter
from models.doctor import Doctor
from config.db import conn
......@@ -53,7 +53,7 @@ async def delete_doctor(id):
@doctor.put('/api/availability/{id}')
async def update_availability(id, availabilities: List[IsAvailable]):
async def update_availability(id, availabilities: List[Availability]):
try:
available_dic = dict()
for available in availabilities:
......
def availableEntity(item) -> dict:
def availabilityEntity(item) -> dict:
return {
"day": item["day"],
"availability": item["availability"]
"availableTime": item["availableTime"]
}
def availablesEntity(entity) -> list:
def availabilitiesEntity(entity) -> list:
print(entity)
return [availableEntity(item) for item in entity]
return [availabilityEntity(item) for item in entity]
\ No newline at end of file
def doctorEntity(item) -> dict:
return {
"id":str(item["id"]),
"id":item["id"],
"title": item["title"],
"name": item["name"],
"phone": item["phone"],
"isAvailable": item["isAvailable"]
"email": item["email"],
"permitNo": item["permitNo"],
"address": item["address"],
"availability": item["availability"]
}
def doctorsEntity(entity) -> list:
return [doctorEntity(item) for item in entity]
\ 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