Example #1
0
def site_providers(request, return_python=False):
	"""
	Gets a list of the providers at the user's current site.

	If return_python is true, this will just return the object that would have
	been converted to JSON format.
	"""
	p = request.role_user
	location = p.current_site

	response = {
		'data': {'users': []},
		'warnings': {},
	}

	if (not location):
		return HttpResponse(content=json.dumps(response), mimetype='application/json')

	providers = get_all_site_providers(location)

	response['data']['users'] = _set_providers_list(providers, p)

	if (return_python):
		return response

	return HttpResponse(content=json.dumps(response), mimetype='application/json')
Example #2
0
def main_nurse(request, nurse):
	"""Displays the nurse's home page."""
	context = get_context(request)
	context['user_type'] = "nurse"

	context['site_providers'] = get_all_site_providers(nurse.user.current_site)
	context['site_clinical_clerks'] = get_all_site_clinical_clerks(nurse.user.current_site)
	context['community_physicians'] = get_community_professionals(nurse.user.current_practice)

	return render_to_response('home_nurse.html', context)
Example #3
0
	def testGetSiteStaff(self):
		site = create_site()
		rs = get_all_site_providers(site)
		data = {}
		data['users'] = setSubProviderResultList(rs)
		self.assertEqual(data, getSiteStaff(site.id))
		with self.assertRaises(Http404): getSiteStaff('')
		site_ids = Site.objects.filter().values_list('id', flat=True)
		not_exist_id = 1
		while not_exist_id in site_ids:
			not_exist_id += 1
		with self.assertRaises(Http404): getSiteStaff(not_exist_id)
Example #4
0
def getSiteProviders(site_id):
    if not site_id:
        raise Http404

    try:
        site = Site.objects.get(pk=site_id)
        rs = get_all_site_providers(site)
        data = {}
        data['users'] = setSubProviderResultList(rs)
        return data
    except Site.DoesNotExist:
        raise Http404
Example #5
0
def getSiteProviders(site_id):
	if not site_id:
		raise Http404 

	try:
		site = Site.objects.get(pk=site_id)
		rs = get_all_site_providers(site)
		data = {}
		data['users'] = setSubProviderResultList(rs)
		return data
	except Site.DoesNotExist:
		raise Http404
Example #6
0
def main_nurse(request, nurse):
    """Displays the nurse's home page."""
    context = get_context(request)
    context['user_type'] = "nurse"

    context['site_providers'] = get_all_site_providers(nurse.user.current_site)
    context['site_clinical_clerks'] = get_all_site_clinical_clerks(
        nurse.user.current_site)
    context['community_physicians'] = get_community_professionals(
        nurse.user.current_practice)

    return render_to_response('home_nurse.html', context)
Example #7
0
def practice_main_view(request):
	"""Displays office manager/staff home page."""

	if (not 'OfficeStaff' in request.session['MHL_UserIDs']):
		return err403(request)
		#print "%s %s is an Office_Manager"%(request.user.first_name, request.user.last_name)

	context = get_context(request)
	providerDict = dict()
	siteStaffDict = dict()
	local_practicesDict = dict()
	comm_professionalsDict = dict()
	practice_membersDict = dict()

	context['recent_sent_box'] = box_recent_sent(request)

	office_staff = request.session['MHL_Users']['OfficeStaff']
	current_practice = office_staff.current_practice
	context['zip'] = office_staff.user.zip

	if current_practice:
		context['mdcom_phone'] = phone_formater(current_practice.mdcom_phone)
		#list of practice for this location:
		practice_list = get_practices_by_position(current_practice.practice_lat, 
			current_practice.practice_longit).only('practice_name', 'id')
		local_practicesDict['providers'] = set_practices_result(practice_list, request)

		#list of providers for this practice:
		practice_members = all_practice_members(current_practice.id, 
			strip_staff_mobile=False, strip_staff_pager=False)
		practice_membersDict['providers'] = set_practice_members_result(practice_members, request)

	else:
		context['mdcom_phone'] = '(none)'
		#list of practice for this location:
		local_practicesDict['providers'] = []
		#list of providers for this practice:
		practice_membersDict['providers'] = []

	current_site = office_staff.current_site
	if (current_site != None):
		#context['site_providers'] = get_all_site_providers(office_staff.current_site.id)
#		providerDict['providers'] = get_all_site_providers(office_staff.current_site.id)

		providers = get_all_site_providers(office_staff.current_site.id)
		set_providers_result(providers, request) 
		providerDict['providers'] = providers
		site_staffs = get_all_site_staff(office_staff.current_site.id)
		siteStaffDict['users'] = set_site_staff_result(site_staffs, office_staff)

		#context['current_site_short_name'] = office_staff.current_site.short_name
		if current_site.short_name:
			providerDict['current_site'] = current_site.short_name
		else:
			providerDict['current_site'] = current_site.name
	else:
		providerDict['current_site'] = _("Hospital Site")

	comm_professionals = get_community_professionals(current_practice)	
	set_providers_result(comm_professionals, request) 
	#raise Exception ('practice_providers', context)
	comm_professionalsDict['providers'] = comm_professionals
	#does this manager have business cell phone?
	#context['business_cell'] = office_staff.user.mobile_phone
#	local_practicesDict['business_cell'] = office_staff.user.mobile_phone
	#does this practice have pending incoming requests for joining practice, 
	#get all managers for this practice

	# refer to ticket #1292, make the search condition same with staff page.
#	practice_staff = OfficeStaff.objects.filter(current_practice=current_practice).values('user')
	practice_staff = OfficeStaff.objects.filter().values('user')
#	#get all pending to ANY manager from this practice
#	#raise Exception(current_practice,OfficeManagers) 
	pend_assoc = Pending_Association.objects.filter(practice_location=current_practice, 
		to_user__in=practice_staff).filter(~Q(from_user__in=practice_staff)).count()

	context['receive_request_count'] = pend_assoc

	context['auto_refresh_time'] = settings.MSGLIST_AUTOREFRESH_TIME

	context['practice_members'] = render_to_string('userInfo3.html', practice_membersDict)
	context['site_provider'] = render_to_string('userInfo.html', providerDict)
	context['site_staff'] = render_to_string('userInfo4.html', siteStaffDict)
	context['comm_professionals'] = render_to_string('userInfo.html', comm_professionalsDict)
	context['local_practices'] = render_to_string('userInfo2.html', local_practicesDict)

	mhluser = request.session['MHL_Users']['MHLUser']
	orgs = getOrganizationsOfUser(mhluser, current_practice=current_practice)
	providerDict['org'] = orgs

	context['orgOroviders'] = renderOrganizationForDashbord(orgs, request)
	context['my_favorite'] = get_my_favorite(mhluser, html=True)

	providerDict["current_organization_type"] = get_org_type_name(current_practice, none_text="")
	if Office_Manager.objects.filter(user=office_staff, practice=current_practice).exists():
		context['caller_anssvc'] = office_staff.get_caller_anssvc_display()
		context['mobile_phone'] = phone_formater(office_staff.user.mobile_phone)
		context['office_phone'] = phone_formater(office_staff.office_phone)
		context['other_phone'] = phone_formater(office_staff.user.phone)

		#add by xlin 20100208 for html code refacting
		providerDict['userType'] = 1

		context['tabUI'] = render_to_string('tabUI.html', providerDict)
		return render_to_response('dashboard_office_manager.html', context)

	providerDict['userType'] = 2
	context['tabUI'] = render_to_string('tabUI.html', providerDict)
	return render_to_response('dashboard_office_staff.html', context)
Example #8
0
def main_provider(request, user, user_type):
	"""Displays the physician/np_pa's home page."""
	context = get_context(request)
	context['auto_refresh_time'] = settings.MSGLIST_AUTOREFRESH_TIME

	context['user_type'] = user_type
	current_provider = user.user

	providers = get_all_site_providers(current_provider.current_site)
	set_providers_result(providers, request)
	site_staffs = get_all_site_staff(current_provider.current_site)
	site_staffs = set_site_staff_result(site_staffs, current_provider)

	context['unread_msg_count'] = get_message_count(user.user, ('ANS', 'VM'), read_flag=False)

	community_physicians = get_community_providers(user)
	set_providers_result(community_physicians, request)
	context['community_physicians'] = community_physicians
	members = dict()
	local_practicesDict = dict()
	current_practice = current_provider.current_practice
	if (current_practice):
		practice_members = all_practice_members(current_practice, 
			strip_staff_mobile=False, strip_staff_pager=True)
		members['providers'] = set_practice_members_result(practice_members, request)
		practice_list = get_practices_by_position(current_practice.practice_lat, 
			current_practice.practice_longit).only('practice_name', 'id')
		local_practicesDict['providers'] = set_practices_result(practice_list, request)
	else:
		members['providers'] = []
		local_practicesDict['providers'] = []

	context['mdcom_fwd'] = current_provider.get_forward_voicemail_display()
	context['anssvc_fwd'] = current_provider.get_forward_anssvc_display()

	context['mobile_phone'] = phone_formater(current_provider.mobile_phone)
	context['office_phone'] = phone_formater(current_provider.office_phone)
	context['other_phone'] = phone_formater(current_provider.phone)
	context['mdcom_phone'] = phone_formater(current_provider.mdcom_phone, display_provisionLink=True)
	context['zip'] = current_provider.zip

	#does this provider have pending incoming request to join practices,
	pend_assoc = Pending_Association.objects.filter(to_user=request.user)
	assoc_lst = [{'practice_location':e.practice_location, 'from_user':e.from_user} 
				for e in pend_assoc]

	pend_list = []
	for e in assoc_lst:
		p = {}
		p['user'] = e['from_user'].first_name + ' ' + e['from_user'].last_name
		p['practice_name'] = e['practice_location'].practice_name
		p['type'] = ''
		p['practice_addr'] = e['practice_location'].practice_address1 + '' + \
			e['practice_location'].practice_address2
		p['practice_zip'] = e['practice_location'].practice_zip

		pend_list.append(p)
	context['accept_invites_count'] = pend_list

	#add by xlin in 20120207
	providersDict = dict()
	community = dict()
	siteStaffDict = dict()
	providersDict['providers'] = providers
	community['providers'] = community_physicians
	siteStaffDict['users'] = site_staffs

	providersDict['userType'] = 0

	#add org tab 20120820
	mhluser = request.session['MHL_Users']['MHLUser']
	orgs = getOrganizationsOfUser(mhluser, current_practice=current_practice)
	providersDict['org'] = orgs
	context['orgOroviders'] = renderOrganizationForDashbord(orgs, request)

	providersDict["current_organization_type"] = get_org_type_name(current_practice, none_text="")
	context['tabUI'] = render_to_string('tabUI.html', providersDict)
	context['providers'] = render_to_string('userInfo.html', providersDict)
	context['site_staff'] = render_to_string('userInfo4.html', siteStaffDict)

	context['community_physicians'] = render_to_string('userInfo.html', community)
	context['practice_members'] = render_to_string('userInfo3.html', members)
	context['local_practices'] = render_to_string('userInfo2.html', local_practicesDict)
	context['my_favorite'] = get_my_favorite(mhluser, html=True)

	return render_to_response('dashboard_provider.html', context)
Example #9
0
def practice_main_view(request):
    """Displays office manager/staff home page."""

    if (not 'OfficeStaff' in request.session['MHL_UserIDs']):
        return err403(request)
        #print "%s %s is an Office_Manager"%(request.user.first_name, request.user.last_name)

    context = get_context(request)
    providerDict = dict()
    siteStaffDict = dict()
    local_practicesDict = dict()
    comm_professionalsDict = dict()
    practice_membersDict = dict()

    context['recent_sent_box'] = box_recent_sent(request)

    office_staff = request.session['MHL_Users']['OfficeStaff']
    current_practice = office_staff.current_practice
    context['zip'] = office_staff.user.zip

    if current_practice:
        context['mdcom_phone'] = phone_formater(current_practice.mdcom_phone)
        #list of practice for this location:
        practice_list = get_practices_by_position(
            current_practice.practice_lat,
            current_practice.practice_longit).only('practice_name', 'id')
        local_practicesDict['providers'] = set_practices_result(
            practice_list, request)

        #list of providers for this practice:
        practice_members = all_practice_members(current_practice.id,
                                                strip_staff_mobile=False,
                                                strip_staff_pager=False)
        practice_membersDict['providers'] = set_practice_members_result(
            practice_members, request)

    else:
        context['mdcom_phone'] = '(none)'
        #list of practice for this location:
        local_practicesDict['providers'] = []
        #list of providers for this practice:
        practice_membersDict['providers'] = []

    current_site = office_staff.current_site
    if (current_site != None):
        #context['site_providers'] = get_all_site_providers(office_staff.current_site.id)
        #		providerDict['providers'] = get_all_site_providers(office_staff.current_site.id)

        providers = get_all_site_providers(office_staff.current_site.id)
        set_providers_result(providers, request)
        providerDict['providers'] = providers
        site_staffs = get_all_site_staff(office_staff.current_site.id)
        siteStaffDict['users'] = set_site_staff_result(site_staffs,
                                                       office_staff)

        #context['current_site_short_name'] = office_staff.current_site.short_name
        if current_site.short_name:
            providerDict['current_site'] = current_site.short_name
        else:
            providerDict['current_site'] = current_site.name
    else:
        providerDict['current_site'] = _("Hospital Site")

    comm_professionals = get_community_professionals(current_practice)
    set_providers_result(comm_professionals, request)
    #raise Exception ('practice_providers', context)
    comm_professionalsDict['providers'] = comm_professionals
    #does this manager have business cell phone?
    #context['business_cell'] = office_staff.user.mobile_phone
    #	local_practicesDict['business_cell'] = office_staff.user.mobile_phone
    #does this practice have pending incoming requests for joining practice,
    #get all managers for this practice

    # refer to ticket #1292, make the search condition same with staff page.
    #	practice_staff = OfficeStaff.objects.filter(current_practice=current_practice).values('user')
    practice_staff = OfficeStaff.objects.filter().values('user')
    #	#get all pending to ANY manager from this practice
    #	#raise Exception(current_practice,OfficeManagers)
    pend_assoc = Pending_Association.objects.filter(
        practice_location=current_practice,
        to_user__in=practice_staff).filter(~Q(
            from_user__in=practice_staff)).count()

    context['receive_request_count'] = pend_assoc

    context['auto_refresh_time'] = settings.MSGLIST_AUTOREFRESH_TIME

    context['practice_members'] = render_to_string('userInfo3.html',
                                                   practice_membersDict)
    context['site_provider'] = render_to_string('userInfo.html', providerDict)
    context['site_staff'] = render_to_string('userInfo4.html', siteStaffDict)
    context['comm_professionals'] = render_to_string('userInfo.html',
                                                     comm_professionalsDict)
    context['local_practices'] = render_to_string('userInfo2.html',
                                                  local_practicesDict)

    mhluser = request.session['MHL_Users']['MHLUser']
    orgs = getOrganizationsOfUser(mhluser, current_practice=current_practice)
    providerDict['org'] = orgs

    context['orgOroviders'] = renderOrganizationForDashbord(orgs, request)
    context['my_favorite'] = get_my_favorite(mhluser, html=True)

    providerDict["current_organization_type"] = get_org_type_name(
        current_practice, none_text="")
    if Office_Manager.objects.filter(user=office_staff,
                                     practice=current_practice).exists():
        context['caller_anssvc'] = office_staff.get_caller_anssvc_display()
        context['mobile_phone'] = phone_formater(
            office_staff.user.mobile_phone)
        context['office_phone'] = phone_formater(office_staff.office_phone)
        context['other_phone'] = phone_formater(office_staff.user.phone)

        #add by xlin 20100208 for html code refacting
        providerDict['userType'] = 1

        context['tabUI'] = render_to_string('tabUI.html', providerDict)
        return render_to_response('dashboard_office_manager.html', context)

    providerDict['userType'] = 2
    context['tabUI'] = render_to_string('tabUI.html', providerDict)
    return render_to_response('dashboard_office_staff.html', context)
Example #10
0
def main_provider(request, user, user_type):
    """Displays the physician/np_pa's home page."""
    context = get_context(request)
    context['auto_refresh_time'] = settings.MSGLIST_AUTOREFRESH_TIME

    context['user_type'] = user_type
    current_provider = user.user

    providers = get_all_site_providers(current_provider.current_site)
    set_providers_result(providers, request)
    site_staffs = get_all_site_staff(current_provider.current_site)
    site_staffs = set_site_staff_result(site_staffs, current_provider)

    context['unread_msg_count'] = get_message_count(user.user, ('ANS', 'VM'),
                                                    read_flag=False)

    community_physicians = get_community_providers(user)
    set_providers_result(community_physicians, request)
    context['community_physicians'] = community_physicians
    members = dict()
    local_practicesDict = dict()
    current_practice = current_provider.current_practice
    if (current_practice):
        practice_members = all_practice_members(current_practice,
                                                strip_staff_mobile=False,
                                                strip_staff_pager=True)
        members['providers'] = set_practice_members_result(
            practice_members, request)
        practice_list = get_practices_by_position(
            current_practice.practice_lat,
            current_practice.practice_longit).only('practice_name', 'id')
        local_practicesDict['providers'] = set_practices_result(
            practice_list, request)
    else:
        members['providers'] = []
        local_practicesDict['providers'] = []

    context['mdcom_fwd'] = current_provider.get_forward_voicemail_display()
    context['anssvc_fwd'] = current_provider.get_forward_anssvc_display()

    context['mobile_phone'] = phone_formater(current_provider.mobile_phone)
    context['office_phone'] = phone_formater(current_provider.office_phone)
    context['other_phone'] = phone_formater(current_provider.phone)
    context['mdcom_phone'] = phone_formater(current_provider.mdcom_phone,
                                            display_provisionLink=True)
    context['zip'] = current_provider.zip

    #does this provider have pending incoming request to join practices,
    pend_assoc = Pending_Association.objects.filter(to_user=request.user)
    assoc_lst = [{
        'practice_location': e.practice_location,
        'from_user': e.from_user
    } for e in pend_assoc]

    pend_list = []
    for e in assoc_lst:
        p = {}
        p['user'] = e['from_user'].first_name + ' ' + e['from_user'].last_name
        p['practice_name'] = e['practice_location'].practice_name
        p['type'] = ''
        p['practice_addr'] = e['practice_location'].practice_address1 + '' + \
         e['practice_location'].practice_address2
        p['practice_zip'] = e['practice_location'].practice_zip

        pend_list.append(p)
    context['accept_invites_count'] = pend_list

    #add by xlin in 20120207
    providersDict = dict()
    community = dict()
    siteStaffDict = dict()
    providersDict['providers'] = providers
    community['providers'] = community_physicians
    siteStaffDict['users'] = site_staffs

    providersDict['userType'] = 0

    #add org tab 20120820
    mhluser = request.session['MHL_Users']['MHLUser']
    orgs = getOrganizationsOfUser(mhluser, current_practice=current_practice)
    providersDict['org'] = orgs
    context['orgOroviders'] = renderOrganizationForDashbord(orgs, request)

    providersDict["current_organization_type"] = get_org_type_name(
        current_practice, none_text="")
    context['tabUI'] = render_to_string('tabUI.html', providersDict)
    context['providers'] = render_to_string('userInfo.html', providersDict)
    context['site_staff'] = render_to_string('userInfo4.html', siteStaffDict)

    context['community_physicians'] = render_to_string('userInfo.html',
                                                       community)
    context['practice_members'] = render_to_string('userInfo3.html', members)
    context['local_practices'] = render_to_string('userInfo2.html',
                                                  local_practicesDict)
    context['my_favorite'] = get_my_favorite(mhluser, html=True)

    return render_to_response('dashboard_provider.html', context)