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
rakesh.pv
mqtt_redis
Commits
a5ad958b
Commit
a5ad958b
authored
Feb 06, 2023
by
rakesh.pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed redis
parent
b2e45239
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
23 deletions
+41
-23
scripts/config/mqtt_connection.py
+1
-1
scripts/core/handlers/assign_doctor_to_patient.py
+4
-12
scripts/core/handlers/create_new_patient_data.py
+12
-4
scripts/core/handlers/send_to_mqtt_patient_details.py
+0
-0
scripts/core/handlers/store_patient_details_in_redis.py
+2
-5
scripts/core/services/app.py
+22
-1
scripts/database/model.py
+0
-0
No files found.
scripts/config/mqtt_connection.py
View file @
a5ad958b
MQTT_HOST
=
'192.168.0.220'
MQTT_PORT
=
1883
TOPIC
=
'doctor'
MQTT_
TOPIC
=
'doctor'
scripts/core/handlers/assign_doctor_to_patient.py
View file @
a5ad958b
from
paho
import
mqtt
import
paho.mqtt.client
as
mqtt
from
scripts.config.mqtt_connection
import
MQTT_HOST
,
MQTT_PORT
...
...
@@ -7,12 +6,13 @@ from scripts.config.redis_connection import r
mqtt_client
=
mqtt
.
Client
()
mqtt_client
.
connect
(
MQTT_HOST
,
MQTT_PORT
)
#
no_of_doctor
=
int
(
input
(
" enter the number of docotr [ mqtt topic ]"
))
no_of_doctor
=
int
(
input
(
" enter the number of doctor [ mqtt topic ]"
))
c
=
0
def
assign_doctor
(
patient_id
):
def
assign_doctor
_to_patient
(
patient_id
):
try
:
c
=
0
global
c
c
=
(
c
+
1
)
doctor_topic
=
"doctor"
+
str
(
c
)
...
...
@@ -22,11 +22,3 @@ def assign_doctor(patient_id):
except
Exception
as
e
:
print
(
"Exception occurred due to
\"
"
,
e
,
"
\"
"
)
def
send_patient_details
(
patient_details
):
try
:
# Publish the patient information to the doctor's topic
mqtt_client
.
publish
(
patient_details
)
except
Exception
as
e
:
print
(
"Exception occurred due to
\"
"
,
e
,
"
\"
"
)
scripts/core/handlers/create_new_patient_data.py
View file @
a5ad958b
import
json
from
scripts.core.handlers.assign_doctor_to_patient
import
send_patient_details
from
scripts.core.handlers.store_patient_details_in_redis
import
insert_data_redis
def
insert_new_data
():
# from scripts.core.handlers.assign_doctor_to_patient import send_patient_details
def
insert_new_data
():
patient_name
=
input
(
"enter patient name"
)
patient_id
=
int
(
input
(
"enter patient id"
))
patient_description
=
input
(
"enter patient description"
)
patiend_age
=
int
(
input
(
"enter patient age"
))
entire_data
=
{
"patient_description"
:
patient_description
,
"patient_name"
:
patient_name
,
"patient_id"
:
patient_id
,
"age "
:
patiend_age
,
}
data_to_be_sent
=
{
"patient_description"
:
patient_description
,
...
...
@@ -24,4 +31,5 @@ def insert_new_data():
json
.
dumps
(
data_to_be_sent
))
# -> scripts.core.handlers.store_patient_details_in_redis
insert_data_redis
(
patient_id
,
json
.
dumps
(
data_to_be_sent
))
send_patient_details
(
json
.
dumps
(
data_to_be_sent
))
Mqtt_msg
=
json
.
dumps
(
entire_data
)
return
Mqtt_msg
scripts/core/handlers/send_to_mqtt_patient_details.py
deleted
100644 → 0
View file @
b2e45239
scripts/core/handlers/store_patient_details_in_redis.py
View file @
a5ad958b
from
scripts.config.redis_connection
import
r
from
scripts.core.handlers.assign_doctor_to_patient
import
assign_doctor
,
send_patient_details
from
scripts.core.handlers.assign_doctor_to_patient
import
assign_doctor_to_patient
def
check_patient_id
(
patient_id
):
...
...
@@ -15,7 +14,7 @@ def check_patient_id(patient_id):
else
:
print
()
assign_doctor
(
patient_id
)
assign_doctor
_to_patient
(
patient_id
)
except
Exception
as
e
:
...
...
@@ -26,5 +25,3 @@ def insert_data_redis(patient_id, x):
# -> scripts.core.handlers.check_patient_visited
check_patient_id
(
patient_id
)
scripts/core/services/app.py
View file @
a5ad958b
import
paho.mqtt.client
as
mqtt
from
fastapi
import
FastAPI
from
scripts.config.mqtt_connection
import
MQTT_HOST
,
MQTT_PORT
,
MQTT_TOPIC
from
scripts.core.handlers.create_new_patient_data
import
insert_new_data
app
=
FastAPI
()
...
...
@@ -13,5 +15,24 @@ def index():
# ->scripts.core.handlers.create_new_patient_data
@app.get
(
"/consulation/"
)
def
consult_doctor
():
x
=
insert_new_data
()
insert_new_data
()
def
on_publish
(
client
,
userdata
,
mid
):
print
(
"Message Published..."
)
def
on_connect
(
client
,
userdata
,
flags
,
rc
):
client
.
subscribe
(
MQTT_TOPIC
)
client
.
publish
(
MQTT_TOPIC
,
x
)
def
on_message
(
client
,
userdata
,
msg
):
print
(
msg
.
topic
)
print
(
msg
.
payload
)
client
.
disconnect
()
mqttc
=
mqtt
.
Client
()
mqttc
.
on_publish
=
on_publish
mqttc
.
on_connect
=
on_connect
mqttc
.
on_message
=
on_message
mqttc
.
connect
(
MQTT_HOST
,
MQTT_PORT
)
mqttc
.
loop_forever
()
scripts/database/model.py
deleted
100644 → 0
View file @
b2e45239
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