Skip to content

Commit

Permalink
Release/uat 1.0.4 (#46)
Browse files Browse the repository at this point in the history
* Updated dev 4 9 24 (#36)

* update reply show only changed data and logtime deco func add

* consist of update response change gghnbackgroundtask and rean login once change

* removed some comments and rectified set reminder resp msg

* changed filename to logtime

* changed date format to resolve issue of when date (#37)

* Update Dockerfile

* Update requirements.txt

* added search reply and noted user id in json (#44)

---------

Co-authored-by: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com>
  • Loading branch information
nisha-inflectionzone and rf-opssupport authored Oct 25, 2024
1 parent 8a062c3 commit c1163d3
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 170 deletions.
62 changes: 49 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
FROM python:3.10
# FROM python:3.10
# WORKDIR /app
# RUN python -m venv venv
# RUN . venv/bin/activate
# RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 ghostscript -y
# RUN apt-get install -y awscli dos2unix
# RUN pip install --upgrade pip
# RUN pip install setuptools wheel
# COPY requirements.txt /app/
# RUN pip install --no-cache-dir -r requirements.txt
# COPY . /app
# # RUN aws s3 cp s3://duploservices-dev-configs-new-167414264568/document-processor/GMU_admin.json /app/assets
# EXPOSE 3000
# #CMD ["python", "main.py"]
# COPY entrypoint.sh /app/entrypoint.sh
# RUN dos2unix /app/entrypoint.sh
# RUN chmod +x /app/entrypoint.sh
# ENTRYPOINT ["/bin/bash", "-c", "/app/entrypoint.sh"]

FROM python:3.12-slim-bookworm

# Set the working directory
WORKDIR /app
RUN python -m venv venv
RUN . venv/bin/activate
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 ghostscript -y
RUN apt-get install -y awscli dos2unix
RUN pip install --upgrade pip
RUN pip install setuptools wheel

# Install necessary tools for the build process and dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libstdc++6 \
libx11-6 \
ghostscript \
awscli \
dos2unix \
libexpat1 && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Upgrade pip and install Python packages
RUN pip install --upgrade pip setuptools wheel

# Copy requirements and install them
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --use-deprecated=legacy-resolver -r requirements.txt

# Copy the rest of the application code
COPY . /app
# RUN aws s3 cp s3://duploservices-dev-configs-new-167414264568/document-processor/GMU_admin.json /app/assets

# Convert the entrypoint script to Unix format and make it executable
RUN dos2unix /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh

# Expose port
EXPOSE 3000
#CMD ["python", "main.py"]
COPY entrypoint.sh /app/entrypoint.sh
RUN dos2unix /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

# Set the entrypoint
ENTRYPOINT ["/bin/bash", "-c", "/app/entrypoint.sh"]
8 changes: 8 additions & 0 deletions app/api/appointment/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,11 @@ async def readfile_summary(filename,storage_service):
raise e


async def reply_data(filename,reply,storage_service):
try:
reportfile = ReadReport()
filecontent = await reportfile.readfile_content_by_reply(filename,reply,storage_service)
return(filecontent)
except Exception as e:
raise e

34 changes: 32 additions & 2 deletions app/api/appointment/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from fastapi import APIRouter, HTTPException, status
from fastapi import Request
from fastapi.responses import JSONResponse
from app.api.appointment.handler import handle, handle_aws, read_appointment_file, readfile_content, readfile_content_by_phone, readfile_summary, recent_file, update_reply_by_ph
from app.common.appointment_api.appointment_utils import form_file_name, get_client_name
from app.api.appointment.handler import handle, handle_aws, read_appointment_file, readfile_content, readfile_content_by_phone, readfile_summary, recent_file, reply_data, update_reply_by_ph
from app.common.appointment_api.appointment_utils import form_file_name, get_client_name, map_reply
from app.common.base_response import BaseResponseModel
from app.common.cache import cache
from fastapi import FastAPI, Depends
Expand Down Expand Up @@ -125,3 +125,33 @@ async def read_individual_phone_data(client_bot_name: str, phone_number: str, da
except Exception as e:
print(e)
return JSONResponse(status_code=status.status.HTTP_404_NOT_FOUND, content={"message": "Data not found"})


@router.get("/reply-report/", status_code=status.HTTP_200_OK)
async def reply_report(clientname: str,date: str, reply: str | None = None,storage_service: IStorageService = Depends(get_storage_service)):
date_str = date
if(date_str == 'None' or clientname == 'None'):
print("date returned null")
return(None)
if(reply != None):
reply_str = reply
reply = await map_reply(reply_str)
formatted_date = datetime.strptime(date_str, '%Y-%m-%d').strftime('%Y-%m-%d')
print("formatted_date:",formatted_date)
date_string = formatted_date
client = clientname.lower()
print("client..",client)
filename = await form_file_name(client,date_string)
if(filename == 'None'):
print("filename returned null")
try:
# file_data = await read_appointment_file(filename,storage_service)
reply_summary = await reply_data(filename,reply,storage_service)
data = {
"Summary":reply_summary['reply_count'],
"File_data":reply_summary['reply_details']
}
return(data)
except Exception as e:
print(e)
return JSONResponse(status_code=status.HTTP_404_NOT_FOUND, content={"message": "File not found"})
15 changes: 15 additions & 0 deletions app/common/appointment_api/appointment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,18 @@ async def get_client_name(client):
print(e)
return(None)

async def map_reply(reply):
try:
reply_str = reply.lower()
if(reply_str == 'yes'):
reply = 'Yes'
return(reply)
if(reply_str == 'no'):
reply = 'No'
return(reply)
if(reply_str == 'not replied'):
reply = 'Not replied'
return(reply)
except Exception as e:
print(e)
return(None)
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@ async def update_phone_by_EMRId(self, file_name, date,storage_service):
# print("appointment file data",appointment_data)
for app_data in appointment_data:
EMRId=app_data['participant_code']
phone_nos = await self.search_phone_by_EMRId(file_name, date, EMRId)
if(phone_nos != None):
app_data['phone_number'] = phone_nos
patient_detail = await self.search_phone_by_EMRId(file_name, date, EMRId)
if(patient_detail != None):
app_data['phone_number'] = patient_detail['phone']
app_data['rean_patient_userid'] = patient_detail['userId']
else:
app_data['phone_number'] = ''
app_data['rean_patient_userid'] = ''

retrived_data = await storage_service.update_file(file_name,appointment_data)
data = retrived_data
Expand All @@ -284,8 +286,14 @@ async def search_phone_by_EMRId(self, file_name, date, EMRId):
# print('searched emrid', result)
if response.status_code == 200 and not result['Message'] == 'No records found!':
phone_no_retrived = str(result['Data']['Patients']['Items'][0]['Phone'])
user_id = str(result['Data']['Patients']['Items'][0]['UserId'])
print(f"phone retrived for {EMRId} is {phone_no_retrived}")
return (phone_no_retrived)
print(f"userId retrived for {EMRId} is {user_id}")
patient_data = {
'phone': phone_no_retrived,
'userId': user_id
}
return (patient_data)
else:
# print(result['Message'])
return(None)
65 changes: 58 additions & 7 deletions app/services/common_service/read_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,67 @@ async def readfile_content_by_ph(self, filename, phone_number,storage_service):
for item in data:
if item['phone_number'] == phone_number:
data={
'Name of patient': item['name_of_patient'],
'Facility name': item['facility_name'],
'Appointment time':item['appointment_time'],
'Participant code': item['participant_code'],
'Patient status': item['patient_status'],
'WhatsApp message id':item['whatsapp_message_id'],
'Patient replied':item['patient_replied']
'name_of_patient': item['name_of_patient'],
'facility_name': item['facility_name'],
'rean_patient_userid': item['rean_patient_userid'],
'appointment_time':item['appointment_time'],
'participant_code': item['participant_code'],
'patient_status': item['patient_status'],
'whatsapp_message_id':item['whatsapp_message_id'],
'patient_replied':item['patient_replied']
}
self.patient_data.append(data)
return(self.patient_data)

except FileNotFoundError:
raise HTTPException(status_code=404, detail="Data not found")

async def readfile_content_by_reply(self,filename,reply,storage_service):
try:
patient_reply_count = 0
count = 0
patient_reply_data=[]

file_data = await storage_service.search_file(filename)
if(file_data!= None):
if(reply != None):
for item in file_data:
if item['patient_replied'] == reply:
patient_reply_count =patient_reply_count + 1
data={
'name_of_patient': item['name_of_patient'],
'facility_name': item['facility_name'],
'phone_number': item['phone_number'],
'appointment_time':item['appointment_time'],
'participant_code': item['participant_code'],
'patient_status': item['patient_status'],
'whatsapp_message_id':item['whatsapp_message_id'],
'patient_replied':item['patient_replied']
}
patient_reply_data.append(data)
detail_data = {
'reply_count': patient_reply_count,
'reply_details' : patient_reply_data
}
else:
for item in file_data:
count = count + 1
data={
'name_of_patient': item['name_of_patient'],
'facility_name': item['facility_name'],
'phone_number': item['phone_number'],
'appointment_time':item['appointment_time'],
'participant_code': item['participant_code'],
'patient_status': item['patient_status'],
'whatsapp_message_id':item['whatsapp_message_id'],
'patient_replied':item['patient_replied']
}
patient_reply_data.append(data)
detail_data = {
'reply_count': count,
'reply_details' : patient_reply_data
}
return(detail_data)

except FileNotFoundError:
raise HTTPException(status_code=404, detail="Data not found")
Loading

0 comments on commit c1163d3

Please sign in to comment.