Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion compare_eRegister_vs_hie_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from dateutil.relativedelta import relativedelta
from dateutil.rrule import *
import os

# Open the spreadsheet
def compare_eregister_vs_hie_data(demographics_file, hie_file,facility_name):
Expand All @@ -18,10 +19,14 @@ def compare_eregister_vs_hie_data(demographics_file, hie_file,facility_name):
sheet2 = workbook2.worksheets[0]

# Create a list to store the values

wb2 = Workbook()
# set file path
filepath2="/home/openmrs/openmrs-openshr-utils/data/"+facility_name+"_found_HTS_observations.xlsx"

if os.path.exists(filepath2):
os.remove(filepath2)

# save workbook
wb2.save(filepath2)
wb2 = load_workbook(filepath2)
Expand All @@ -41,6 +46,9 @@ def compare_eregister_vs_hie_data(demographics_file, hie_file,facility_name):
file_date=(start_date + relativedelta(weekday=FR(-1))).strftime('%d_%m_%Y')

filepath3="/home/openmrs/openmrs-openshr-utils/data/"+facility_name+"_missing_HTS_observations_"+file_date+".xlsx"
if os.path.exists(filepath3):
os.remove(filepath3)

# save workbook
wb3.save(filepath3)
wb3 = load_workbook(filepath3)
Expand Down
3 changes: 3 additions & 0 deletions convert_demographics_excel_to_csv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#importing pandas as pd
import pandas as pd
import os

def convert_demographics_excel_to_csv(filename_xlsx,filename_csv):
if os.path.exists(filename_csv):
os.remove(filename_csv)

# Read and store content
# of an excel file
Expand Down
26 changes: 16 additions & 10 deletions demograhics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ def demographics(facility_name,sql_exported_file,heina_id):
#########################################
### create a new empty work book
#########################################

if os.path.exists('/home/openmrs/openmrs-openshr-utils/converted.xlsx'):
os.remove('/home/openmrs/openmrs-openshr-utils/converted.xlsx')
# create Workbook object
read_file = pd.read_csv (sql_exported_file,header=None)
read_file.to_csv (sql_exported_file, header=['Identifier', 'givenname', 'familyname', 'address1', 'address2', 'city', 'dateOfBirth', 'phoneNumber', 'identifier', 'gender', 'mothersMaidenName', 'familyname2', 'motherName', 'maritalstatusCode'], index = False)

read_file = pd.read_csv (sql_exported_file)
read_file.to_excel ('/home/openmrs/openmrs-openshr-utils/converted.xlsx', index = False, header=True)

try:
read_file = pd.read_csv (sql_exported_file,header=None)
read_file.to_csv (sql_exported_file, header=['Identifier', 'givenname', 'familyname', 'address1', 'address2', 'city', 'dateOfBirth', 'phoneNumber', 'identifier', 'gender', 'mothersMaidenName', 'familyname2', 'motherName', 'maritalstatusCode'], index = False)

read_file = pd.read_csv (sql_exported_file)
read_file.to_excel ('/home/openmrs/openmrs-openshr-utils/converted.xlsx', index = False, header=True)
except:
print("No patients seen/consulted for this period")
wb2 = Workbook()
# set file path
filepath2="/home/openmrs/openmrs-openshr-utils/"+facility_name+"_HTSNew.xlsx"
filepath2 = path2="/home/openmrs/openmrs-openshr-utils/"+facility_name+"_HTSNew.xlsx"
# if not os.path.exists("./data/"):
# os.mkdir("data")
if os.path.exists(filepath2):
os.remove(filepath2)

# save workbook
wb2.save(filepath2)

Expand All @@ -47,7 +50,10 @@ def demographics(facility_name,sql_exported_file,heina_id):

# set file path
filepath = "/home/openmrs/openmrs-openshr-utils/converted.xlsx"
# load demo.xlsx
# load demo.xlsx
if not os.path.exists(filepath):
wb3 = Workbook()
wb3.save(filepath)
wb = load_workbook(filename = filepath)

# select demo.xlsx
Expand Down
2 changes: 2 additions & 0 deletions demographics_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def demographics(facility_name,sql_exported_file,heina_id):
read_file = pd.read_csv (sql_exported_file,header=None)
read_file.to_csv (sql_exported_file, header=['Identifier', 'givenname', 'familyname', 'address1', 'address2', 'city', 'dateOfBirth', 'phoneNumber', 'identifier', 'gender', 'mothersMaidenName', 'familyname2', 'motherName', 'maritalstatusCode'], index = False)

if os.path.exists('/home/openmrs/openmrs-openshr-utils/converted_ART.xlsx'):
os.remove('/home/openmrs/openmrs-openshr-utils/converted_ART.xlsx')
read_file = pd.read_csv (sql_exported_file)
read_file.to_excel ('/home/openmrs/openmrs-openshr-utils/converted_ART.xlsx', index = False, header=True)

Expand Down
5 changes: 5 additions & 0 deletions find_missing_ART_clients.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from openempi_session import Openempi_session
from helper import get_patients_from_csv
from helper import write_data_to_csv
import os

def find_missing_clients(csv_filename,facility_name):
filename = csv_filename
Expand All @@ -22,6 +23,10 @@ def find_missing_clients(csv_filename,facility_name):
for patient in missing_patients:
print(patient.givenName+" "+patient.familyName+"\n")

if os.path.exists("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_found_ART_patients.csv"):
os.remove("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_found_ART_patients.csv")
if os.path.exists("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_ART_patients.csv"):
os.remove("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_ART_patients.csv")
write_data_to_csv("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_found_ART_patients.csv", found_patients)
write_data_to_csv("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_ART_patients.csv", missing_patients)
return "/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_ART_patients.csv"
6 changes: 5 additions & 1 deletion find_missing_clients.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from openempi_session import Openempi_session
from helper import get_patients_from_csv
from helper import write_data_to_csv
import os

def find_missing_clients(csv_filename,facility_name):
filename = csv_filename
Expand All @@ -21,7 +22,10 @@ def find_missing_clients(csv_filename,facility_name):
print("=================Missing Patients=================\n")
for patient in missing_patients:
print(patient.givenName+" "+patient.familyName+"\n")

if os.path.exists("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_found_patients.csv"):
os.remove("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_found_patients.csv")
if os.path.exists("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_patients.csv"):
os.remove("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_patients.csv")
write_data_to_csv("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_found_patients.csv", found_patients)
write_data_to_csv("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_patients.csv", missing_patients)
return "/home/openmrs/openmrs-openshr-utils/"+facility_name+"_missing_patients.csv"
5 changes: 5 additions & 0 deletions send_missing_clients.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from openempi_session import Openempi_session
from helper import get_patients_from_csv
from helper import write_data_to_csv
import os

def send_missing_clients(missing_csv_filename,facility_name):
filename = missing_csv_filename
Expand All @@ -26,6 +27,10 @@ def send_missing_clients(missing_csv_filename,facility_name):
for patient in failed_patients:
print(patient.givenName+" "+patient.familyName+"\n")

if os.path.exists("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_sent_patients.csv"):
os.remove("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_sent_patients.csv")
if os.path.exists("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_failed_patients.csv"):
os.remove("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_failed_patients.csv")
write_data_to_csv("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_sent_patients.csv", sent_patients)
write_data_to_csv("/home/openmrs/openmrs-openshr-utils/"+facility_name+"_failed_patients.csv", failed_patients)