Commit e0e841e8 by rakesh.pv

intial build : more work to do

parents
# Default ignored files
/shelf/
/workspace.xml
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N806" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (python_redis)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/python_redis.iml" filepath="$PROJECT_DIR$/.idea/python_redis.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
import uvicorn
uvicorn.run("scripts.core.services.app:app")
MQTT_HOST = '192.168.0.220'
MQTT_PORT = 1883
TOPIC = 'doctor/#'
import redis
REDIS_PORT = 6379
REDIS_HOST = '127.0.0.1'
r = redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
from scripts.config.redis_connection import r
def check_patient_id(patient_id):
try:
# Check if the patient has visited before
all_patient_id = r.keys()
if r.exists(patient_id):
doctor_topic = r.get(patient_id)
print("patient id already presnt in redis databse")
else:
# If the patient is new, assign a doctor using round-robin
print("done succesfull")
except Exception as e:
print("Exception occurred due to \"", e, "\"")
import json
from scripts.core.handlers.store_patient_details_in_redis import insert_data_redis
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"))
data_to_be_sent = {
"patient_description": patient_description,
"patient_name": patient_name,
"age ": patiend_age,
}
print(" data that will be published to broker is :\n\n", "patiend id :\n", patient_id, "\npatient description \n\n",
json.dumps(data_to_be_sent))
insert_data_redis(patient_id, json.dumps(data_to_be_sent))
from scripts.config.redis_connection import r
from scripts.core.handlers.check_patient_visited import check_patient_id
def insert_data_redis(patient_id,x):
r.set(patient_id,x)
check_patient_id(patient_id)
from fastapi import FastAPI
from scripts.core.handlers.create_new_patient_data import insert_new_data
app = FastAPI()
@app.get("/")
def index():
return {"message :", " FAST API IS CONNECTED"}
insert_new_data()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment