Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MQTT-Redis
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
arjun.b
MQTT-Redis
Commits
3650e464
Commit
3650e464
authored
Feb 06, 2023
by
arjun.b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logging file added
parent
9607ff16
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletions
+11
-1
scripts/config/application_config.py
+3
-1
scripts/core/handlers/assign_patient.py
+4
-0
scripts/core/handlers/publisher_handler.py
+4
-0
No files found.
scripts/config/application_config.py
View file @
3650e464
import
configparser
import
configparser
from
scripts.logging.logging
import
logger
try
:
try
:
config
=
configparser
.
ConfigParser
()
config
=
configparser
.
ConfigParser
()
config
.
read
(
r'E:\MQTT-redis\conf\application.conf'
)
config
.
read
(
r'E:\MQTT-redis\conf\application.conf'
)
...
@@ -12,4 +14,4 @@ try:
...
@@ -12,4 +14,4 @@ try:
redis_port
=
config
.
get
(
"redis_connect"
,
"port"
)
redis_port
=
config
.
get
(
"redis_connect"
,
"port"
)
file_name
=
config
.
get
(
"logging"
,
"file_name"
)
file_name
=
config
.
get
(
"logging"
,
"file_name"
)
except
configparser
.
NoOptionError
:
except
configparser
.
NoOptionError
:
print
(
"could not find conf file"
)
logger
.
error
(
"could not find conf file"
)
scripts/core/handlers/assign_patient.py
View file @
3650e464
...
@@ -3,6 +3,7 @@ from paho.mqtt import client as mqtt_client
...
@@ -3,6 +3,7 @@ from paho.mqtt import client as mqtt_client
from
scripts.config.application_config
import
hostname
,
port_num
,
topic_name
from
scripts.config.application_config
import
hostname
,
port_num
,
topic_name
from
scripts.config.redis_connection
import
r
from
scripts.config.redis_connection
import
r
from
scripts.core.handlers.get_next_doctor
import
get_next_doctor
from
scripts.core.handlers.get_next_doctor
import
get_next_doctor
from
scripts.logging.logging
import
logger
broker
=
hostname
broker
=
hostname
port
=
int
(
port_num
)
port
=
int
(
port_num
)
...
@@ -12,6 +13,7 @@ client.connect(broker, port, 60)
...
@@ -12,6 +13,7 @@ client.connect(broker, port, 60)
def
assign_patient
(
patient
,
doctors
):
def
assign_patient
(
patient
,
doctors
):
try
:
# Get the next doctor for the patient
# Get the next doctor for the patient
next_doctor
=
get_next_doctor
(
doctors
)
next_doctor
=
get_next_doctor
(
doctors
)
...
@@ -29,3 +31,5 @@ def assign_patient(patient, doctors):
...
@@ -29,3 +31,5 @@ def assign_patient(patient, doctors):
patient
.
update
({
"doctor"
:
next_doctor
})
patient
.
update
({
"doctor"
:
next_doctor
})
r
.
hset
(
patient
[
'patient_id'
],
'doctor'
,
next_doctor
)
r
.
hset
(
patient
[
'patient_id'
],
'doctor'
,
next_doctor
)
client
.
publish
(
topic
,
json
.
dumps
(
patient
))
client
.
publish
(
topic
,
json
.
dumps
(
patient
))
except
Exception
as
e
:
logger
.
error
(
f
"could not assign patient: {e}"
)
scripts/core/handlers/publisher_handler.py
View file @
3650e464
from
scripts.core.handlers.assign_patient
import
assign_patient
from
scripts.core.handlers.assign_patient
import
assign_patient
from
scripts.logging.logging
import
logger
class
PublishHandler
:
class
PublishHandler
:
@staticmethod
@staticmethod
def
main_handler
(
details
):
def
main_handler
(
details
):
try
:
doctors
=
[
'Dr. Smith'
,
'Dr. Johnson'
,
'Dr. Brown'
,
"Dr. Arjun B"
]
doctors
=
[
'Dr. Smith'
,
'Dr. Johnson'
,
'Dr. Brown'
,
"Dr. Arjun B"
]
patient_details
=
{
patient_details
=
{
"patient_id"
:
details
.
id
,
"patient_id"
:
details
.
id
,
...
@@ -12,3 +14,5 @@ class PublishHandler:
...
@@ -12,3 +14,5 @@ class PublishHandler:
"name"
:
details
.
name
"name"
:
details
.
name
}
}
assign_patient
(
patient_details
,
doctors
)
assign_patient
(
patient_details
,
doctors
)
except
Exception
as
e
:
logger
.
error
(
f
"cant get patients details :{e}"
)
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