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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
33 deletions
+31
-33
.idea/sonarlint/issuestore/index.pb
+2
-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
+3
-5
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
# assigning the doctors to new patients
import
time
def
assign_new_doctor
(
conn_queue
,
conn_patient
,
client
,
dict_data
,
next_doc
):
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
# updating the patient details with doctor id
dict_data
.
update
({
"doctor"
:
f
'doctor{next_doc}'
})
dict_data
.
update
({
"doctor"
:
f
'doctor{next_doc}'
})
# update the db with new data
# update the db with new data
conn_patient
.
hmset
(
dict_data
[
'patient_id'
],
dict_data
)
conn_patient
.
hmset
(
dict_data
[
'patient_id'
],
dict_data
)
# set the patient to the doctors queue
patient_id
=
dict_data
[
'patient_id'
]
conn_queue
.
set
(
f
'doctor{next_doc}'
,
dict_data
[
'patient_id'
])
# publish the doctor
# 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
# assigning existing patients to the doctors
import
time
def
assign_doc_exist
(
conn_queue
,
conn_patient
,
client
,
dict_data
):
def
assign_doc_exist
(
conn_queue
,
conn_patient
,
client
,
dict_data
):
# getting the doctor id from the patient db
# getting the doctor id from the patient db
doctor
=
conn_patient
.
hmget
(
dict_data
[
'patient_id'
],
'doctor'
)
doctor
=
conn_patient
.
hmget
(
dict_data
[
'patient_id'
],
'doctor'
)
# updating the doctors queue
avi_doc
=
conn_queue
.
get
(
doctor
[
0
]
.
decode
())
conn_queue
.
set
(
doctor
[
0
]
.
decode
(),
dict_data
[
'patient_id'
])
# 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
# 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
...
@@ -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
# check if the next doctor is not the last index
if
int
(
next_doc
)
!=
doctors_counter
:
if
int
(
next_doc
)
!=
doctors_counter
:
avi_doc
=
conn_queue
.
get
(
f
'doctor{next_doc}'
)
# assign the doctor
assign_new_doctor
(
conn_queue
,
conn_patient
,
client
,
dict_data
,
next_doc
)
conn_queue
.
set
(
'next_doc'
,
next_doc
+
1
)
# check if the doctor queue is empty
if
avi_doc
==
b
''
:
assign_new_doctor
(
conn_queue
,
conn_patient
,
client
,
dict_data
,
next_doc
)
conn_queue
.
set
(
'next_doc'
,
next_doc
+
1
)
else
:
else
:
conn_queue
.
set
(
'next_doc'
,
0
)
conn_queue
.
set
(
'next_doc'
,
0
)
...
...
scripts/services/app_services_run.py
View file @
bb069f5f
...
@@ -74,11 +74,6 @@ def patient_data(body: Patient):
...
@@ -74,11 +74,6 @@ def patient_data(body: Patient):
# creating the paho client to listen to the port
# creating the paho client to listen to the port
client
.
connect
(
mqtt_host
,
int
(
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
# generating the patients
dict_data
=
generate_patients
(
patient_data_val
)
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