def report_context(self): from pact import api ret = {} try: patient_doc = self.get_case() has_error = False except Exception as ex: logging.exception('problem getting pact patient data for patient {}. {}'.format( self.patient_id, ex )) has_error = True patient_doc = None if patient_doc is None: self.report_template_path = "pact/patient/nopatient.html" if has_error: ret['error_message'] = "Patient not found" else: ret['error_message'] = "No patient selected" return ret view_mode = self.request.GET.get('view', 'info') ret['patient_doc'] = patient_doc ret['pt_root_url'] = patient_doc.get_info_url() ret['view_mode'] = view_mode if view_mode == 'info': self.report_template_path = "pact/patient/pactpatient_info.html" ret['cloudcare_addr_edit_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_ADDRESS) ret['cloudcare_pn_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_PROGRESS_NOTE) ret['cloudcare_dot_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_DOT) ret['cloudcare_bw_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_BLOODWORK) elif view_mode == 'submissions': tabular_context = super(PactPatientInfoReport, self).report_context tabular_context.update(ret) self.report_template_path = "pact/patient/pactpatient_submissions.html" return tabular_context elif view_mode == 'schedule': the_form = ScheduleForm() ret['schedule_form'] = the_form ret['schedule_fields'] = json.dumps(list(the_form.fields.keys())) self.report_template_path = "pact/patient/pactpatient_schedule.html" elif view_mode == 'edit': the_form = PactPatientForm(self.request, patient_doc) ret['patient_form'] = the_form self.report_template_path = "pact/patient/pactpatient_edit.html" elif view_mode == 'providers': self.report_template_path = "pact/patient/pactpatient_providers.html" elif view_mode == 'careplan': ret.update(case_hierarchy_context(patient_doc, lambda case_id: reverse('case_data', args=[PACT_DOMAIN, case_id]), show_view_buttons=False )) self.report_template_path = "pact/patient/pactpatient_careplan.html" else: raise Http404 return ret
def report_context(self): from pact import api ret = {} try: patient_doc = self.get_case() has_error = False except Exception as ex: logging.exception('problem getting pact patient data for patient {}. {}'.format( self.patient_id, ex )) has_error = True patient_doc = None if patient_doc is None: self.report_template_path = "pact/patient/nopatient.html" if has_error: ret['error_message'] = "Patient not found" else: ret['error_message'] = "No patient selected" return ret view_mode = self.request.GET.get('view', 'info') ret['patient_doc'] = patient_doc ret['pt_root_url'] = patient_doc.get_info_url() ret['view_mode'] = view_mode if view_mode == 'info': self.report_template_path = "pact/patient/pactpatient_info.html" ret['cloudcare_addr_edit_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_ADDRESS) ret['cloudcare_pn_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_PROGRESS_NOTE) ret['cloudcare_dot_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_DOT) ret['cloudcare_bw_url'] = api.get_cloudcare_url(patient_doc._id, api.FORM_BLOODWORK) elif view_mode == 'submissions': tabular_context = super(PactPatientInfoReport, self).report_context tabular_context.update(ret) self.report_template_path = "pact/patient/pactpatient_submissions.html" return tabular_context elif view_mode == 'schedule': the_form = ScheduleForm() ret['schedule_form'] = the_form ret['schedule_fields'] = json.dumps(list(the_form.fields.keys())) self.report_template_path = "pact/patient/pactpatient_schedule.html" elif view_mode == 'edit': the_form = PactPatientForm(self.request, patient_doc) ret['patient_form'] = the_form self.report_template_path = "pact/patient/pactpatient_edit.html" elif view_mode == 'providers': self.report_template_path = "pact/patient/pactpatient_providers.html" elif view_mode == 'careplan': ret.update(case_hierarchy_context(patient_doc, lambda case_id: reverse('case_data', args=[PACT_DOMAIN, case_id]), show_view_buttons=False )) self.report_template_path = "pact/patient/pactpatient_careplan.html" else: raise Http404 return ret
class PactPatientInfoReport(PactDrilldownReportMixin, PactElasticTabularReportMixin): slug = "patient" description = "some patient" hide_filters = True filters = [] ajax_pagination = True xform_es = ReportXFormES(PACT_DOMAIN) default_sort = {"received_on": "desc"} name = "Patient Info" @use_timeago def decorator_dispatcher(self, request, *args, **kwargs): return super(PactPatientInfoReport, self).decorator_dispatcher(request, *args, **kwargs) @property def patient_id(self): return self.request.GET.get('patient_id') def get_case(self): if self.patient_id is None: return None return PactPatientCase.get(self.patient_id) @property def report_context(self): from pact import api ret = {} try: patient_doc = self.get_case() has_error = False except Exception, ex: logging.exception( u'problem getting pact patient data for patient {}. {}'.format( self.patient_id, ex)) has_error = True patient_doc = None if patient_doc is None: self.report_template_path = "pact/patient/nopatient.html" if has_error: ret['error_message'] = "Patient not found" else: ret['error_message'] = "No patient selected" return ret view_mode = self.request.GET.get('view', 'info') ret['patient_doc'] = patient_doc ret['pt_root_url'] = patient_doc.get_info_url() ret['view_mode'] = view_mode if view_mode == 'info': self.report_template_path = "pact/patient/pactpatient_info.html" ret['cloudcare_addr_edit_url'] = api.get_cloudcare_url( patient_doc._id, api.FORM_ADDRESS) ret['cloudcare_pn_url'] = api.get_cloudcare_url( patient_doc._id, api.FORM_PROGRESS_NOTE) ret['cloudcare_dot_url'] = api.get_cloudcare_url( patient_doc._id, api.FORM_DOT) ret['cloudcare_bw_url'] = api.get_cloudcare_url( patient_doc._id, api.FORM_BLOODWORK) elif view_mode == 'submissions': tabular_context = super(PactPatientInfoReport, self).report_context tabular_context.update(ret) self.report_template_path = "pact/patient/pactpatient_submissions.html" return tabular_context elif view_mode == 'schedule': the_form = ScheduleForm() ret['schedule_form'] = the_form ret['schedule_fields'] = json.dumps(the_form.fields.keys()) self.report_template_path = "pact/patient/pactpatient_schedule.html" elif view_mode == 'edit': the_form = PactPatientForm(self.request, patient_doc) ret['patient_form'] = the_form self.report_template_path = "pact/patient/pactpatient_edit.html" elif view_mode == 'providers': self.report_template_path = "pact/patient/pactpatient_providers.html" elif view_mode == 'careplan': ret.update({ 'case_hierarchy_options': { "show_view_buttons": False, "get_case_url": lambda case_id: reverse('case_details', args=[PACT_DOMAIN, case_id]) }, 'case': patient_doc, }) self.report_template_path = "pact/patient/pactpatient_careplan.html" else: raise Http404 return ret