2019-07-12 06:58:34 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright (c) 2018, ESS LLP and contributors
|
|
|
|
# For license information, please see license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
2020-11-29 17:08:14 +00:00
|
|
|
import json
|
2019-07-12 06:58:34 +00:00
|
|
|
from frappe.utils import cint
|
|
|
|
from erpnext.healthcare.utils import render_docs_as_html
|
|
|
|
|
|
|
|
@frappe.whitelist()
|
2020-11-29 17:08:14 +00:00
|
|
|
def get_feed(name, document_types=None, start=0, page_length=20):
|
2019-07-12 06:58:34 +00:00
|
|
|
"""get feed"""
|
2020-11-29 17:08:14 +00:00
|
|
|
filters = {'patient': name}
|
|
|
|
if document_types:
|
|
|
|
document_types = json.loads(document_types)
|
2020-11-29 17:13:56 +00:00
|
|
|
if len(document_types):
|
|
|
|
filters['reference_doctype'] = ['IN', document_types]
|
2020-11-29 17:08:14 +00:00
|
|
|
|
|
|
|
result = frappe.db.get_all('Patient Medical Record',
|
|
|
|
fields=['name', 'owner', 'creation',
|
|
|
|
'reference_doctype', 'reference_name', 'subject'],
|
|
|
|
filters=filters,
|
|
|
|
order_by='creation DESC',
|
|
|
|
limit=cint(page_length),
|
|
|
|
start=cint(start)
|
|
|
|
)
|
|
|
|
|
2019-07-12 06:58:34 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
@frappe.whitelist()
|
|
|
|
def get_feed_for_dt(doctype, docname):
|
|
|
|
"""get feed"""
|
2020-11-29 17:08:14 +00:00
|
|
|
result = frappe.db.get_all('Patient Medical Record',
|
|
|
|
fields=['name', 'owner', 'creation',
|
|
|
|
'reference_doctype', 'reference_name', 'subject'],
|
|
|
|
filters={
|
|
|
|
'reference_doctype': doctype,
|
|
|
|
'reference_name': docname
|
|
|
|
},
|
|
|
|
order_by='creation DESC'
|
|
|
|
)
|
2019-07-12 06:58:34 +00:00
|
|
|
|
|
|
|
return result
|
2020-11-29 17:08:14 +00:00
|
|
|
|
|
|
|
@frappe.whitelist()
|
|
|
|
def get_patient_history_doctypes():
|
|
|
|
document_types = []
|
|
|
|
settings = frappe.get_single("Patient History Settings")
|
|
|
|
|
|
|
|
for entry in settings.standard_doctypes:
|
|
|
|
document_types.append(entry.document_type)
|
|
|
|
|
|
|
|
for entry in settings.custom_doctypes:
|
|
|
|
document_types.append(entry.document_type)
|
|
|
|
|
|
|
|
return document_types
|