Example #1
0
def create_profile_solr(data):
	request_type = "POST"
	url = "%s/createProfile"%get_base_url()
	args = json.loads(data)
	if args['mobile'] and not not_duplicate_contact(args['mobile']):
		return {"message_summary":"Contact Already Registered"}

	barcode = get_barcode()
	args["barcode"]=str(barcode)
	data = json.dumps(args)
	from phr.phr.phr_api import get_response
	response = get_response(url,data,request_type)
	res = json.loads(response.text)
	if res and res.get('returncode')==101:
		data = json.loads(data)
		path = get_image_path(barcode,res['entityid'])
		from phr.templates.pages.login import set_default_dashboard
		set_default_dashboard(res['entityid'])		
		args = {"entityid":res.get('entityid'),"linking_id":data["linking_id"],"relationship":data["relationship"],"received_from":"Desktop"}
		request_type="POST"
		url = "%s/linkprofile"%get_base_url()
		from phr.phr.phr_api import get_response
		response = get_response(url,json.dumps(args),request_type)
		res = json.loads(response.text)
		update_lphr_barcode(path,res.get('entityid'))
		return res
Example #2
0
def create_profile_solr(data):
    request_type = "POST"
    url = "%s/createProfile" % get_base_url()
    args = json.loads(data)
    if args['mobile'] and not not_duplicate_contact(args['mobile']):
        return {"message_summary": "Contact Already Registered"}

    barcode = get_barcode()
    args["barcode"] = str(barcode)
    data = json.dumps(args)
    from phr.phr.phr_api import get_response
    response = get_response(url, data, request_type)
    res = json.loads(response.text)
    if res and res.get('returncode') == 101:
        data = json.loads(data)
        path = get_image_path(barcode, res['entityid'])
        from phr.templates.pages.login import set_default_dashboard
        set_default_dashboard(res['entityid'])
        args = {
            "entityid": res.get('entityid'),
            "linking_id": data["linking_id"],
            "relationship": data["relationship"],
            "received_from": "Desktop"
        }
        request_type = "POST"
        url = "%s/linkprofile" % get_base_url()
        from phr.phr.phr_api import get_response
        response = get_response(url, json.dumps(args), request_type)
        res = json.loads(response.text)
        update_lphr_barcode(path, res.get('entityid'))
        return res
Example #3
0
def get_visit_data(data):
    request_type = "POST"
    url = "%s/searchVisitByFilterparam" % get_base_url()
    from phr.phr.phr_api import get_response

    fields, values, tab = get_data_to_render(data)

    pos = 0

    for filed_dict in fields:
        pos = +1
        if 'rows' in filed_dict.keys():
            rows = filed_dict.get('rows')
            break

    data = json.loads(data)

    response = get_response(
        url,
        json.dumps({
            "profileId": data.get('profile_id'),
            "visit_date_from": data.get('visit_date_from'),
            "visit_date_to": data.get('visit_date_to')
        }), request_type)
    res_data = json.loads(response.text)

    url = "%s/phrdata/getprofilevisitfilecount" % get_base_url()

    response = get_response(url,
                            json.dumps({"profile_id": data.get('profile_id')}),
                            request_type)
    res_data1 = json.loads(response.text)

    event_count_dict = {}
    get_event_wise_count_dict(res_data1.get('FileCountData'), event_count_dict)

    if res_data.get('list'):
        for visit in res_data.get('list'):

            count_list = [0, 0, 0, 0, 0]

            data = [
                '<input  type="radio" name="visit" id = "%s"><div style="display:none">%s</div>'
                % (visit['entityid'], visit['entityid']), visit['visit_title'],
                visit['str_visit_date'], visit['visit_descripton'],
                visit['doctor_name']
            ]

            event_list_updater(visit['entityid'], event_count_dict, count_list,
                               data)

            rows.extend([data])

    return {'rows': rows, 'listview': fields, 'page_size': 5}
Example #4
0
def create_event(data):
	response = ''
	request_type="POST"
	url = "%s/createEvent"%get_base_url()

	event_data={
			"event_title": data.get('event_title'),
			"profile_id": data.get('profile_id'),
			"str_event_date": data.get('event_date'),
			"received_from": "Desktop",
			"event_symptoms" : data.get('complaints'),
			"event_descripton": data.get('event_descripton')
		}

	event_date = datetime.datetime.strptime(event_data.get('str_event_date'), "%d/%m/%Y").strftime('%Y-%m-%d')
	
	if date_diff(event_date, nowdate()) > 0:
		frappe.msgprint("Event Date should be past or current")
		return {"exe":"Event Date should be past or current"}

	else:
		response=get_response(url, json.dumps(event_data), request_type)
		make_log(json.loads(response.text).get('entityid'),"Event","Create","Event Created")

	return json.loads(response.text)
Example #5
0
def get_phr_pdf(profile_id):
    import os, time
    path = os.path.join(os.getcwd(),
                        get_site_path().replace('.', "").replace('/', ""),
                        'public', 'files', profile_id)
    solr_op = 'dms/getPhrPdfwithfilelocation'
    url = get_base_url() + solr_op
    request_type = 'POST'
    path += "/"
    data = {"profileId": profile_id, "file_location": [path]}
    from phr.phr.phr_api import get_response
    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res:
        url = ""
        url = get_url() + "/files/%s/" % (profile_id) + cstr(
            res['file_location'].split('/')[-1]) + '?id=' + str(
                int(round(time.time() * 1000)))
        res["url"] = url
        response.headers[
            'Content-Disposition'] = 'attachment; filename=' + res[
                "file_location"].split("/")[-1]
        return res
    else:
        frappe.msgprint(_("Issue Downloading PDF"))
Example #6
0
def create_event(data):
    response = ''
    request_type = "POST"
    url = "%s/createEvent" % get_base_url()

    event_data = {
        "event_title": data.get('event_title'),
        "profile_id": data.get('profile_id'),
        "str_event_date": data.get('event_date'),
        "received_from": "Desktop",
        "event_symptoms": data.get('complaints'),
        "event_descripton": data.get('event_descripton')
    }

    event_date = datetime.datetime.strptime(event_data.get('str_event_date'),
                                            "%d/%m/%Y").strftime('%Y-%m-%d')

    if date_diff(event_date, nowdate()) > 0:
        frappe.msgprint("Event Date should be past or current")
        return {"exe": "Event Date should be past or current"}

    else:
        response = get_response(url, json.dumps(event_data), request_type)
        make_log(
            json.loads(response.text).get('entityid'), "Event", "Create",
            "Event Created")

    return json.loads(response.text)
Example #7
0
def update_profile_solr(data, dashboard=None):
    request_type = "POST"
    user_details = json.loads(data)
    if not_duplicate_contact(user_details.get('mobile'),
                             user_details.get('email')):
        url = get_base_url() + "/updateProfile"
        from phr.phr.phr_api import get_response
        response = get_response(url, data, request_type)
        res = json.loads(response.text)
        profile = json.loads(data)
        if res['returncode'] == 102:
            sub = "Profile Updated Successfully"
            make_log(profile.get('entityid'), "profile", "update", sub)
            update_user_details(profile)
            mob_code = make_mv_entry(user_details.get('mobile'),
                                     profile.get('entityid'))
            return {
                "rtcode": 100,
                "msg": "Profile Updated Successfully",
                "mob_no": user_details.get('mobile'),
                "user": user_details.get('email'),
                "mobile_code": mob_code
            }
        else:
            return {"rtcode": 101, "msg": "Error While Updating Profile"}
    else:
        return {
            "rtcode":
            201,
            "msg":
            "Maintioned contact number is already registered with another profile."
        }
Example #8
0
	def create_solr_profile(self):
		request_type = "POST"
		url = get_base_url()+'createProvider'
		data = {
					"provider_type": self.provider_type,
					"name": self.provider_name,
					"specialization": self.specialization,
					"mobile": self.mobile_number,
					"email": self.email,
					"comments": '',
					"address1": self.address,
					"country": self.country,
					"city": self.city,
					"visiting_hours": '',
					"address2": self.address_2,
					"state": self.state,
					"pincode": self.pincode,
					'received_from': 'Desktop',
					"provider": True,
					"person_firstname":self.first_name,
					"person_middlename":self.middle_name,
					"person_lastname":self.last_name
				}

		from phr.phr.phr_api import get_response
		response = get_response(url, json.dumps(data),request_type)
		print "response",response
		res = json.loads(response.text)

		if res['returncode']==129:
			self.provider_id = res['entityid']
Example #9
0
def get_individual_visit_count_for_badges(visit_id, profile_id, req_id=None):
    if req_id:
        req_id = frappe.get_doc('Shared Requests', req_id)
        event_dict = json.loads(req_id.event_dict)
        sub_event_count = json.loads(req_id.sub_event_count)

    else:
        request_type = "POST"
        url = get_base_url() + 'admin/getvisitfilecount'
        args = {"profileId": profile_id}
        response = get_response(url, json.dumps(args), request_type)
        res = response.text
        event_list = []
        event_dict = {}
        sub_event_count = {}
        if res:
            jsonobj = json.loads(res)
            if jsonobj["returncode"] == 139:
                for visit in json.loads(jsonobj["list"]):
                    if visit['visit']['entityid'] == visit_id:
                        event_wise_count_dict(visit['visitFileMapCount'],
                                              event_dict, sub_event_count)
                        break

    return get_count_dict(event_dict, sub_event_count)
Example #10
0
def get_profile_list(data):
	request_type="POST"
	url="%s/sharephr/getprofilelistSharedFrom"%get_base_url()
	from phr.phr.phr_api import get_response

	pos = 0

	for filed_dict in fields:
		pos =+ 1
		if 'rows' in filed_dict.keys():
			rows = filed_dict.get('rows')
			break

	data=json.loads(data)

	response=get_response(url, json.dumps({"to_profile_id":data.get('profile_id')}), request_type)

	if response.text:
		res_data = json.loads(response.text)

		to_profile = data.get('profile_id')

		if res_data.get('visitshareProfileList'):
			for profile in res_data.get('visitshareProfileList'):
				data = ['<a nohref id="%s"> %s %s </a>'%(profile.get("entityid"), profile.get("person_firstname"), profile.get("person_lastname"))]
				rows.extend([data])

	rows = get_dm_profiles(rows, to_profile)

	return {
		'rows': rows,
		'listview': fields,
		'page_size': 5
	}
Example #11
0
def create_profile_in_solr(args):
	request_type="POST"
	url = "%s/createProfile"%get_base_url()
	data=json.dumps(args)
	from phr.phr.phr_api import get_response
	response=get_response(url,data,request_type)
	return response.text
Example #12
0
def get_patient_data(data):
	dms_files = []
	filelist = frappe.db.sql("select files_list from `tabShared Requests` where name = '%s'"%data.get('other_param').get('req_id'), as_list=1)[0][0]
	filelist = json.loads(filelist)

	data_dict ={"to_profile_id":data.get('profile_id'),
		"received_from": "desktop", "from_profile_id": data.get('other_param').get('patient_profile_id'),
		"event_tag_id": data.get('other_param').get('event_id')}

	for fl in filelist:
		fl = fl.split('files/')[1].split('/')
		file_dict = {"entityid": fl[4],
			"profile_id": fl[0],
			"event_id": fl[1]}

		file_dict['tag_id'] = fl[4] + '-' +  fl[2].split('-')[1] + fl[3].split('_')[1]
		file_dict["file_id"] = [fl[5].replace('-watermark', '')]

		file_dict['file_location'] = [os.path.join(os.getcwd(), get_site_path().replace('.',"")
									.replace('/', ""), 'public', 'files',
									data_dict.get('to_profile_id'),
									data.get('other_param').get('req_id'), fl[1], fl[2], fl[3], fl[4])]

		frappe.create_folder(file_dict['file_location'][0])

		file_dict['file_location'] = [file_dict['file_location'][0] + '/' + file_dict["file_id"][0]]

		if not  os.path.exists(file_dict['file_location'][0]):
			dms_files.append(file_dict)

		request_type="POST"
		url="%s/dms/getvisitmultiplefile"%get_base_url()
		from phr.phr.phr_api import get_response
		param = {"filelist": dms_files}
		response=get_response(url, json.dumps(param), request_type)
Example #13
0
def create_profile_in_solr(args):
    request_type = "POST"
    url = "%s/createProfile" % get_base_url()
    data = json.dumps(args)
    from phr.phr.phr_api import get_response
    response = get_response(url, data, request_type)
    return response.text
Example #14
0
def get_url(data):
    from phr.templates.pages.utils import get_base_url

    method = get_method(data)
    base_url = get_base_url()
    url = base_url + method

    return url
Example #15
0
def get_url(data):
	from phr.templates.pages.utils import get_base_url

	method=get_method(data)
	base_url=get_base_url()
	url=base_url+method
	
	return url
Example #16
0
def update_profile_solr(data):
	request_type="POST"
	url = "%s/updateProfile"%get_base_url()
	from phr.phr.phr_api import get_response
	response=get_response(url,data,request_type)
	res=json.loads(response.text)
	if res['returncode']=="102":
		return "Profile Updated Successfully"
Example #17
0
def write_file(data):
	request_type = "POST"
	url = "%sdms/getvisitsinglefile"%get_base_url()
	
	response = get_response(url, json.dumps(data), request_type)
	res_data = json.loads(response.text)

	return res_data
Example #18
0
def update_profile_solr(data):
    request_type = "POST"
    url = "%s/updateProfile" % get_base_url()
    from phr.phr.phr_api import get_response
    response = get_response(url, data, request_type)
    res = json.loads(response.text)
    if res['returncode'] == "102":
        return "Profile Updated Successfully"
Example #19
0
def get_image_details(data):
	request_type="POST"
	url = "%smobile/dms/getalleventfiles"%get_base_url()
	
	response = get_response(url, json.dumps({"profile_id":data.get('profile_id'), "event_id": data.get("event_id")}), request_type)
	res_data = json.loads(response.text)

	return res_data.get('filelist')
Example #20
0
def get_visit_data(data):
	request_type="POST"
	url="%s/searchVisitByFilterparam"%get_base_url()
	from phr.phr.phr_api import get_response

	fields, values, tab= get_data_to_render(data)

	pos = 0

	for filed_dict in fields:
		pos =+ 1
		if 'rows' in filed_dict.keys(): 
			rows = filed_dict.get('rows')
			break

	data=json.loads(data)

	response=get_response(url, json.dumps({"profileId":data.get('profile_id'), "visit_date_from": data.get('visit_date_from'), "visit_date_to": data.get('visit_date_to')}), request_type)
	res_data = json.loads(response.text)

	url = "%s/phrdata/getprofilevisitfilecount"%get_base_url()

	response=get_response(url, json.dumps({"profile_id":data.get('profile_id')}), request_type)
	res_data1 = json.loads(response.text)

	event_count_dict = {}
	get_event_wise_count_dict(res_data1.get('FileCountData'), event_count_dict)

	if res_data.get('list'):
		for visit in res_data.get('list'):

			count_list = [0, 0, 0, 0, 0]

			data = ['<input  type="radio" name="visit" id = "%s"><div style="display:none">%s</div>'%(visit['entityid'], visit['entityid']),
					visit['visit_title'], visit['str_visit_date'], 
					visit['visit_descripton'], visit['doctor_name']]

			event_list_updater(visit['entityid'], event_count_dict, count_list, data)
			
			rows.extend([data])
	
	return {
		'rows': rows,
		'listview': fields,
		'page_size': 5
	}
Example #21
0
def get_event_data(data):
	fields, values, tab = get_data_to_render(data)

	request_type="POST"
	url="%s/searchEventByFilterParam"%get_base_url()
	from phr.phr.phr_api import get_response

	pos = 0

	for filed_dict in fields:
		pos =+ 1
		if 'rows' in filed_dict.keys(): 
			rows = filed_dict.get('rows')
			break

	data=json.loads(data)
	profile_id = data.get('profile_id')
	
	response=get_response(url, json.dumps({"profileId":data.get('profile_id'),"event_date_from":data.get('event_date_from'),"event_date_to":data.get('event_date_to')}), request_type)
	res_data = json.loads('{"message":[["1425279780000-964082","HepetitisC","18/02/2018","Cough ,Weakness ,headache",6,2,0,0,0],["1424754329307-454191","headache ak","02/12/2016","",0,0,0,0,0]]}')

	url = "%s/phrdata/getprofilefilecount"%get_base_url()
	response=get_response(url, json.dumps({"profile_id":data.get('profile_id')}), request_type)
	res_data1 = json.loads(response.text)

	event_count_dict = {}
	get_event_wise_count_dict(res_data1.get('FileCountData'), event_count_dict)

	if res_data.get('list'):
		for visit in res_data.get('list'):
			count_list = [0, 0, 0, 0, 0]
			if not visit.get("event_diseasemontoring"):
				data = ['<input type="radio" name="event" id = "%s" "><div style="display:none">%s</div>'%(visit['entityid'], visit['entityid']), 
						"""<a nohref id="%(entityid)s" onclick="Events.prototype.open_form('%(entityid)s', '%(event_title)s', '%(profile_id)s')"> %(event_title)s </a>"""%{"entityid": visit['entityid'],"event_title": visit['event_title'], "profile_id":profile_id}, 
						datetime.datetime.fromtimestamp(cint(visit['event_date'])/1000.0).strftime('%d/%m/%Y'), 
						"<div style='word-wrap: break-word;width:60%%;'>%s</div>"%' ,'.join(visit['event_symptoms'])]
				
				event_list_updater(visit['entityid'], event_count_dict, count_list, data)
				
				rows.extend([data])

	return {
		'rows': rows,
		'listview': fields,
		'page_size': 5
	}
Example #22
0
def write_file(data):
    request_type = "POST"
    url = "%sdms/getvisitsinglefile" % get_base_url()

    response = get_response(url, json.dumps(data), request_type)
    res_data = json.loads(response.text)

    return res_data
Example #23
0
def search_profile_data_from_solr(profile_id):
    solr_op = 'admin/searchlinkprofile'
    url = get_base_url() + solr_op
    request_type = 'POST'
    data = {"from_profile_id": profile_id}
    from phr.phr.phr_api import get_response
    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res['returncode'] == 120:
        return res['list'][0]
Example #24
0
def get_data_from_solr(profile_id):
    solr_op = 'getlatesteventvisitlistbyprofileid'
    url = get_base_url() + solr_op
    request_type = 'POST'
    data = {"profileId": profile_id, "rowCountLimit": 5}
    from phr.phr.phr_api import get_response
    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res['returncode'] == 105:
        return res['actualdata']
Example #25
0
def get_data_from_solr(profile_id):
    solr_op = "getlatesteventvisitlistbyprofileid"
    url = get_base_url() + solr_op
    request_type = "POST"
    data = {"profileId": profile_id, "rowCountLimit": 5}
    from phr.phr.phr_api import get_response

    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res["returncode"] == 105:
        return res["actualdata"]
Example #26
0
def search_profile_data_from_solr(profile_id):
    solr_op = "admin/searchlinkprofile"
    url = get_base_url() + solr_op
    request_type = "POST"
    data = {"from_profile_id": profile_id}
    from phr.phr.phr_api import get_response

    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res["returncode"] == 120:
        return res["list"][0]
Example #27
0
def get_linked_phrs(profile_id):
    solr_op = 'searchchildprofile'
    url = get_base_url() + solr_op
    request_type = 'POST'
    data = {"to_profile_id": profile_id}
    from phr.phr.phr_api import get_response
    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res['returncode'] == 120:
        #linked_phr_list=get_lphrs_with_img(res)
        return res
Example #28
0
def delink_phr_solr(id,parent,res):
	args = json.loads(res)
	solr_op = 'unlinkProfile'
	url = get_base_url()+solr_op
	request_type = 'POST'
	jsonobj = {"entityid":id,"linking_id":parent,"received_from":"Desktop","mobile":args["mobile"],"email":args["email"]}
	from phr.phr.phr_api import get_response
	response = get_response(url,json.dumps(jsonobj),request_type)
	res = json.loads(response.text)
	if res['returncode']==121:
		return res
Example #29
0
def save_data_to_solr(args):
	request_type = "POST"
	url = get_base_url()+'updatedismonitoring'
	response = get_response(url,args,request_type)
	res = response.text
	if res:
		jsonobj=json.loads(res)
		if jsonobj['returncode']==132 or jsonobj['returncode']==133:
			dm=json.loads(args)
			sub="Disease Monitoring created"
			make_log(dm['profile_id'],"Disease Monitoring (CR)","create",sub)
Example #30
0
def get_existing_records_from_solr(profile_id, event_master_id):
    request_type = "POST"
    url = get_base_url() + 'getdiseasemtreventvisit'
    args = {"profile_id": profile_id, "event_master_id": event_master_id}
    response = get_response(url, json.dumps(args), request_type)
    res = response.text
    if res:
        jsonobj = json.loads(res)
        if jsonobj["returncode"] == 105:
            actdata = jsonobj["actualdata"]
            dmlist = json.loads(actdata)
            return dmlist[0]["disease_mtr_visit_List"]
Example #31
0
def save_data_to_solr(args):
    request_type = "POST"
    url = get_base_url() + 'updatedismonitoring'
    response = get_response(url, args, request_type)
    res = response.text
    if res:
        jsonobj = json.loads(res)
        if jsonobj['returncode'] == 132 or jsonobj['returncode'] == 133:
            dm = json.loads(args)
            sub = "Disease Monitoring created"
            make_log(dm['profile_id'], "Disease Monitoring (CR)", "create",
                     sub)
Example #32
0
def get_existing_records_from_solr(profile_id,event_master_id):
	request_type="POST"
	url=get_base_url()+'getdiseasemtreventvisit'
	args={"profile_id":profile_id,"event_master_id":event_master_id}
	response=get_response(url,json.dumps(args),request_type)
	res=response.text
	if res:
		jsonobj=json.loads(res)
		if jsonobj["returncode"]==105:
			actdata=jsonobj["actualdata"]
			dmlist=json.loads(actdata)
			return dmlist[0]["disease_mtr_visit_List"]
Example #33
0
def get_linked_phrs(profile_id):
    solr_op = "searchchildprofile"
    url = get_base_url() + solr_op
    request_type = "POST"
    data = {"to_profile_id": profile_id}
    from phr.phr.phr_api import get_response

    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    if res["returncode"] == 120:
        # linked_phr_list=get_lphrs_with_img(res)
        return res
Example #34
0
def get_image_details(data):
    request_type = "POST"
    url = "%smobile/dms/getalleventfiles" % get_base_url()

    response = get_response(
        url,
        json.dumps({
            "profile_id": data.get('profile_id'),
            "event_id": data.get("event_id")
        }), request_type)
    res_data = json.loads(response.text)

    return res_data.get('filelist')
Example #35
0
def get_dm_data(dm):
	#conditions = get_conditions(filters)
	request_type="POST"
	url=get_base_url()+'admin/getalldiseasemtreventvisit'
	args={"event_master_id":dm.name}
	response=get_response(url,json.dumps(args),request_type)
	res=response.text
	if res:
		jsonobj=json.loads(res)
		if jsonobj["returncode"]==105:
			actdata=jsonobj["list"]
			#dmlist=json.loads(actdata)
			return actdata[0]["disease_mtr_visit_List"]
Example #36
0
def create_provider_in_solr(data,profile_id):
	request_type="POST"
	url=get_base_url()+'createProvider'
	from phr.phr.phr_api import get_response
	response=get_response(url,data,request_type)
	res=json.loads(response.text)
	if res['returncode']==129:
		link_provider(res, data, profile_id)
		create_provider_master_entry(res, data)
		provider=json.loads(data)
		sub="created provider "+provider.get('name')
		make_log(profile_id,"provider","create",sub)
		return res
	return res
Example #37
0
def create_provider_in_solr(data, profile_id):
    request_type = "POST"
    url = get_base_url() + 'createProvider'
    from phr.phr.phr_api import get_response
    response = get_response(url, data, request_type)
    res = json.loads(response.text)
    if res['returncode'] == 129:
        link_provider(res, data, profile_id)
        create_provider_master_entry(res, data)
        provider = json.loads(data)
        sub = "created provider " + provider.get('name')
        make_log(profile_id, "provider", "create", sub)
        return res
    return res
Example #38
0
def get_patients_ids(doctype, txt, searchfield, start, page_len, filters):
	solr_op = 'admin/searchallprofile'
	url=get_base_url()+solr_op
	request_type = 'POST'
	data = {}
	from phr.phr.phr_api import get_response
	response = get_response(url,json.dumps(data),request_type)
	res = json.loads(response.text)
	profile_list = []
	profile_dic = {}
	if res['returncode']==120:
		for data in res['list']:
			profile_list.append([data['entityid'],data['email'],data['person_firstname']])

	return profile_list
Example #39
0
def get_patients_ids(doctype, txt, searchfield, start, page_len, filters):
    solr_op = 'admin/searchallprofile'
    url = get_base_url() + solr_op
    request_type = 'POST'
    data = {}
    from phr.phr.phr_api import get_response
    response = get_response(url, json.dumps(data), request_type)
    res = json.loads(response.text)
    profile_list = []
    profile_dic = {}
    if res['returncode'] == 120:
        for data in res['list']:
            profile_list.append(
                [data['entityid'], data['email'], data['person_firstname']])

    return profile_list
Example #40
0
def delink_phr_solr(id, parent, res):
    args = json.loads(res)
    solr_op = 'unlinkProfile'
    url = get_base_url() + solr_op
    request_type = 'POST'
    jsonobj = {
        "entityid": id,
        "linking_id": parent,
        "received_from": "Desktop",
        "mobile": args["mobile"],
        "email": args["email"]
    }
    from phr.phr.phr_api import get_response
    response = get_response(url, json.dumps(jsonobj), request_type)
    res = json.loads(response.text)
    if res['returncode'] == 121:
        return res
Example #41
0
def update_event(data):
    response = ''
    request_type = "POST"
    url = "%s/createupdateevent" % get_base_url()
    owner = frappe.db.get_value('User', {'profile_id': data.get('profile_id')},
                                'first_name')
    event_data = {
        "entityid": data.get('entityid'),
        "event_complaint_list": [],
        "profile_owner_name": owner if owner else data.get("cname"),
        "status": "active",
        "event_diseasemontoring": False,
        "event_symptoms": data.get('complaints'),
        "event_title": data.get('event_title'),
        "profile_id": data.get('profile_id'),
        "str_event_date": data.get('event_date'),
        "event_descripton": data.get('event_descripton'),
        "visit_files": data.get('dms_file_list'),
        "doctor_id": data.get('doctor_id'),
        "doctor_name": data.get("doctor_name"),
        "visit_descripton": data.get('event_descripton'),
        "received_from": "Desktop",
        "str_visit_date": data.get('visit_date'),
        "diagnosis_desc": data.get('diagnosis_desc')
    }

    import datetime
    event_date = datetime.datetime.strptime(event_data.get('str_event_date'),
                                            "%d/%m/%Y").strftime('%Y-%m-%d')
    visit_date = datetime.datetime.strptime(event_data.get('str_visit_date'),
                                            "%d/%m/%Y").strftime('%Y-%m-%d')

    if date_diff(visit_date, nowdate()) > 0:
        frappe.msgprint("Visit Date could not be greater than current date")
        return {"exe": "Visit Date could not be greater than current date"}

    elif date_diff(visit_date, event_date) < 0:
        frappe.msgprint("Visit Date should not be less than Event Date")
        return {"exe": "Event Date should be past or current"}

    else:
        response = get_response(url, json.dumps(event_data), request_type)
        make_log(data.get('entityid'), "Event", "Update", "Event Updated")

    return json.loads(response.text)
Example #42
0
def get_patient_data(data):
    dms_files = []
    filelist = frappe.db.sql(
        "select files_list from `tabShared Requests` where name = '%s'" %
        data.get('other_param').get('req_id'),
        as_list=1)[0][0]
    filelist = json.loads(filelist)

    data_dict = {
        "to_profile_id": data.get('profile_id'),
        "received_from": "desktop",
        "from_profile_id": data.get('other_param').get('patient_profile_id'),
        "event_tag_id": data.get('other_param').get('event_id')
    }

    for fl in filelist:
        fl = fl.split('files/')[1].split('/')
        file_dict = {"entityid": fl[4], "profile_id": fl[0], "event_id": fl[1]}

        file_dict['tag_id'] = fl[4] + '-' + fl[2].split('-')[1] + fl[3].split(
            '_')[1]
        file_dict["file_id"] = [fl[5].replace('-watermark', '')]

        file_dict['file_location'] = [
            os.path.join(os.getcwd(),
                         get_site_path().replace('.', "").replace('/', ""),
                         'public', 'files', data_dict.get('to_profile_id'),
                         data.get('other_param').get('req_id'), fl[1], fl[2],
                         fl[3], fl[4])
        ]

        frappe.create_folder(file_dict['file_location'][0])

        file_dict['file_location'] = [
            file_dict['file_location'][0] + '/' + file_dict["file_id"][0]
        ]

        if not os.path.exists(file_dict['file_location'][0]):
            dms_files.append(file_dict)

        request_type = "POST"
        url = "%s/dms/getvisitmultiplefile" % get_base_url()
        from phr.phr.phr_api import get_response
        param = {"filelist": dms_files}
        response = get_response(url, json.dumps(param), request_type)
Example #43
0
def get_event_data(filters):
	request_type="POST"
	url=get_base_url()+'admin/geteventfilecount'
	args={"profileId":filters.profile_id}
	response=get_response(url,json.dumps(args),request_type)
	res=response.text
	event_list=[]
	if res:
		jsonobj=json.loads(res)
		if jsonobj["returncode"]==139:
			for event in json.loads(jsonobj["list"]):
				event_count_dict={}
				event_dic={}
				get_event_wise_count_dict(event.get('eventFileMapCount'), event_count_dict)
				count_list=event_list_updater(event['event']['entityid'],event_count_dict)
				event_dic={"event_name":event['event']['event_title'],"date":datetime.datetime.fromtimestamp(event['event']['event_date']/1e3).strftime('%d-%m-%Y'),"complaint":event['event']['event_symptoms'],"complaint_desc":event['event']['event_descripton'],"1":count_list[0],"2":count_list[1],"3":count_list[2],"4":count_list[3],"5":count_list[4]}
				event_list.append(event_dic)
			return event_list		
Example #44
0
def update_profile_solr(data,dashboard=None):
	request_type = "POST"
	user_details = json.loads(data)
	if 	not_duplicate_contact(user_details.get('mobile'),user_details.get('email')):
		url = get_base_url()+"/updateProfile"
		from phr.phr.phr_api import get_response
		response = get_response(url,data,request_type)
		res = json.loads(response.text)
		profile = json.loads(data)
		if res['returncode']==102:
			sub = "Profile Updated Successfully"
			make_log(profile.get('entityid'),"profile","update",sub)
			update_user_details(profile)
			mob_code = make_mv_entry(user_details.get('mobile'),profile.get('entityid'))
			return {"rtcode":100,"msg":"Profile Updated Successfully","mob_no":user_details.get('mobile'),"user":user_details.get('email'),"mobile_code":mob_code}
		else:
			return {"rtcode":101,"msg":"Error While Updating Profile"}
	else:
		return {"rtcode":201,"msg":"Maintioned contact number is already registered with another profile."}
Example #45
0
def get_visit_data(filters):
	request_type="POST"
	url=get_base_url()+'admin/getvisitfilecount'
	args={"profileId":filters.profile_id}
	response=get_response(url,json.dumps(args),request_type)
	res=response.text
	visit_list=[]
	if res:
		jsonobj=json.loads(res)
		if jsonobj["returncode"]==139:
			for event in json.loads(jsonobj["list"]):
				event_count_dict={}
				visit_dic={}
				frappe.errprint(event)
				get_event_wise_count_dict(event.get('visitFileMapCount'), event_count_dict)
				count_list=event_list_updater(event['visit']['entityid'],event_count_dict)
				visit_dic={"event_name":event['visit']['event']['event_title'],"date":datetime.datetime.fromtimestamp(event['visit']['visit_date']/1e3).strftime('%d-%m-%Y'),"desc":event['visit']['visit_descripton'],"doc":event['visit']['doctor_name'],"1":count_list[0],"2":count_list[1],"3":count_list[2],"4":count_list[3],"5":count_list[4]}
				visit_list.append(visit_dic)
			return visit_list
Example #46
0
def get_phr_pdf(profile_id):
	import os, time
	path = os.path.join(os.getcwd(), get_site_path().replace('.',"").replace('/', ""), 'public', 'files', profile_id)
	solr_op = 'dms/getPhrPdfwithfilelocation'
	url = get_base_url()+solr_op
	request_type = 'POST'
	path += "/"
	data = {"profileId":profile_id,"file_location": [path]}
	from phr.phr.phr_api import get_response
	response = get_response(url,json.dumps(data),request_type)
	res = json.loads(response.text)
	if res:
		url = ""
		url = get_url()+"/files/%s/"%(profile_id)+cstr(res['file_location'].split('/')[-1]) + '?id=' + str(int(round(time.time() * 1000)))
		res["url"]=url
		response.headers['Content-Disposition'] = 'attachment; filename='+res["file_location"].split("/")[-1]
		return res
	else:
		frappe.msgprint(_("Issue Downloading PDF"))
Example #47
0
def update_event(data):
	response = ''
	request_type="POST"
	url="%s/createupdateevent"%get_base_url()
	owner = frappe.db.get_value('User', {'profile_id':data.get('profile_id')}, 'first_name')
	event_data =	{
			"entityid":data.get('entityid'),
			"event_complaint_list":[],
			"profile_owner_name": owner if  owner else data.get("cname") ,
			"status": "active",
			"event_diseasemontoring": False,
			"event_symptoms" :data.get('complaints'),
			"event_title": data.get('event_title'),
			"profile_id": data.get('profile_id'),
			"str_event_date": data.get('event_date'),
			"event_descripton": data.get('event_descripton'),
			"visit_files": data.get('dms_file_list'),
			"doctor_id": data.get('doctor_id'),
			"doctor_name": data.get("doctor_name"),
			"visit_descripton": data.get('event_descripton'),
			"received_from": "Desktop",
			"str_visit_date": data.get('visit_date'),
			"diagnosis_desc": data.get('diagnosis_desc')
	}

	import datetime
	event_date = datetime.datetime.strptime(event_data.get('str_event_date'), "%d/%m/%Y").strftime('%Y-%m-%d')
	visit_date = datetime.datetime.strptime(event_data.get('str_visit_date'), "%d/%m/%Y").strftime('%Y-%m-%d')

	if date_diff(visit_date, nowdate()) > 0:
		frappe.msgprint("Visit Date could not be greater than current date")
		return {"exe":"Visit Date could not be greater than current date"}

	elif date_diff(visit_date, event_date) < 0:
		frappe.msgprint("Visit Date should not be less than Event Date")
		return {"exe":"Event Date should be past or current"}

	else:
		response=get_response(url, json.dumps(event_data), request_type)
		make_log(data.get('entityid'),"Event","Update","Event Updated")

	return json.loads(response.text)
Example #48
0
def get_individual_event_count_for_badges(event_id,profile_id, req_id=None):
	if req_id:
		req_id = frappe.get_doc('Shared Requests', req_id)
		event_dict = json.loads(req_id.event_dict)
		sub_event_count = json.loads(req_id.sub_event_count)

	else:
		request_type="POST"
		url=get_base_url()+'admin/geteventfilecount'
		args={"profileId":profile_id,"eventId":event_id}
		response=get_response(url,json.dumps(args),request_type)
		res=response.text
		event_list=[]
		event_dict={}
		sub_event_count={}
		if res:
			jsonobj=json.loads(res)
			if jsonobj["returncode"]==139:
				event=json.loads(jsonobj["list"])
				event_wise_count_dict(event[0]['eventFileMapCount'], event_dict,sub_event_count)

	return get_count_dict(event_dict, sub_event_count)		
Example #49
0
def get_profile_list(data):
    request_type = "POST"
    url = "%s/sharephr/getprofilelistSharedFrom" % get_base_url()
    from phr.phr.phr_api import get_response

    pos = 0

    for filed_dict in fields:
        pos = +1
        if 'rows' in filed_dict.keys():
            rows = filed_dict.get('rows')
            break

    data = json.loads(data)

    response = get_response(
        url, json.dumps({"to_profile_id": data.get('profile_id')}),
        request_type)

    if response.text:
        res_data = json.loads(response.text)

        to_profile = data.get('profile_id')

        if res_data.get('visitshareProfileList'):
            for profile in res_data.get('visitshareProfileList'):
                data = [
                    '<a nohref id="%s"> %s %s </a>' %
                    (profile.get("entityid"), profile.get("person_firstname"),
                     profile.get("person_lastname"))
                ]
                rows.extend([data])

    rows = get_dm_profiles(rows, to_profile)

    return {'rows': rows, 'listview': fields, 'page_size': 5}
Example #50
0
def share_via_providers_account(data):
	event_dict = {}
	sub_event_count = {}
	if not data.get('files'):
		event_data =	{
				"sharelist": [
						{
							"to_profile_id": data.get('doctor_id'),
							"received_from":"desktop",
							"from_profile_id": data.get('profile_id'),
							"event_tag_id": data.get('entityid') if not data.get('event_id') else data.get('event_id'),
							"access_type": "RDW",
							"str_start_date": datetime.datetime.strptime(nowdate(), '%Y-%m-%d').strftime('%d/%m/%Y'),
							"str_end_date": data.get('sharing_duration')
						}
					]
				}

		if data.get('event_id'):
			for shared_meta in event_data.get('sharelist'):
		 		shared_meta["visit_tag_id"] = data.get('entityid')
		 	url="%s/sharephr/sharemultiplevisit"%get_base_url()

		else:
			url="%s/sharephr/sharemultipleevent"%get_base_url()
		request_type="POST"
		
		response=get_response(url, json.dumps(event_data), request_type)
		
		files_list = get_files_doc(event_data, data, None, event_dict, sub_event_count)
		make_sharing_request(event_data, data, files_list, event_dict, sub_event_count)
		make_log(data.get('profile_id'),"Event","Shared Via Provider","Event <b style='color: #89c148;'>%s</b> has shared with Provider <b style='color: #89c148;'>%s</b> \
			for duration <b style='color: #89c148;'>%s</b>"%(data.get('event_title'), data.get('doctor_name'), data.get('sharing_duration')))
		return {"returncode":2,"message_summary":eval(json.loads(response.text).get('sharelist'))[0].get('message_summary')}

	else:
		sharelist = []
		file_path = []
		for fl in data.get('files'):
			file_path.append(fl)
			file_details = fl.split('/')
			sharelist.append({
				"to_profile_id": data.get('doctor_id'),
				"received_from":"desktop",
				"from_profile_id": data.get('profile_id'),
				"visit_tag_id": file_details[4],
				"event_tag_id": data.get('entityid') if not data.get('event_id') else data.get('event_id'),
				"tag_id": file_details[4] + '-' + cstr(file_details[2].split('-')[1]) + cstr(file_details[3].split('_')[1]) ,
				"file_id": [file_details[5].replace('-watermark', '')],
				"file_access": ['RW'],
				"str_start_date": datetime.datetime.strptime(nowdate(), '%Y-%m-%d').strftime('%d/%m/%Y'),
				"str_end_date": data.get('sharing_duration')
			})
			
		request_type="POST"
		url = "%s/sharephr/sharemultiplevisitfiles"%get_base_url()
		event_data = {'sharelist': sharelist}
		
		response=get_response(url, json.dumps(event_data), request_type)
		event_data['file_path'] = file_path

		files_list = get_files_doc(event_data, data, None, event_dict, sub_event_count)
		make_sharing_request(event_data, data, files_list, event_dict, sub_event_count)
		make_log(data.get('profile_id'),"Event","Shared Via Provider","Event <b style='color: #89c148;'>%s</b> has been shared with Provider <b style='color: #89c148;'>%s</b> \
			till <b style='color: #89c148;'>%s</b>"%(data.get('event_title'), data.get('doctor_name'), data.get('sharing_duration')))
		return {"returncode":2,"message_summary":json.loads(json.loads(response.text).get('sharelist'))[0].get('message_summary')}
Example #51
0
def get_event_info(event_id):
	request_type="POST"
	url = "%ssearchEvent"%get_base_url()
	response=get_response(url, json.dumps({"entityid":event_id}), request_type)
	return json.loads(response.text)["list"][0].get('event_title')
Example #52
0
def get_event_info(event_id):
    request_type = "POST"
    url = "%ssearchEvent" % get_base_url()
    response = get_response(url, json.dumps({"entityid": event_id}),
                            request_type)
    return json.loads(response.text)["list"][0].get('event_title')
Example #53
0
def get_event_data(data):
    fields, values, tab = get_data_to_render(data)

    request_type = "POST"
    url = "%s/searchEventByFilterParam" % get_base_url()
    from phr.phr.phr_api import get_response

    pos = 0

    for filed_dict in fields:
        pos = +1
        if 'rows' in filed_dict.keys():
            rows = filed_dict.get('rows')
            break

    data = json.loads(data)
    profile_id = data.get('profile_id')

    response = get_response(
        url,
        json.dumps({
            "profileId": data.get('profile_id'),
            "event_date_from": data.get('event_date_from'),
            "event_date_to": data.get('event_date_to')
        }), request_type)
    res_data = json.loads(response.text)

    url = "%s/phrdata/getprofilefilecount" % get_base_url()
    response = get_response(url,
                            json.dumps({"profile_id": data.get('profile_id')}),
                            request_type)
    res_data1 = json.loads(response.text)

    event_count_dict = {}
    get_event_wise_count_dict(res_data1.get('FileCountData'), event_count_dict)

    if res_data.get('list'):
        for visit in res_data.get('list'):
            count_list = [0, 0, 0, 0, 0]
            if not visit.get("event_diseasemontoring"):
                data = [
                    '<input type="radio" name="event" id = "%s" "><div style="display:none">%s</div>'
                    % (visit['entityid'], visit['entityid']),
                    """<a nohref id="%(entityid)s" onclick="Events.prototype.open_form('%(entityid)s', '%(event_title)s', '%(profile_id)s')"> %(event_title)s </a>"""
                    % {
                        "entityid": visit['entityid'],
                        "event_title": visit['event_title'],
                        "profile_id": profile_id
                    },
                    datetime.datetime.fromtimestamp(
                        cint(visit['event_date']) /
                        1000.0).strftime('%d/%m/%Y'),
                    "<div style='word-wrap: break-word;width:60%%;'>%s</div>" %
                    ' ,'.join(visit['event_symptoms'])
                ]

                event_list_updater(visit['entityid'], event_count_dict,
                                   count_list, data)

                rows.extend([data])

    return {'rows': rows, 'listview': fields, 'page_size': 5}
Example #54
0
def share_via_providers_account(data):
    event_dict = {}
    sub_event_count = {}
    if not data.get('files'):
        event_data = {
            "sharelist": [{
                "to_profile_id":
                data.get('doctor_id'),
                "received_from":
                "desktop",
                "from_profile_id":
                data.get('profile_id'),
                "event_tag_id":
                data.get('entityid')
                if not data.get('event_id') else data.get('event_id'),
                "access_type":
                "RDW",
                "str_start_date":
                datetime.datetime.strptime(nowdate(),
                                           '%Y-%m-%d').strftime('%d/%m/%Y'),
                "str_end_date":
                data.get('sharing_duration')
            }]
        }

        if data.get('event_id'):
            for shared_meta in event_data.get('sharelist'):
                shared_meta["visit_tag_id"] = data.get('entityid')
            url = "%s/sharephr/sharemultiplevisit" % get_base_url()

        else:
            url = "%s/sharephr/sharemultipleevent" % get_base_url()
        request_type = "POST"

        response = get_response(url, json.dumps(event_data), request_type)

        files_list = get_files_doc(event_data, data, None, event_dict,
                                   sub_event_count)
        make_sharing_request(event_data, data, files_list, event_dict,
                             sub_event_count)
        make_log(
            data.get('profile_id'), "Event", "Shared Via Provider",
            "Event <b style='color: #89c148;'>%s</b> has shared with Provider <b style='color: #89c148;'>%s</b> \
			for duration <b style='color: #89c148;'>%s</b>" %
            (data.get('event_title'), data.get('doctor_name'),
             data.get('sharing_duration')))
        return {
            "returncode":
            2,
            "message_summary":
            eval(json.loads(
                response.text).get('sharelist'))[0].get('message_summary')
        }

    else:
        sharelist = []
        file_path = []
        for fl in data.get('files'):
            file_path.append(fl)
            file_details = fl.split('/')
            sharelist.append({
                "to_profile_id":
                data.get('doctor_id'),
                "received_from":
                "desktop",
                "from_profile_id":
                data.get('profile_id'),
                "visit_tag_id":
                file_details[4],
                "event_tag_id":
                data.get('entityid')
                if not data.get('event_id') else data.get('event_id'),
                "tag_id":
                file_details[4] + '-' + cstr(file_details[2].split('-')[1]) +
                cstr(file_details[3].split('_')[1]),
                "file_id": [file_details[5].replace('-watermark', '')],
                "file_access": ['RW'],
                "str_start_date":
                datetime.datetime.strptime(nowdate(),
                                           '%Y-%m-%d').strftime('%d/%m/%Y'),
                "str_end_date":
                data.get('sharing_duration')
            })

        request_type = "POST"
        url = "%s/sharephr/sharemultiplevisitfiles" % get_base_url()
        event_data = {'sharelist': sharelist}

        response = get_response(url, json.dumps(event_data), request_type)
        event_data['file_path'] = file_path

        files_list = get_files_doc(event_data, data, None, event_dict,
                                   sub_event_count)
        make_sharing_request(event_data, data, files_list, event_dict,
                             sub_event_count)
        make_log(
            data.get('profile_id'), "Event", "Shared Via Provider",
            "Event <b style='color: #89c148;'>%s</b> has been shared with Provider <b style='color: #89c148;'>%s</b> \
			till <b style='color: #89c148;'>%s</b>" %
            (data.get('event_title'), data.get('doctor_name'),
             data.get('sharing_duration')))
        return {
            "returncode":
            2,
            "message_summary":
            json.loads(json.loads(
                response.text).get('sharelist'))[0].get('message_summary')
        }