Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
task9_redis_sender
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
arun.uday
task9_redis_sender
Commits
bb069f5f
Commit
bb069f5f
authored
Feb 06, 2023
by
arun.uday
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v3
parent
0fde07ab
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
32 deletions
+28
-32
.idea/sonarlint/issuestore/index.pb
+0
-16
scripts/core/handlers/next_doc_assign.py
+13
-4
scripts/core/handlers/next_doc_existing.py
+13
-3
scripts/core/handlers/queue_check.py
+2
-4
scripts/services/app_services_run.py
+0
-5
No files found.
.idea/sonarlint/issuestore/index.pb
View file @
bb069f5f
No preview for this file type
scripts/core/handlers/next_doc_assign.py
View file @
bb069f5f
# assigning the doctors to new patients
import
time
def
assign_new_doctor
(
conn_queue
,
conn_patient
,
client
,
dict_data
,
next_doc
):
avi_doc
=
conn_queue
.
get
(
f
'doctor{next_doc}'
)
# check if the doctor queue is empty
if
avi_doc
!=
b
''
:
print
(
"Wait for the doctor to be free..."
)
time
.
sleep
(
3
)
conn_queue
.
set
(
f
'doctor{next_doc}'
,
''
)
# updating the patient details with doctor id
dict_data
.
update
({
"doctor"
:
f
'doctor{next_doc}'
})
# update the db with new data
conn_patient
.
hmset
(
dict_data
[
'patient_id'
],
dict_data
)
# set the patient to the doctors queue
conn_queue
.
set
(
f
'doctor{next_doc}'
,
dict_data
[
'patient_id'
])
patient_id
=
dict_data
[
'patient_id'
]
# publish the doctor
client
.
publish
(
f
'doctor{next_doc}'
,
dict_data
[
'patient_id'
]
)
client
.
publish
(
f
'doctor{next_doc}'
,
patient_id
)
scripts/core/handlers/next_doc_existing.py
View file @
bb069f5f
# assigning existing patients to the doctors
import
time
def
assign_doc_exist
(
conn_queue
,
conn_patient
,
client
,
dict_data
):
# getting the doctor id from the patient db
doctor
=
conn_patient
.
hmget
(
dict_data
[
'patient_id'
],
'doctor'
)
# updating the doctors queue
conn_queue
.
set
(
doctor
[
0
]
.
decode
(),
dict_data
[
'patient_id'
])
avi_doc
=
conn_queue
.
get
(
doctor
[
0
]
.
decode
())
# check if the doctor queue is empty
if
avi_doc
!=
b
''
:
print
(
"Wait for the doctor to be free..."
)
time
.
sleep
(
3
)
conn_queue
.
set
(
doctor
[
0
]
.
decode
(),
''
)
patient_id
=
dict_data
[
'patient_id'
]
# publishing the doctor
client
.
publish
(
doctor
[
0
]
.
decode
(),
dict_data
[
'patient_id'
]
)
client
.
publish
(
doctor
[
0
]
.
decode
(),
patient_id
)
scripts/core/handlers/queue_check.py
View file @
bb069f5f
...
...
@@ -6,12 +6,10 @@ def set_patient_queue(conn_queue, conn_patient, client, dict_data, next_doc, doc
# check if the next doctor is not the last index
if
int
(
next_doc
)
!=
doctors_counter
:
avi_doc
=
conn_queue
.
get
(
f
'doctor{next_doc}'
)
# check if the doctor queue is empty
if
avi_doc
==
b
''
:
# assign the doctor
assign_new_doctor
(
conn_queue
,
conn_patient
,
client
,
dict_data
,
next_doc
)
conn_queue
.
set
(
'next_doc'
,
next_doc
+
1
)
else
:
conn_queue
.
set
(
'next_doc'
,
0
)
...
...
scripts/services/app_services_run.py
View file @
bb069f5f
...
...
@@ -74,11 +74,6 @@ def patient_data(body: Patient):
# creating the paho client to listen to the port
client
.
connect
(
mqtt_host
,
int
(
port
))
def
on_connect
(
client_id
,
userdata
,
flags
,
rc
):
print
(
"Connected with result code "
+
str
(
rc
),
client_id
,
userdata
,
flags
)
client
.
on_connect
=
on_connect
# generating the patients
dict_data
=
generate_patients
(
patient_data_val
)
...
...
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