Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Skin disease Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Skin disease
Skin disease Server
Commits
52a0c926
Commit
52a0c926
authored
Sep 17, 2021
by
Hansi rathnayaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API modifications
parent
4f75f520
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
routes/doctor.py
routes/doctor.py
+3
-4
schemas/doctor.py
schemas/doctor.py
+12
-2
No files found.
routes/doctor.py
View file @
52a0c926
...
...
@@ -5,7 +5,7 @@ import re
from
os
import
error
from
bson.objectid
import
ObjectId
from
schemas.doctor
import
doctorEntity
,
doctorsEntity
from
schemas.doctor
import
doctorEntity
,
doctorsEntity
,
doctorGetEntity
from
schemas.availability
import
availabilityEntity
,
availabilitiesEntity
from
fastapi
import
APIRouter
from
models.doctor
import
Doctor
...
...
@@ -30,8 +30,7 @@ async def find_one_doctor(id):
async
def
create_doctor
(
doctor
:
Doctor
):
try
:
conn
.
skinDiseaseDB
.
doctor
.
insert_one
(
dict
(
doctor
))
return
doctorEntity
(
conn
.
skinDiseaseDB
.
doctor
.
find_one
({
"id"
:
doctor
.
id
}))
#return {"success": True}
return
{
"success"
:
True
}
except
error
:
return
{
"success"
:
False
,
"msg"
:
error
}
...
...
@@ -39,7 +38,7 @@ async def create_doctor(doctor: Doctor):
async
def
update_doctor
(
id
,
doctor
:
Doctor
):
try
:
conn
.
skinDiseaseDB
.
doctor
.
find_one_and_update
({
"id"
:
id
},{
"$set"
:
dict
(
doctor
)})
return
doctorEntity
(
conn
.
skinDiseaseDB
.
doctor
.
find_one
({
"id"
:
id
}))
return
{
"success"
:
True
}
except
error
:
return
{
"success"
:
False
,
"msg"
:
error
}
...
...
schemas/doctor.py
View file @
52a0c926
def
doctorEntity
(
item
)
->
dict
:
return
{
"id"
:
item
[
"id"
]
,
"id"
:
str
(
item
[
"id"
])
,
"title"
:
item
[
"title"
],
"name"
:
item
[
"name"
],
"phone"
:
item
[
"phone"
],
...
...
@@ -9,5 +9,15 @@ def doctorEntity(item) -> dict:
"address"
:
item
[
"address"
],
"availability"
:
item
[
"availability"
]
}
def
doctorGetEntity
(
item
)
->
dict
:
return
{
"id"
:
str
(
item
[
"id"
]),
"title"
:
item
[
"title"
],
"name"
:
item
[
"name"
],
"phone"
:
item
[
"phone"
],
"email"
:
item
[
"email"
]
}
def
doctorsEntity
(
entity
)
->
list
:
return
[
doctorEntity
(
item
)
for
item
in
entity
]
\ No newline at end of file
return
[
doctorGetEntity
(
item
)
for
item
in
entity
]
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment