def patients_mch(): if api_key.check_key(request.query.api_key,"mch","patients"): api_key.accessed(request.query.api_key) if request.query.type=="csv": data=get_data.patients(database="mch_aggregation") return helper_functions.patients_to_csv(data) else: return get_data.patients(database="mch_aggregation") else: abort(401, "Access denied.")
def patients_hiv(): if api_key.check_key(request.query.api_key,"hiv","patients"): api_key.accessed(request.query.api_key) if request.query.type=="csv": data=get_data.patients(database="openmrs_aggregation") return helper_functions.patients_to_csv(data) else: return {'patients':get_data.patients(database="openmrs_aggregation")} else: abort(401, "Access denied.")
def verification_eligible(): if api_key.check_key(request.query.api_key,"hiv","neel"): api_key.accessed(request.query.api_key) if request.query.type=="csv": data=get_data.neel(database="openmrs_aggregation") return helper_functions.patients_to_csv(data) else: return get_data.neel(database="openmrs_aggregation") else: abort(401, "Access denied.")
if type(entry["next_appointment"])==datetime.datetime: if (today-entry["next_appointment"]).days>14: location=entry["location"] if location in data.keys(): data[location].append(int(entry["pid"])) else: data[location]=[int(entry["pid"])] return data def verification_eligible(database="openmrs_aggregation"): connection=pymongo.MongoClient() db=connection[database] db.authenticate(dbConfig.mongo_username,dbConfig.mongo_password) collection=db.patients data={} today=datetime.datetime.now() for entry in collection.find(): if entry["eligible_for_art"]==1 and entry["on_art"]==0: location=entry["location"] if location in data.keys(): data[location].append(int(entry["pid"])) else: data[location]=[int(entry["pid"])] return data if __name__=="__main__": import datetime print helper_functions.patients_to_csv(neel()) # print report_hiv(datetime.datetime.now()-datetime.timedelta(days=365*100),datetime.datetime.now(),"all") # data=hiv_performance_by_week("1990-10-05")