[Enhance][Fix] Healthcare - DocType and Fields renaming (#14861)

* Rename DT - Physician Schedule Time Slot to Healthcare Schedule Time Slot

* Role name change

* Rename DT - Physician Schedule to Practitioner Schedule

* Rename DT - Physician Service Unit Schedule

* Rename DT - Physician to Practitioner

* Lab Test Template - field disabled in standard filter

* Patient - customer creation fix

* Rename DT - Consultation - Encounter

* Patches.txt updated for rename doctypes and fields in Healthcare

* Patch - Rename doctypes and fields in Healthcare Domain

* Fix - Patch - rename_healthcare_doctype_and_fields

* Vital Signs - New Fields - Abdomen, Tongue and Reflexes

* Web Form - Patient - Personal Details

* Rename DocType Physician to Healthcare Practitioner

* Rename DocType Consultation to Patient Encounter

* Web Form - Personal Details - Fix

* Web Form - Personal Details - Codacy Fix

* Healthcare patch run for all domain

* Rename label Practitioner to Healthcare Practitioner

* Rename Encounter to Patient Encounter
This commit is contained in:
Jamsheer 2018-07-16 18:08:53 +05:30 committed by Nabin Hait
parent 14e94f824e
commit f926911399
78 changed files with 1173 additions and 619 deletions

View File

@ -304,13 +304,13 @@ def get_data():
"hidden": 1
},
{
"module_name": "Consultation",
"module_name": "Patient Encounter",
"color": "#2ecc71",
"icon": "fa fa-stethoscope",
"doctype": "Consultation",
"doctype": "Patient Encounter",
"type": "link",
"link": "List/Consultation",
"label": _("Consultation"),
"link": "List/Patient Encounter",
"label": _("Patient Encounter"),
"hidden": 1
},
{

View File

@ -15,8 +15,8 @@ def get_data():
},
{
"type": "doctype",
"name": "Consultation",
"label": _("Consultation"),
"name": "Patient Encounter",
"label": _("Patient Encounter"),
},
{
"type": "doctype",
@ -74,13 +74,13 @@ def get_data():
},
{
"type": "doctype",
"name": "Physician",
"label": _("Physician"),
"name": "Healthcare Practitioner",
"label": _("Healthcare Practitioner"),
},
{
"type": "doctype",
"name": "Physician Schedule",
"label": _("Physician Schedule"),
"name": "Practitioner Schedule",
"label": _("Practitioner Schedule"),
},
{
"type": "doctype",

View File

@ -1,16 +1,16 @@
[
{
"doctype": "Physician",
"doctype": "Healthcare Practitioner",
"first_name": "Eddie Jessup",
"department": "Pathology"
},
{
"doctype": "Physician",
"doctype": "Healthcare Practitioner",
"first_name": "Deepshi Garg",
"department": "ENT"
},
{
"doctype": "Physician",
"doctype": "Healthcare Practitioner",
"first_name": "Amit Jain",
"department": "Microbiology"
}

View File

@ -16,12 +16,12 @@ def setup_data():
make_consulation()
make_appointment()
consulation_on_appointment()
lab_test_on_consultation()
lab_test_on_encounter()
frappe.db.commit()
frappe.clear_cache()
def make_masters():
import_json("Physician")
import_json("Healthcare Practitioner")
import_drug()
frappe.db.commit()
@ -46,8 +46,8 @@ def make_patient():
def make_appointment():
i = 1
while i <= 4:
physician = get_random("Physician")
department = frappe.get_value("Physician", physician, "department")
practitioner = get_random("Healthcare Practitioner")
department = frappe.get_value("Healthcare Practitioner", practitioner, "department")
patient = get_random("Patient")
patient_sex = frappe.get_value("Patient", patient, "sex")
appointment = frappe.new_doc("Patient Appointment")
@ -59,92 +59,92 @@ def make_appointment():
appointment.appointment_date = appointment_datetime
appointment.patient = patient
appointment.patient_sex = patient_sex
appointment.physician = physician
appointment.practitioner = practitioner
appointment.department = department
appointment.save(ignore_permissions = True)
i += 1
def make_consulation():
for i in range(3):
physician = get_random("Physician")
department = frappe.get_value("Physician", physician, "department")
practitioner = get_random("Healthcare Practitioner")
department = frappe.get_value("Healthcare Practitioner", practitioner, "department")
patient = get_random("Patient")
patient_sex = frappe.get_value("Patient", patient, "sex")
consultation = set_consultation(patient, patient_sex, physician, department, getdate(), i)
consultation.save(ignore_permissions=True)
encounter = set_encounter(patient, patient_sex, practitioner, department, getdate(), i)
encounter.save(ignore_permissions=True)
def consulation_on_appointment():
for i in range(3):
appointment = get_random("Patient Appointment")
appointment = frappe.get_doc("Patient Appointment",appointment)
consultation = set_consultation(appointment.patient, appointment.patient_sex, appointment.physician, appointment.department, appointment.appointment_date, i)
consultation.appointment = appointment.name
consultation.save(ignore_permissions=True)
encounter = set_encounter(appointment.patient, appointment.patient_sex, appointment.practitioner, appointment.department, appointment.appointment_date, i)
encounter.appointment = appointment.name
encounter.save(ignore_permissions=True)
def set_consultation(patient, patient_sex, physician, department, consultation_date, i):
consultation = frappe.new_doc("Consultation")
consultation.patient = patient
consultation.patient_sex = patient_sex
consultation.physician = physician
consultation.visit_department = department
consultation.consultation_date = consultation_date
def set_encounter(patient, patient_sex, practitioner, department, encounter_date, i):
encounter = frappe.new_doc("Patient Encounter")
encounter.patient = patient
encounter.patient_sex = patient_sex
encounter.practitioner = practitioner
encounter.visit_department = department
encounter.encounter_date = encounter_date
if i > 2 and patient_sex=='Female':
consultation.symptoms = "Having chest pains for the last week."
consultation.diagnosis = """This patient's description of dull, aching,
encounter.symptoms = "Having chest pains for the last week."
encounter.diagnosis = """This patient's description of dull, aching,
exertion related substernal chest pain is suggestive of ischemic
cardiac origin. Her findings of a FH of early ASCVD, hypertension,
and early surgical menopause are pertinent risk factors for development
of coronary artery disease. """
else:
consultation = append_drug_rx(consultation)
consultation = append_test_rx(consultation)
return consultation
encounter = append_drug_rx(encounter)
encounter = append_test_rx(encounter)
return encounter
def make_lab_test():
physician = get_random("Physician")
practitioner = get_random("Healthcare Practitioner")
patient = get_random("Patient")
patient_sex = frappe.get_value("Patient", patient, "sex")
template = get_random("Lab Test Template")
set_lab_test(patient, patient_sex, physician, template)
set_lab_test(patient, patient_sex, practitioner, template)
def lab_test_on_consultation():
def lab_test_on_encounter():
i = 1
while i <= 2:
test_rx = get_random("Lab Prescription", filters={'test_created': 0})
test_rx = frappe.get_doc("Lab Prescription", test_rx)
consultation = frappe.get_doc("Consultation", test_rx.parent)
set_lab_test(consultation.patient, consultation.patient_sex, consultation.physician, test_rx.test_code, test_rx.name)
encounter = frappe.get_doc("Patient Encounter", test_rx.parent)
set_lab_test(encounter.patient, encounter.patient_sex, encounter.practitioner, test_rx.test_code, test_rx.name)
i += 1
def set_lab_test(patient, patient_sex, physician, template, rx=None):
def set_lab_test(patient, patient_sex, practitioner, template, rx=None):
lab_test = frappe.new_doc("Lab Test")
lab_test.physician = physician
lab_test.practitioner = practitioner
lab_test.patient = patient
lab_test.patient_sex = patient_sex
lab_test.template = template
lab_test.prescription = rx
create_test_from_template(lab_test)
def append_test_rx(consultation):
def append_test_rx(encounter):
i = 1
while i <= 2:
test_rx = consultation.append("test_prescription")
test_rx = encounter.append("test_prescription")
test_rx.test_code = get_random("Lab Test Template")
i += 1
return consultation
return encounter
def append_drug_rx(consultation):
def append_drug_rx(encounter):
i = 1
while i <= 3:
drug = get_random("Item", filters={"item_group":"Drug"})
drug = frappe.get_doc("Item", drug)
drug_rx = consultation.append("drug_prescription")
drug_rx = encounter.append("drug_prescription")
drug_rx.drug_code = drug.item_code
drug_rx.drug_name = drug.item_name
drug_rx.dosage = get_random("Prescription Dosage")
drug_rx.period = get_random("Prescription Duration")
i += 1
return consultation
return encounter
def random_date(start,l):
current = start

View File

@ -2,7 +2,7 @@ data = {
'desktop_icons': [
'Patient',
'Patient Appointment',
'Consultation',
'Patient Encounter',
'Lab Test',
'Healthcare',
'Accounts',
@ -26,4 +26,4 @@ data = {
insert_after='customer')
},
'on_setup': 'erpnext.healthcare.setup.setup_healthcare'
}
}

View File

@ -725,7 +725,7 @@
"print": 1,
"read": 1,
"report": 1,
"role": "Medical Administrator",
"role": "Healthcare Administrator",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
@ -781,4 +781,4 @@
"title_field": "template",
"track_changes": 1,
"track_seen": 1
}
}

View File

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, ESS LLP and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest
# test_records = frappe.get_test_records('Consultation')
class TestConsultation(unittest.TestCase):
pass

View File

@ -14,11 +14,12 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@ -27,10 +28,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Physician",
"label": "Healthcare Practitioner",
"length": 0,
"no_copy": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -41,10 +42,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -72,10 +75,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -102,10 +107,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -132,10 +139,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -162,10 +171,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -193,6 +204,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -206,7 +218,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-05 11:26:35.292841",
"modified": "2018-07-16 12:43:45.635230",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Fee Validity",
@ -215,7 +227,6 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@ -238,11 +249,11 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "physician,patient",
"search_fields": "practitioner, patient",
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "physician",
"title_field": "practitioner",
"track_changes": 0,
"track_seen": 0
}

View File

@ -13,7 +13,7 @@ from frappe.utils import nowdate, add_days
class TestFeeValidity(unittest.TestCase):
def test_fee_validity(self):
patient = get_random("Patient")
physician = get_random("Physician")
practitioner = get_random("Healthcare Practitioner")
department = get_random("Medical Department")
if not patient:
@ -29,36 +29,36 @@ class TestFeeValidity(unittest.TestCase):
medical_department.save(ignore_permissions=True)
department = medical_department.name
if not physician:
physician = frappe.new_doc("Physician")
physician.first_name = "Amit Jain"
physician.department = department
physician.save(ignore_permissions=True)
physician = physician.name
if not practitioner:
practitioner = frappe.new_doc("Healthcare Practitioner")
practitioner.first_name = "Amit Jain"
practitioner.department = department
practitioner.save(ignore_permissions=True)
practitioner = practitioner.name
frappe.db.set_value("Healthcare Settings", None, "max_visit", 2)
frappe.db.set_value("Healthcare Settings", None, "valid_days", 7)
appointment = create_appointment(patient, physician, nowdate(), department)
appointment = create_appointment(patient, practitioner, nowdate(), department)
invoice = frappe.db.get_value("Patient Appointment", appointment.name, "sales_invoice")
self.assertEqual(invoice, None)
invoice_appointment(appointment)
appointment = create_appointment(patient, physician, add_days(nowdate(), 4), department)
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 4), department)
invoice = frappe.db.get_value("Patient Appointment", appointment.name, "sales_invoice")
self.assertTrue(invoice)
appointment = create_appointment(patient, physician, add_days(nowdate(), 5), department)
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 5), department)
invoice = frappe.db.get_value("Patient Appointment", appointment.name, "sales_invoice")
self.assertEqual(invoice, None)
appointment = create_appointment(patient, physician, add_days(nowdate(), 10), department)
appointment = create_appointment(patient, practitioner, add_days(nowdate(), 10), department)
invoice = frappe.db.get_value("Patient Appointment", appointment.name, "sales_invoice")
self.assertEqual(invoice, None)
def create_appointment(patient, physician, appointment_date, department):
def create_appointment(patient, practitioner, appointment_date, department):
appointment = frappe.new_doc("Patient Appointment")
appointment.patient = patient
appointment.physician = physician
appointment.practitioner = practitioner
appointment.department = department
appointment.appointment_date = appointment_date
appointment.company = "_Test Company"

View File

@ -1,7 +1,7 @@
// Copyright (c) 2016, ESS LLP and contributors
// For license information, please see license.txt
frappe.ui.form.on('Physician', {
frappe.ui.form.on('Healthcare Practitioner', {
setup: function(frm) {
frm.set_query('account', 'accounts', function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
@ -15,11 +15,11 @@ frappe.ui.form.on('Physician', {
});
},
refresh: function(frm) {
frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Physician'};
frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Healthcare Practitioner'};
if(!frm.is_new()) {
frappe.contacts.render_address_and_contact(frm);
}
frm.set_query("service_unit", "physician_schedules", function(){
frm.set_query("service_unit", "practitioner_schedules", function(){
return {
filters: {
"is_group": false,
@ -30,7 +30,7 @@ frappe.ui.form.on('Physician', {
}
});
frappe.ui.form.on("Physician", "user_id",function(frm) {
frappe.ui.form.on("Healthcare Practitioner", "user_id",function(frm) {
if(frm.doc.user_id){
frappe.call({
"method": "frappe.client.get",
@ -64,7 +64,7 @@ frappe.ui.form.on("Physician", "user_id",function(frm) {
}
});
frappe.ui.form.on("Physician", "employee", function(frm) {
frappe.ui.form.on("Healthcare Practitioner", "employee", function(frm) {
if(frm.doc.employee){
frappe.call({
"method": "frappe.client.get",

View File

@ -14,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -45,6 +46,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -76,6 +78,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -107,6 +110,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -138,6 +142,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -170,6 +175,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -202,6 +208,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -234,6 +241,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -266,6 +274,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -296,6 +305,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -327,6 +337,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -358,6 +369,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -389,6 +401,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -420,6 +433,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -451,11 +465,12 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "physician_schedules",
"fieldname": "practitioner_schedules",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
@ -464,10 +479,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Physician Schedules",
"label": "Practitioner Schedules",
"length": 0,
"no_copy": 0,
"options": "Physician Service Unit Schedule",
"options": "Practitioner Service Unit Schedule",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -483,6 +498,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -514,6 +530,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -546,6 +563,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -577,6 +595,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -608,6 +627,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -638,6 +658,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -669,6 +690,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -700,6 +722,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -732,6 +755,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -774,16 +798,15 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-03-09 15:25:43.166877",
"modified": "2018-07-10 11:18:58.760297",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Physician",
"name": "Healthcare Practitioner",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
@ -803,7 +826,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
@ -823,7 +845,6 @@
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,

View File

@ -10,12 +10,12 @@ from frappe.utils import cstr
from erpnext.accounts.party import validate_party_accounts
from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
class Physician(Document):
class HealthcarePractitioner(Document):
def onload(self):
load_address_and_contact(self)
def autoname(self):
# physician first_name and last_name
# practitioner first_name and last_name
self.name = " ".join(filter(None,
[cstr(self.get(f)).strip() for f in ["first_name","middle_name","last_name"]]))
@ -25,20 +25,20 @@ class Physician(Document):
if self.user_id:
self.validate_for_enabled_user_id()
self.validate_duplicate_user_id()
existing_user_id = frappe.db.get_value("Physician", self.name, "user_id")
existing_user_id = frappe.db.get_value("Healthcare Practitioner", self.name, "user_id")
if self.user_id != existing_user_id:
frappe.permissions.remove_user_permission(
"Physician", self.name, existing_user_id)
"Healthcare Practitioner", self.name, existing_user_id)
else:
existing_user_id = frappe.db.get_value("Physician", self.name, "user_id")
existing_user_id = frappe.db.get_value("Healthcare Practitioner", self.name, "user_id")
if existing_user_id:
frappe.permissions.remove_user_permission(
"Physician", self.name, existing_user_id)
"Healthcare Practitioner", self.name, existing_user_id)
def on_update(self):
if self.user_id:
frappe.permissions.add_user_permission("Physician", self.name, self.user_id)
frappe.permissions.add_user_permission("Healthcare Practitioner", self.name, self.user_id)
def validate_for_enabled_user_id(self):
@ -49,11 +49,11 @@ class Physician(Document):
frappe.throw(_("User {0} is disabled").format(self.user_id))
def validate_duplicate_user_id(self):
physician = frappe.db.sql_list("""select name from `tabPhysician` where
practitioner = frappe.db.sql_list("""select name from `tabHealthcare Practitioner` where
user_id=%s and name!=%s""", (self.user_id, self.name))
if physician:
throw(_("User {0} is already assigned to Physician {1}").format(
self.user_id, physician[0]), frappe.DuplicateEntryError)
if practitioner:
throw(_("User {0} is already assigned to Healthcare Practitioner {1}").format(
self.user_id, practitioner[0]), frappe.DuplicateEntryError)
def on_trash(self):
delete_contact_and_address('Physician', self.name)
delete_contact_and_address('Healthcare Practitioner', self.name)

View File

@ -3,12 +3,12 @@ from frappe import _
def get_data():
return {
'heatmap': True,
'heatmap_message': _('This is based on transactions against this Physician.'),
'fieldname': 'physician',
'heatmap_message': _('This is based on transactions against this Healthcare Practitioner.'),
'fieldname': 'practitioner',
'transactions': [
{
'label': _('Appointments and Consultations'),
'items': ['Patient Appointment', 'Consultation']
'label': _('Appointments and Patient Encounters'),
'items': ['Patient Appointment', 'Patient Encounter']
},
{
'label': _('Lab Tests'),

View File

@ -2,15 +2,15 @@
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Physician", function (assert) {
QUnit.test("test: Healthcare Practitioner", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Physician
() => frappe.tests.make('Physician', [
// insert a new Healthcare Practitioner
() => frappe.tests.make('Healthcare Practitioner', [
// values to be set
{key: 'value'}
]),

View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest
class TestHealthcarePractitioner(unittest.TestCase):
pass

View File

@ -41,6 +41,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -71,6 +72,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
@ -101,6 +103,7 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -114,10 +117,10 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-07-12 14:28:01.985998",
"modified": "2018-05-08 13:45:57.226530",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Physician Schedule Time Slot",
"name": "Healthcare Schedule Time Slot",
"name_case": "",
"owner": "rmehta@gmail.com",
"permissions": [],

View File

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from frappe.model.document import Document
class PhysicianScheduleTimeSlot(Document):
class HealthcareScheduleTimeSlot(Document):
pass

View File

@ -380,7 +380,7 @@
"print": 1,
"read": 1,
"report": 1,
"role": "Medical Administrator",
"role": "Healthcare Administrator",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
@ -417,4 +417,4 @@
"title_field": "healthcare_service_unit_name",
"track_changes": 1,
"track_seen": 0
}
}

View File

@ -14,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -40,10 +41,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -71,10 +74,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -103,10 +108,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -134,10 +141,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -163,10 +172,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -193,10 +204,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -225,10 +238,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -242,7 +257,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Consultations in valid days",
"label": "Patient Encounters in valid days",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -255,10 +270,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -285,10 +302,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -315,10 +334,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -345,10 +366,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -377,10 +400,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -407,15 +432,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Hello {{doc.patient}}, You have scheduled an appointment with {{doc.physician}} by {{doc.start_dt}} at {{doc.company}}.\nThank you, Good day!",
"default": "Hello {{doc.patient}}, You have scheduled an appointment with {{doc.practitioner}} by {{doc.start_dt}} at {{doc.company}}.\nThank you, Good day!",
"depends_on": "app_con",
"fieldname": "app_con_msg",
"fieldtype": "Small Text",
@ -439,10 +466,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -471,10 +500,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -500,10 +531,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -530,15 +563,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Hello {{doc.patient}}, You have an appointment with {{doc.physician}} by {{doc.appointment_time}} at {{doc.company}}.\nThank you, Good day!\n",
"default": "Hello {{doc.patient}}, You have an appointment with {{doc.practitioner}} by {{doc.appointment_time}} at {{doc.company}}.\nThank you, Good day!\n",
"depends_on": "app_rem",
"fieldname": "app_rem_msg",
"fieldtype": "Small Text",
@ -562,10 +597,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -593,15 +630,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"columns": 0,
"description": "Default income accounts to be used if not set in Physician to book Consultation charges.",
"description": "Default income accounts to be used if not set in Healthcare Practitioner to book Appointment charges.",
"fieldname": "sb_in_ac",
"fieldtype": "Section Break",
"hidden": 0,
@ -624,10 +663,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -655,15 +696,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
"columns": 0,
"description": "Default receivable accounts to be used if not set in Patient to book Consultation charges.",
"description": "Default receivable accounts to be used if not set in Patient to book Appointment charges.",
"fieldname": "sb_r_ac",
"fieldtype": "Section Break",
"hidden": 0,
@ -686,10 +729,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -717,10 +762,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -747,10 +794,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -778,10 +827,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -808,10 +859,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -837,10 +890,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -868,10 +923,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -899,10 +956,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -929,10 +988,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -960,10 +1021,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -989,10 +1052,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1020,6 +1085,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -1033,7 +1099,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-05 11:36:44.087182",
"modified": "2018-07-16 14:00:04.171717",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Settings",
@ -1042,7 +1108,6 @@
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,

View File

@ -50,9 +50,9 @@ def get_receivable_account(company):
return receivable_account
return frappe.db.get_value("Company", company, "default_receivable_account")
def get_income_account(physician, company):
if(physician):
income_account = get_account("Physician", None, physician, company)
def get_income_account(practitioner, company):
if(practitioner):
income_account = get_account("Healthcare Practitioner", None, practitioner, company)
if income_account:
return income_account
income_account = get_account(None, "income_account", "Healthcare Settings", company)

View File

@ -30,7 +30,7 @@ frappe.ui.form.on('Lab Test', {
});
}
if(frm.doc.__islocal){
frm.add_custom_button(__('Get from Consultation'), function () {
frm.add_custom_button(__('Get from Patient Encounter'), function () {
get_lab_test_prescribed(frm);
});
}
@ -60,7 +60,7 @@ frappe.ui.form.on('Lab Test', {
},
onload: function (frm) {
frm.add_fetch("physician", "department", "department");
frm.add_fetch("practitioner", "department", "department");
if(frm.doc.employee){
frappe.call({
method: "frappe.client.get",
@ -160,21 +160,21 @@ var show_lab_tests = function(frm, result){
$.each(result, function(x, y){
var row = $(repl('<div class="col-xs-12" style="padding-top:12px; text-align:center;" >\
<div class="col-xs-2"> %(lab_test)s </div>\
<div class="col-xs-2"> %(consultation)s </div>\
<div class="col-xs-3"> %(physician)s </div>\
<div class="col-xs-2"> %(encounter)s </div>\
<div class="col-xs-3"> %(practitioner)s </div>\
<div class="col-xs-3"> %(date)s </div>\
<div class="col-xs-1">\
<a data-name="%(name)s" data-lab-test="%(lab_test)s"\
data-consultation="%(consultation)s" data-physician="%(physician)s"\
data-encounter="%(encounter)s" data-practitioner="%(practitioner)s"\
data-invoice="%(invoice)s" href="#"><button class="btn btn-default btn-xs">Get Lab Test\
</button></a></div></div>', {name:y[0], lab_test: y[1], consultation:y[2], invoice:y[3], physician:y[4], date:y[5]})).appendTo(html_field);
</button></a></div></div>', {name:y[0], lab_test: y[1], encounter:y[2], invoice:y[3], practitioner:y[4], date:y[5]})).appendTo(html_field);
row.find("a").click(function() {
frm.doc.template = $(this).attr("data-lab-test");
frm.doc.prescription = $(this).attr("data-name");
frm.doc.physician = $(this).attr("data-physician");
frm.doc.practitioner = $(this).attr("data-practitioner");
frm.set_df_property("template", "read_only", 1);
frm.set_df_property("patient", "read_only", 1);
frm.set_df_property("physician", "read_only", 1);
frm.set_df_property("practitioner", "read_only", 1);
if($(this).attr("data-invoice") != 'null'){
frm.doc.invoice = $(this).attr("data-invoice");
refresh_field("invoice");

View File

@ -15,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -42,11 +43,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -74,11 +76,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -106,16 +109,17 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "patient.patient_name",
"fetch_from": "patient.patient_name",
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
@ -139,11 +143,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -170,11 +175,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -202,16 +208,17 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -220,10 +227,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Doctor",
"label": "Healthcare Practitioner",
"length": 0,
"no_copy": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -234,11 +241,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -265,11 +273,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -296,11 +305,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -328,11 +338,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -358,11 +369,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -390,11 +402,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -422,11 +435,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -453,11 +467,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -484,11 +499,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -516,11 +532,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -548,11 +565,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -581,16 +599,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "employee.employee_name",
"fetch_from": "employee.employee_name",
"fieldname": "employee_name",
"fieldtype": "Data",
"hidden": 0,
@ -614,16 +633,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "employee.designation",
"fetch_from": "employee.designation",
"fieldname": "employee_designation",
"fieldtype": "Data",
"hidden": 0,
@ -647,11 +667,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -679,11 +700,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -710,11 +732,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -740,11 +763,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -771,11 +795,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -801,11 +826,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -833,11 +859,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -865,11 +892,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -895,11 +923,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -926,11 +955,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -956,11 +986,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -987,11 +1018,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1017,11 +1049,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1048,11 +1081,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1078,11 +1112,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1109,11 +1144,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -1140,11 +1176,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1171,11 +1208,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1202,11 +1240,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1234,11 +1273,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1265,11 +1305,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1296,11 +1337,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1327,11 +1369,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1358,11 +1401,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1389,11 +1433,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1421,7 +1466,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
}
],
@ -1436,7 +1481,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-16 22:43:40.341869",
"modified": "2018-07-16 12:47:01.425117",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test",
@ -1505,7 +1550,7 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "patient,invoice,physician,test_name,sample",
"search_fields": "patient,invoice,practitioner,test_name,sample",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",

View File

@ -60,13 +60,13 @@ def update_status(status, name):
def update_lab_test_print_sms_email_status(print_sms_email, name):
frappe.db.set_value("Lab Test",name,print_sms_email,1)
def create_lab_test_doc(invoice, consultation, patient, template):
def create_lab_test_doc(invoice, encounter, patient, template):
#create Test Result for template, copy vals from Invoice
lab_test = frappe.new_doc("Lab Test")
if(invoice):
lab_test.invoice = invoice
if(consultation):
lab_test.physician = consultation.physician
if(encounter):
lab_test.practitioner = encounter.practitioner
lab_test.patient = patient.name
lab_test.patient_age = patient.get_age()
lab_test.patient_sex = patient.sex
@ -159,9 +159,9 @@ def create_lab_test_from_desk(patient, template, prescription, invoice=None):
if not (template):
return
patient = frappe.get_doc("Patient", patient)
consultation_id = frappe.get_value("Lab Prescription", prescription, "parent")
consultation = frappe.get_doc("Consultation", consultation_id)
lab_test = create_lab_test(patient, template, prescription, consultation, invoice)
encounter_id = frappe.get_value("Lab Prescription", prescription, "parent")
encounter = frappe.get_doc("Patient Encounter", encounter_id)
lab_test = create_lab_test(patient, template, prescription, encounter, invoice)
return lab_test.name
def create_sample_collection(lab_test, template, patient, invoice):
@ -215,8 +215,8 @@ def load_result_format(lab_test, template, prescription, invoice):
lab_test.save(ignore_permissions=True) # insert the result
return lab_test
def create_lab_test(patient, template, prescription, consultation, invoice):
lab_test = create_lab_test_doc(invoice, consultation, patient, template)
def create_lab_test(patient, template, prescription, encounter, invoice):
lab_test = create_lab_test_doc(invoice, encounter, patient, template)
lab_test = create_sample_collection(lab_test, template, patient, invoice)
lab_test = load_result_format(lab_test, template, prescription, invoice)
return lab_test
@ -292,5 +292,5 @@ def create_invoice(company, patient, lab_tests, prescriptions):
@frappe.whitelist()
def get_lab_test_prescribed(patient):
return frappe.db.sql("""select cp.name, cp.test_code, cp.parent, cp.invoice, ct.physician, ct.consultation_date from tabConsultation ct,
return frappe.db.sql("""select cp.name, cp.test_code, cp.parent, cp.invoice, ct.practitioner, ct.encounter_date from `tabPatient Encounter` ct,
`tabLab Prescription` cp where ct.patient=%s and cp.parent=ct.name and cp.test_created=0""", (patient))

View File

@ -14,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -40,11 +41,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -72,11 +74,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -103,11 +106,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -136,11 +140,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -168,11 +173,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -198,11 +204,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -232,11 +239,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -266,11 +274,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -299,11 +308,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -332,11 +342,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -364,11 +375,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -395,11 +407,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -425,11 +438,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -458,11 +472,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -489,11 +504,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -521,11 +537,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -553,11 +570,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -584,11 +602,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -616,11 +635,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -648,11 +668,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -678,11 +699,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -709,11 +731,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -740,11 +763,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -772,16 +796,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "sample.sample_uom",
"fetch_from": "sample.sample_uom",
"fieldname": "sample_uom",
"fieldtype": "Data",
"hidden": 0,
@ -805,11 +830,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -837,11 +863,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -868,11 +895,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -900,11 +928,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -918,7 +947,7 @@
"in_filter": 1,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"in_standard_filter": 1,
"label": "disabled",
"length": 0,
"no_copy": 0,
@ -932,7 +961,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
}
],
@ -946,7 +975,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-16 22:43:26.086857",
"modified": "2018-07-02 11:58:00.266070",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Lab Test Template",

View File

@ -33,8 +33,8 @@ frappe.ui.form.on('Patient', {
frm.add_custom_button(__('Medical Record'), function () {
create_medical_record(frm);
}, "Create");
frm.add_custom_button(__('Consultation'), function () {
btn_create_consultation(frm);
frm.add_custom_button(__('Patient Encounter'), function () {
btn_create_encounter(frm);
}, "Create");
}
},
@ -94,14 +94,14 @@ var btn_create_vital_signs = function (frm) {
frappe.new_doc("Vital Signs");
};
var btn_create_consultation = function (frm) {
var btn_create_encounter = function (frm) {
if (!frm.doc.name) {
frappe.throw(__("Please save the patient first"));
}
frappe.route_options = {
"patient": frm.doc.name,
};
frappe.new_doc("Consultation");
frappe.new_doc("Patient Encounter");
};
var btn_invoice_registration = function (frm) {

View File

@ -81,7 +81,7 @@ def create_customer(doc):
territory = "Rest Of The World"
frappe.msgprint(_("Please set default customer group and territory in Selling Settings"), alert=True)
customer = frappe.get_doc({"doctype": "Customer",
"customer_name": doc.name,
"customer_name": doc.patient_name,
"customer_group": customer_group,
"territory" : territory,
"customer_type": "Individual"

View File

@ -7,8 +7,8 @@ def get_data():
'fieldname': 'patient',
'transactions': [
{
'label': _('Appointments and Consultations'),
'items': ['Patient Appointment', 'Consultation']
'label': _('Appointments and Patient Encounters'),
'items': ['Patient Appointment', 'Patient Encounter']
},
{
'label': _('Lab Tests and Vital Signs'),

View File

@ -6,7 +6,7 @@ frappe.ui.form.on('Patient Appointment', {
frm.custom_make_buttons = {
'Sales Invoice': 'Invoice',
'Vital Signs': 'Vital Signs',
'Consultation': 'Consultation'
'Patient Encounter': 'Patient Encounter'
};
},
refresh: function(frm) {
@ -15,7 +15,7 @@ frappe.ui.form.on('Patient Appointment', {
filters: {"disabled": 0}
};
});
frm.set_query("physician", function() {
frm.set_query("practitioner", function() {
return {
filters: {
'department': frm.doc.department
@ -47,8 +47,8 @@ frappe.ui.form.on('Patient Appointment', {
},"Create");
}
else{
frm.add_custom_button(__("Consultation"),function(){
btn_create_consultation(frm);
frm.add_custom_button(__("Patient Encounter"),function(){
btn_create_encounter(frm);
},"Create");
}
@ -67,8 +67,8 @@ frappe.ui.form.on('Patient Appointment', {
},"Create");
}
else{
frm.add_custom_button(__("Consultation"),function(){
btn_create_consultation(frm);
frm.add_custom_button(__("Patient Encounter"),function(){
btn_create_encounter(frm);
},"Create");
}
@ -93,22 +93,22 @@ frappe.ui.form.on('Patient Appointment', {
}
else if(frm.doc.status != "Cancelled" && frappe.user.has_role("Accounts User")){
frm.add_custom_button(__('Invoice'), function() {
btn_invoice_consultation(frm);
btn_invoice_encounter(frm);
},__("Create"));
}
}
},
check_availability: function(frm) {
var { physician, appointment_date } = frm.doc;
if(!(physician && appointment_date)) {
frappe.throw(__("Please select Physician and Date"));
var { practitioner, appointment_date } = frm.doc;
if(!(practitioner && appointment_date)) {
frappe.throw(__("Please select Healthcare Practitioner and Date"));
}
// show booking modal
frm.call({
method: 'get_availability_data',
args: {
physician: physician,
practitioner: practitioner,
date: appointment_date
},
callback: (r) => {
@ -124,7 +124,7 @@ frappe.ui.form.on('Patient Appointment', {
function show_empty_state() {
frappe.msgprint({
title: __('Not Available'),
message: __("Physician {0} not available on {1}", [physician.bold(), appointment_date.bold()]),
message: __("Healthcare Practitioner {0} not available on {1}", [practitioner.bold(), appointment_date.bold()]),
indicator: 'red'
});
}
@ -216,7 +216,7 @@ frappe.ui.form.on('Patient Appointment', {
frm.disable_save();
}
},
get_procedure_from_consultation: function(frm) {
get_procedure_from_encounter: function(frm) {
get_procedure_prescribed(frm);
}
});
@ -249,26 +249,26 @@ var show_procedure_templates = function(frm, result){
html_field.empty();
$.each(result, function(x, y){
var row = $(repl('<div class="col-xs-12" style="padding-top:12px; text-align:center;" >\
<div class="col-xs-5"> %(consultation)s <br> %(consulting_physician)s <br> %(consultation_date)s </div>\
<div class="col-xs-5"> %(procedure_template)s <br>%(physician)s <br> %(date)s</div>\
<div class="col-xs-5"> %(encounter)s <br> %(consulting_practitioner)s <br> %(encounter_date)s </div>\
<div class="col-xs-5"> %(procedure_template)s <br>%(practitioner)s <br> %(date)s</div>\
<div class="col-xs-2">\
<a data-name="%(name)s" data-procedure-template="%(procedure_template)s"\
data-consultation="%(consultation)s" data-physician="%(physician)s"\
data-encounter="%(encounter)s" data-practitioner="%(practitioner)s"\
data-date="%(date)s" data-department="%(department)s">\
<button class="btn btn-default btn-xs">Add\
</button></a></div></div><div class="col-xs-12"><hr/><div/>', {name:y[0], procedure_template: y[1],
consultation:y[2], consulting_physician:y[3], consultation_date:y[4],
physician:y[5]? y[5]:'', date: y[6]? y[6]:'', department: y[7]? y[7]:''})).appendTo(html_field);
encounter:y[2], consulting_practitioner:y[3], encounter_date:y[4],
practitioner:y[5]? y[5]:'', date: y[6]? y[6]:'', department: y[7]? y[7]:''})).appendTo(html_field);
row.find("a").click(function() {
frm.doc.procedure_template = $(this).attr("data-procedure-template");
frm.doc.procedure_prescription = $(this).attr("data-name");
frm.doc.physician = $(this).attr("data-physician");
frm.doc.practitioner = $(this).attr("data-practitioner");
frm.doc.appointment_date = $(this).attr("data-date");
frm.doc.department = $(this).attr("data-department");
refresh_field("procedure_template");
refresh_field("procedure_prescription");
refresh_field("appointment_date");
refresh_field("physician");
refresh_field("practitioner");
refresh_field("department");
d.hide();
return false;
@ -295,10 +295,10 @@ var btn_create_procedure = function(frm){
});
};
var btn_create_consultation = function(frm){
var btn_create_encounter = function(frm){
var doc = frm.doc;
frappe.call({
method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.create_consultation",
method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.create_encounter",
args: {appointment: doc.name},
callback: function(data){
if(!data.exc){
@ -338,7 +338,7 @@ var btn_update_status = function(frm, status){
);
};
var btn_invoice_consultation = function(frm){
var btn_invoice_encounter = function(frm){
frappe.call({
doc: frm.doc,
method:"create_invoice",
@ -353,13 +353,13 @@ var btn_invoice_consultation = function(frm){
});
};
frappe.ui.form.on("Patient Appointment", "physician", function(frm) {
if(frm.doc.physician){
frappe.ui.form.on("Patient Appointment", "practitioner", function(frm) {
if(frm.doc.practitioner){
frappe.call({
"method": "frappe.client.get",
args: {
doctype: "Physician",
name: frm.doc.physician
doctype: "Healthcare Practitioner",
name: frm.doc.practitioner
},
callback: function (data) {
frappe.model.set_value(frm.doctype,frm.docname, "department",data.message.department);

View File

@ -15,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -42,11 +43,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -74,16 +76,17 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -92,10 +95,10 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Physician",
"label": "Healthcare Practitioner",
"length": 0,
"no_copy": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -106,16 +109,17 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "get_procedure_from_consultation",
"fieldname": "get_procedure_from_encounter",
"fieldtype": "Button",
"hidden": 0,
"ignore_user_permissions": 0,
@ -137,11 +141,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -169,11 +174,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -201,11 +207,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -232,11 +239,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -263,11 +271,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -295,11 +304,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -327,11 +337,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -359,11 +370,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -391,17 +403,18 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fetch_from": "patient.patient_name",
"fetch_from": "patient.patient_name",
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
@ -425,16 +438,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "patient.sex",
"fetch_from": "patient.sex",
"fieldname": "patient_sex",
"fieldtype": "Data",
"hidden": 0,
@ -458,11 +472,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -490,11 +505,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -523,11 +539,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -555,11 +572,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -586,11 +604,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -617,11 +636,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -647,11 +667,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -679,11 +700,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -711,11 +733,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -742,11 +765,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -773,16 +797,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "referring_physician",
"fieldname": "referring_practitioner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 1,
@ -791,10 +816,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Referring Physician",
"label": "Referring Practitioner",
"length": 0,
"no_copy": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -805,11 +830,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 1,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -837,7 +863,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
}
],
@ -851,7 +877,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-16 22:43:39.359254",
"modified": "2018-07-16 12:48:28.394133",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient Appointment",
@ -920,7 +946,7 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "patient, physician, department, appointment_date, appointment_time",
"search_fields": "patient, practitioner, department, appointment_date, appointment_time",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",

View File

@ -28,7 +28,7 @@ class PatientAppointment(Document):
frappe.db.set_value("Procedure Prescription", self.procedure_prescription, "appointment_booked", True)
# Check fee validity exists
appointment = self
validity_exist = validity_exists(appointment.physician, appointment.patient)
validity_exist = validity_exists(appointment.practitioner, appointment.patient)
if validity_exist:
fee_validity = frappe.get_doc("Fee Validity", validity_exist[0][0])
@ -64,11 +64,11 @@ def appointment_cancel(appointment_id):
@frappe.whitelist()
def get_availability_data(date, physician):
def get_availability_data(date, practitioner):
"""
Get availability data of 'physician' on 'date'
Get availability data of 'practitioner' on 'date'
:param date: Date to check in schedule
:param physician: Name of the physician
:param practitioner: Name of the practitioner
:return: dict containing a list of available slots, list of appointments and time of appointments
"""
@ -77,21 +77,21 @@ def get_availability_data(date, physician):
available_slots = []
slot_details = []
physician_schedule = None
practitioner_schedule = None
employee = None
physician_obj = frappe.get_doc("Physician", physician)
practitioner_obj = frappe.get_doc("Healthcare Practitioner", practitioner)
# Get Physician employee relation
if physician_obj.employee:
employee = physician_obj.employee
elif physician_obj.user_id:
# Get practitioner employee relation
if practitioner_obj.employee:
employee = practitioner_obj.employee
elif practitioner_obj.user_id:
if frappe.db.exists({
"doctype": "Employee",
"user_id": physician_obj.user_id
"user_id": practitioner_obj.user_id
}):
employee = frappe.get_doc("Employee", {"user_id": physician_obj.user_id}).name
employee = frappe.get_doc("Employee", {"user_id": practitioner_obj.user_id}).name
if employee:
# Check if it is Holiday
@ -104,21 +104,21 @@ def get_availability_data(date, physician):
and docstatus = 1""", (employee, date), as_dict=True)
if leave_record:
if leave_record[0].half_day:
frappe.throw(_("Dr {0} on Half day Leave on {1}").format(physician, date))
frappe.throw(_("{0} on Half day Leave on {1}").format(practitioner, date))
else:
frappe.throw(_("Dr {0} on Leave on {1}").format(physician, date))
frappe.throw(_("{0} on Leave on {1}").format(practitioner, date))
# get physicians schedule
if physician_obj.physician_schedules:
for schedule in physician_obj.physician_schedules:
# get practitioners schedule
if practitioner_obj.practitioner_schedules:
for schedule in practitioner_obj.practitioner_schedules:
if schedule.schedule:
physician_schedule = frappe.get_doc("Physician Schedule", schedule.schedule)
practitioner_schedule = frappe.get_doc("Practitioner Schedule", schedule.schedule)
else:
frappe.throw(_("Dr {0} does not have a Physician Schedule. Add it in Physician master".format(physician)))
frappe.throw(_("{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner master".format(practitioner)))
if physician_schedule:
if practitioner_schedule:
available_slots = []
for t in physician_schedule.time_slots:
for t in practitioner_schedule.time_slots:
if weekday == t.day:
available_slots.append(t)
@ -129,10 +129,10 @@ def get_availability_data(date, physician):
slot_name = schedule.schedule+" - "+schedule.service_unit
allow_overlap = frappe.get_value('Healthcare Service Unit', schedule.service_unit, 'overlap_appointments')
if allow_overlap:
# fetch all appointments to physician by service unit
# fetch all appointments to practitioner by service unit
appointments = frappe.get_all(
"Patient Appointment",
filters={"physician": physician, "service_unit": schedule.service_unit, "appointment_date": date, "status": ["not in",["Cancelled"]]},
filters={"practitioner": practitioner, "service_unit": schedule.service_unit, "appointment_date": date, "status": ["not in",["Cancelled"]]},
fields=["name", "appointment_time", "duration", "status"])
else:
# fetch all appointments to service unit
@ -142,21 +142,21 @@ def get_availability_data(date, physician):
fields=["name", "appointment_time", "duration", "status"])
else:
slot_name = schedule.schedule
# fetch all appointments to physician without service unit
# fetch all appointments to practitioner without service unit
appointments = frappe.get_all(
"Patient Appointment",
filters={"physician": physician, "service_unit": '', "appointment_date": date, "status": ["not in",["Cancelled"]]},
filters={"practitioner": practitioner, "service_unit": '', "appointment_date": date, "status": ["not in",["Cancelled"]]},
fields=["name", "appointment_time", "duration", "status"])
slot_details.append({"slot_name":slot_name, "service_unit":schedule.service_unit,
"avail_slot":available_slots, 'appointments': appointments})
else:
frappe.throw(_("Dr {0} does not have a Physician Schedule. Add it in Physician master".format(physician)))
frappe.throw(_("{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner master".format(practitioner)))
if not available_slots and not slot_details:
# TODO: return available slots in nearby dates
frappe.throw(_("Physician not available on {0}").format(weekday))
frappe.throw(_("Healthcare Practitioner not available on {0}").format(weekday))
return {
"slot_details": slot_details
@ -210,37 +210,37 @@ def invoice_appointment(appointment_doc):
sales_invoice.company = appointment_doc.company
sales_invoice.debit_to = get_receivable_account(appointment_doc.company)
fee_validity = get_fee_validity(appointment_doc.physician, appointment_doc.patient, appointment_doc.appointment_date)
fee_validity = get_fee_validity(appointment_doc.practitioner, appointment_doc.patient, appointment_doc.appointment_date)
procedure_template = False
if appointment_doc.procedure_template:
procedure_template = appointment_doc.procedure_template
create_invoice_items(appointment_doc.physician, appointment_doc.company, sales_invoice, procedure_template)
create_invoice_items(appointment_doc.practitioner, appointment_doc.company, sales_invoice, procedure_template)
sales_invoice.save(ignore_permissions=True)
frappe.db.sql("""update `tabPatient Appointment` set sales_invoice=%s where name=%s""", (sales_invoice.name, appointment_doc.name))
frappe.db.set_value("Fee Validity", fee_validity.name, "ref_invoice", sales_invoice.name)
consultation = frappe.db.exists({
"doctype": "Consultation",
encounter = frappe.db.exists({
"doctype": "Patient Encounter",
"appointment": appointment_doc.name})
if consultation:
frappe.db.set_value("Consultation", consultation[0][0], "invoice", sales_invoice.name)
if encounter:
frappe.db.set_value("Patient Encounter", encounter[0][0], "invoice", sales_invoice.name)
return sales_invoice.name
def get_fee_validity(physician, patient, date):
validity_exist = validity_exists(physician, patient)
def get_fee_validity(practitioner, patient, date):
validity_exist = validity_exists(practitioner, patient)
if validity_exist:
fee_validity = frappe.get_doc("Fee Validity", validity_exist[0][0])
fee_validity = update_fee_validity(fee_validity, date)
else:
fee_validity = create_fee_validity(physician, patient, date)
fee_validity = create_fee_validity(practitioner, patient, date)
return fee_validity
def validity_exists(physician, patient):
def validity_exists(practitioner, patient):
return frappe.db.exists({
"doctype": "Fee Validity",
"physician": physician,
"practitioner": practitioner,
"patient": patient})
@ -260,15 +260,15 @@ def update_fee_validity(fee_validity, date):
return fee_validity
def create_fee_validity(physician, patient, date):
def create_fee_validity(practitioner, patient, date):
fee_validity = frappe.new_doc("Fee Validity")
fee_validity.physician = physician
fee_validity.practitioner = practitioner
fee_validity.patient = patient
fee_validity = update_fee_validity(fee_validity, date)
return fee_validity
def create_invoice_items(physician, company, invoice, procedure_template):
def create_invoice_items(practitioner, company, invoice, procedure_template):
item_line = invoice.append("items")
if procedure_template:
procedure_template_obj = frappe.get_doc("Clinical Procedure Template", procedure_template)
@ -277,11 +277,11 @@ def create_invoice_items(physician, company, invoice, procedure_template):
item_line.description = procedure_template_obj.description
else:
item_line.item_name = "Consulting Charges"
item_line.description = "Consulting Charges: " + physician
item_line.description = "Consulting Charges: " + practitioner
item_line.uom = "Nos"
item_line.conversion_factor = 1
item_line.income_account = get_income_account(physician, company)
op_consulting_charge = frappe.db.get_value("Physician", physician, "op_consulting_charge")
item_line.income_account = get_income_account(practitioner, company)
op_consulting_charge = frappe.db.get_value("Healthcare Practitioner", practitioner, "op_consulting_charge")
if op_consulting_charge:
item_line.rate = op_consulting_charge
item_line.amount = op_consulting_charge
@ -292,18 +292,18 @@ def create_invoice_items(physician, company, invoice, procedure_template):
@frappe.whitelist()
def create_consultation(appointment):
def create_encounter(appointment):
appointment = frappe.get_doc("Patient Appointment", appointment)
consultation = frappe.new_doc("Consultation")
consultation.appointment = appointment.name
consultation.patient = appointment.patient
consultation.physician = appointment.physician
consultation.visit_department = appointment.department
consultation.patient_sex = appointment.patient_sex
consultation.consultation_date = appointment.appointment_date
encounter = frappe.new_doc("Patient Encounter")
encounter.appointment = appointment.name
encounter.patient = appointment.patient
encounter.practitioner = appointment.practitioner
encounter.visit_department = appointment.department
encounter.patient_sex = appointment.patient_sex
encounter.encounter_date = appointment.appointment_date
if appointment.sales_invoice:
consultation.invoice = appointment.sales_invoice
return consultation.as_dict()
encounter.invoice = appointment.sales_invoice
return encounter.as_dict()
def remind_appointment():
@ -347,7 +347,7 @@ def get_events(start, end, filters=None):
"""
from frappe.desk.calendar import get_event_conditions
conditions = get_event_conditions("Patient Appointment", filters)
data = frappe.db.sql("""select `tabPatient Appointment`.name, patient, physician, status,
data = frappe.db.sql("""select `tabPatient Appointment`.name, patient, practitioner, status,
duration, timestamp(appointment_date, appointment_time) as 'start', type.color as 'color'
from `tabPatient Appointment`
left join `tabAppointment Type` as type on `tabPatient Appointment`.appointment_type=type.name
@ -360,8 +360,8 @@ def get_events(start, end, filters=None):
return data
@frappe.whitelist()
def get_procedure_prescribed(patient):
return frappe.db.sql("""select pp.name, pp.procedure, pp.parent, ct.physician,
ct.consultation_date, pp.physician, pp.date, pp.department
from tabConsultation ct, `tabProcedure Prescription` pp
return frappe.db.sql("""select pp.name, pp.procedure, pp.parent, ct.practitioner,
ct.encounter_date, pp.practitioner, pp.date, pp.department
from `tabPatient Encounter` ct, `tabProcedure Prescription` pp
where ct.patient='{0}' and pp.parent=ct.name and pp.appointment_booked=0
order by ct.creation desc""".format(patient))

View File

@ -14,9 +14,9 @@ frappe.views.calendar["Patient Appointment"] = {
filters: [
{
'fieldtype': 'Link',
'fieldname': 'physician',
'options': 'Physician',
'label': __('Physician')
'fieldname': 'practitioner',
'options': 'Healthcare Practitioner',
'label': __('Healthcare Practitioner')
},
{
'fieldtype': 'Link',
@ -43,4 +43,4 @@ frappe.views.calendar["Patient Appointment"] = {
'label': __('Status')
}
]
};
};

View File

@ -9,7 +9,7 @@ def get_data():
'transactions': [
{
'label': _('Consultations'),
'items': ['Consultation', 'Vital Signs', 'Patient Medical Record']
'items': ['Patient Encounter', 'Vital Signs', 'Patient Medical Record']
},
{
'label': _('Billing'),

View File

@ -1,7 +1,7 @@
// Copyright (c) 2016, ESS LLP and contributors
// For license information, please see license.txt
frappe.ui.form.on('Consultation', {
frappe.ui.form.on('Patient Encounter', {
setup: function(frm) {
frm.get_field('drug_prescription').grid.editable_fields = [
{fieldname: 'drug_code', columns: 2},
@ -75,7 +75,7 @@ frappe.ui.form.on('Consultation', {
});
if(!frm.doc.__islocal && !frm.doc.invoice && (frappe.user.has_role("Accounts User"))){
frm.add_custom_button(__('Invoice'), function() {
btn_invoice_consultation(frm);
btn_invoice_encounter(frm);
},__("Create"));
}
frm.set_df_property("appointment", "read_only", frm.doc.__islocal ? 0:1);
@ -83,19 +83,19 @@ frappe.ui.form.on('Consultation', {
frm.set_df_property("patient_age", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("patient_sex", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("type", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("physician", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("practitioner", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("visit_department", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("consultation_date", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("consultation_time", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("encounter_date", "read_only", frm.doc.__islocal ? 0:1);
frm.set_df_property("encounter_time", "read_only", frm.doc.__islocal ? 0:1);
}
});
var btn_invoice_consultation = function(frm){
var btn_invoice_encounter = function(frm){
var doc = frm.doc;
frappe.call({
method:
"erpnext.healthcare.doctype.consultation.consultation.create_invoice",
args: {company: doc.company, patient: doc.patient, physician: doc.physician, consultation_id: doc.name },
"erpnext.healthcare.doctype.encounter.encounter.create_invoice",
args: {company: doc.company, patient: doc.patient, practitioner: doc.practitioner, encounter_id: doc.name },
callback: function(data){
if(!data.exc){
if(data.message){
@ -142,7 +142,7 @@ var btn_create_procedure = function (frm) {
frappe.new_doc("Clinical Procedure");
};
frappe.ui.form.on("Consultation", "appointment", function(frm){
frappe.ui.form.on("Patient Encounter", "appointment", function(frm){
if(frm.doc.appointment){
frappe.call({
"method": "frappe.client.get",
@ -153,20 +153,20 @@ frappe.ui.form.on("Consultation", "appointment", function(frm){
callback: function (data) {
frappe.model.set_value(frm.doctype,frm.docname, "patient", data.message.patient);
frappe.model.set_value(frm.doctype,frm.docname, "type", data.message.appointment_type);
frappe.model.set_value(frm.doctype,frm.docname, "physician", data.message.physician);
frappe.model.set_value(frm.doctype,frm.docname, "practitioner", data.message.practitioner);
frappe.model.set_value(frm.doctype,frm.docname, "invoice", data.message.sales_invoice);
}
});
}
});
frappe.ui.form.on("Consultation", "physician", function(frm) {
if(frm.doc.physician){
frappe.ui.form.on("Patient Encounter", "practitioner", function(frm) {
if(frm.doc.practitioner){
frappe.call({
"method": "frappe.client.get",
args: {
doctype: "Physician",
name: frm.doc.physician
doctype: "Healthcare Practitioner",
name: frm.doc.practitioner
},
callback: function (data) {
frappe.model.set_value(frm.doctype,frm.docname, "visit_department",data.message.department);
@ -175,7 +175,7 @@ frappe.ui.form.on("Consultation", "physician", function(frm) {
}
});
frappe.ui.form.on("Consultation", "symptoms_select", function(frm) {
frappe.ui.form.on("Patient Encounter", "symptoms_select", function(frm) {
if(frm.doc.symptoms_select){
var symptoms = null;
if(frm.doc.symptoms)
@ -186,7 +186,7 @@ frappe.ui.form.on("Consultation", "symptoms_select", function(frm) {
frappe.model.set_value(frm.doctype,frm.docname, "symptoms_select", null);
}
});
frappe.ui.form.on("Consultation", "diagnosis_select", function(frm) {
frappe.ui.form.on("Patient Encounter", "diagnosis_select", function(frm) {
if(frm.doc.diagnosis_select){
var diagnosis = null;
if(frm.doc.diagnosis)
@ -198,7 +198,7 @@ frappe.ui.form.on("Consultation", "diagnosis_select", function(frm) {
}
});
frappe.ui.form.on("Consultation", "patient", function(frm) {
frappe.ui.form.on("Patient Encounter", "patient", function(frm) {
if(frm.doc.patient){
frappe.call({
"method": "erpnext.healthcare.doctype.patient.patient.get_patient_detail",

View File

@ -15,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -40,10 +41,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -71,10 +74,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -103,10 +108,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -134,10 +141,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -165,10 +174,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -196,10 +207,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -227,15 +240,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@ -244,10 +259,10 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Doctor",
"label": "Healthcare Practitioner",
"length": 0,
"no_copy": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -258,10 +273,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -289,10 +306,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -318,10 +337,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -349,16 +370,18 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Today",
"fieldname": "consultation_date",
"fieldname": "encounter_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
@ -367,7 +390,7 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Consultation Date",
"label": "Encounter Date",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -380,16 +403,18 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "",
"fieldname": "consultation_time",
"fieldname": "encounter_time",
"fieldtype": "Time",
"hidden": 0,
"ignore_user_permissions": 0,
@ -398,7 +423,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Consultation Time",
"label": "Encounter Time",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@ -411,10 +436,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -442,10 +469,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -472,10 +501,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -503,10 +534,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -533,10 +566,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -564,10 +599,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -594,10 +631,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -626,10 +665,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -657,10 +698,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -689,10 +732,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 1,
@ -719,10 +764,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -750,10 +797,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -780,10 +829,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -811,10 +862,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -841,10 +894,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -872,10 +927,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -902,10 +959,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -933,15 +992,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "consultation_comment",
"fieldname": "encounter_comment",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
@ -963,10 +1024,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -983,7 +1046,7 @@
"label": "Amended From",
"length": 0,
"no_copy": 1,
"options": "Consultation",
"options": "Patient Encounter",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
@ -993,6 +1056,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -1006,16 +1070,15 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-03-19 11:35:13.826577",
"modified": "2018-07-16 12:51:13.487000",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Consultation",
"name": "Patient Encounter",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 1,
"apply_user_permissions": 0,
"cancel": 1,
"create": 1,
"delete": 1,
@ -1038,7 +1101,7 @@
"read_only": 0,
"read_only_onload": 0,
"restrict_to_domain": "Healthcare",
"search_fields": "patient, physician, visit_department, consultation_date, consultation_time",
"search_fields": "patient, practitioner, visit_department, encounter_date, encounter_time",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",

View File

@ -9,14 +9,14 @@ from frappe.utils import getdate, cstr
import json
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account
class Consultation(Document):
class PatientEncounter(Document):
def on_update(self):
if(self.appointment):
frappe.db.set_value("Patient Appointment", self.appointment, "status", "Closed")
update_consultation_to_medical_record(self)
update_encounter_to_medical_record(self)
def after_insert(self):
insert_consultation_to_medical_record(self)
insert_encounter_to_medical_record(self)
def on_cancel(self):
if(self.appointment):
@ -62,8 +62,8 @@ def create_drug_invoice(company, patient, prescriptions):
return sales_invoice.as_dict()
@frappe.whitelist()
def create_invoice(company, patient, physician, consultation_id):
if not consultation_id:
def create_invoice(company, patient, practitioner, encounter_id):
if not encounter_id:
return False
sales_invoice = frappe.new_doc("Sales Invoice")
sales_invoice.customer = frappe.get_value("Patient", patient, "customer")
@ -71,61 +71,61 @@ def create_invoice(company, patient, physician, consultation_id):
sales_invoice.is_pos = '0'
sales_invoice.debit_to = get_receivable_account(company)
create_invoice_items(physician, sales_invoice, company)
create_invoice_items(practitioner, sales_invoice, company)
sales_invoice.save(ignore_permissions=True)
frappe.db.sql("""update tabConsultation set invoice=%s where name=%s""", (sales_invoice.name, consultation_id))
appointment = frappe.db.get_value("Consultation", consultation_id, "appointment")
frappe.db.sql("""update `tabPatient Encounter` set invoice=%s where name=%s""", (sales_invoice.name, encounter_id))
appointment = frappe.db.get_value("Patient Encounter", encounter_id, "appointment")
if appointment:
frappe.db.set_value("Patient Appointment", appointment, "sales_invoice", sales_invoice.name)
return sales_invoice.name
def create_invoice_items(physician, invoice, company):
def create_invoice_items(practitioner, invoice, company):
item_line = invoice.append("items")
item_line.item_name = "Consulting Charges"
item_line.description = "Consulting Charges: " + physician
item_line.description = "Consulting Charges: " + practitioner
item_line.qty = 1
item_line.uom = "Nos"
item_line.conversion_factor = 1
item_line.income_account = get_income_account(physician, company)
op_consulting_charge = frappe.get_value("Physician", physician, "op_consulting_charge")
item_line.income_account = get_income_account(practitioner, company)
op_consulting_charge = frappe.get_value("Healthcare Practitioner", practitioner, "op_consulting_charge")
if op_consulting_charge:
item_line.rate = op_consulting_charge
item_line.amount = op_consulting_charge
return invoice
def insert_consultation_to_medical_record(doc):
def insert_encounter_to_medical_record(doc):
subject = set_subject_field(doc)
medical_record = frappe.new_doc("Patient Medical Record")
medical_record.patient = doc.patient
medical_record.subject = subject
medical_record.status = "Open"
medical_record.communication_date = doc.consultation_date
medical_record.reference_doctype = "Consultation"
medical_record.communication_date = doc.encounter_date
medical_record.reference_doctype = "Patient Encounter"
medical_record.reference_name = doc.name
medical_record.reference_owner = doc.owner
medical_record.save(ignore_permissions=True)
def update_consultation_to_medical_record(consultation):
medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s", (consultation.name))
def update_encounter_to_medical_record(encounter):
medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s", (encounter.name))
if medical_record_id and medical_record_id[0][0]:
subject = set_subject_field(consultation)
subject = set_subject_field(encounter)
frappe.db.set_value("Patient Medical Record", medical_record_id[0][0], "subject", subject)
else:
insert_consultation_to_medical_record(consultation)
insert_encounter_to_medical_record(encounter)
def delete_medical_record(consultation):
frappe.db.sql("""delete from `tabPatient Medical Record` where reference_name = %s""", (consultation.name))
def delete_medical_record(encounter):
frappe.db.sql("""delete from `tabPatient Medical Record` where reference_name = %s""", (encounter.name))
def set_subject_field(consultation):
def set_subject_field(encounter):
subject = "No Diagnosis "
if(consultation.diagnosis):
subject = "Diagnosis: \n"+ cstr(consultation.diagnosis)+". "
if(consultation.drug_prescription):
if(encounter.diagnosis):
subject = "Diagnosis: \n"+ cstr(encounter.diagnosis)+". "
if(encounter.drug_prescription):
subject +="\nDrug(s) Prescribed. "
if(consultation.test_prescription):
if(encounter.test_prescription):
subject += "\nTest(s) Prescribed."
if(consultation.procedure_prescription):
if(encounter.procedure_prescription):
subject += "\nProcedure(s) Prescribed."
return subject

View File

@ -2,7 +2,7 @@ from frappe import _
def get_data():
return {
'fieldname': 'consultation',
'fieldname': 'encounter',
'non_standard_fieldnames': {
'Patient Medical Record': 'reference_name'
},

View File

@ -1,7 +1,6 @@
/*
(c) ESS 2015-16
*/
frappe.listview_settings['Consultation'] = {
frappe.listview_settings['Patient Encounter'] = {
filters:[["docstatus","!=","1"]]
};

View File

@ -2,15 +2,15 @@
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Consultation", function (assert) {
QUnit.test("test: Patient Encounter", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Consultation
() => frappe.tests.make('Consultation', [
// insert a new Patient Encounter
() => frappe.tests.make('Patient Encounter', [
// values to be set
{key: 'value'}
]),

View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest
class TestPatientEncounter(unittest.TestCase):
pass

View File

@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, ESS LLP and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest
import frappe
test_dependencies = ['Physician Schedule']
class TestPhysician(unittest.TestCase):
def tearDown(self):
frappe.delete_doc_if_exists('Physician', '_Testdoctor2', force=1)
def test_new_physician_without_schedule(self):
physician = frappe.new_doc('Physician')
physician.first_name = '_Testdoctor2'
physician.insert()
self.assertEqual(frappe.get_value('Physician', '_Testdoctor2', 'first_name'), '_Testdoctor2')

View File

@ -1,8 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest
class TestPhysicianSchedule(unittest.TestCase):
pass

View File

@ -1,8 +0,0 @@
[
{
"schedule_name": "_Testdoctor1 Schedule"
},
{
"schedule_name": "_Testdoctor2 Schedule"
}
]

View File

@ -1,7 +1,7 @@
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Physician Schedule', {
frappe.ui.form.on('Practitioner Schedule', {
refresh: function(frm) {
cur_frm.fields_dict["time_slots"].grid.wrapper.find('.grid-add-row').hide();
cur_frm.fields_dict["time_slots"].grid.add_custom_button(__('Add Time Slots'), () => {

View File

@ -15,6 +15,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -41,10 +42,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -61,7 +64,7 @@
"label": "Time Slots",
"length": 0,
"no_copy": 0,
"options": "Physician Schedule Time Slot",
"options": "Healthcare Schedule Time Slot",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -72,10 +75,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -102,6 +107,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -115,16 +121,15 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-10-05 11:21:54.488194",
"modified": "2018-06-29 14:55:34.795995",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Physician Schedule",
"name": "Practitioner Schedule",
"name_case": "",
"owner": "rmehta@gmail.com",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,

View File

@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from frappe.model.document import Document
class PhysicianSchedule(Document):
class PractitionerSchedule(Document):
def autoname(self):
self.name = self.schedule_name

View File

@ -2,15 +2,15 @@
// rename this file from _test_[name] to test_[name] to activate
// and remove above this line
QUnit.test("test: Physician Schedule", function (assert) {
QUnit.test("test: Practitioner Schedule", function (assert) {
let done = assert.async();
// number of asserts
assert.expect(1);
frappe.run_serially([
// insert a new Physician Schedule
() => frappe.tests.make('Physician Schedule', [
// insert a new Practitioner Schedule
() => frappe.tests.make('Practitioner Schedule', [
// values to be set
{key: 'value'}
]),

View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest
class TestPractitionerSchedule(unittest.TestCase):
pass

View File

@ -14,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -30,7 +31,7 @@
"label": "Schedule",
"length": 0,
"no_copy": 0,
"options": "Physician Schedule",
"options": "Practitioner Schedule",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -46,6 +47,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -87,10 +89,10 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-05-02 03:38:09.935153",
"modified": "2018-06-29 15:14:18.647514",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Physician Service Unit Schedule",
"name": "Practitioner Service Unit Schedule",
"name_case": "",
"owner": "Administrator",
"permissions": [],

View File

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from frappe.model.document import Document
class PhysicianServiceUnitSchedule(Document):
class PractitionerServiceUnitSchedule(Document):
pass

View File

@ -14,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -41,16 +42,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "procedure.template",
"fetch_from": "procedure.template",
"fieldname": "procedure_name",
"fieldtype": "Data",
"hidden": 0,
@ -74,11 +76,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -106,16 +109,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@ -124,10 +128,10 @@
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Physician",
"label": "Referral",
"length": 0,
"no_copy": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -138,11 +142,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -169,11 +174,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -200,11 +206,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -231,7 +238,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
}
],
@ -245,7 +252,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-05-16 22:43:37.924984",
"modified": "2018-07-16 13:08:15.499491",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Procedure Prescription",

View File

@ -14,6 +14,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -41,16 +42,17 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fetch_from": "patient.patient_name",
"fetch_from": "patient.patient_name",
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
@ -74,11 +76,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -106,16 +109,17 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "consultation",
"fieldname": "encounter",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
@ -124,10 +128,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Consultation",
"label": "Patient Encounter",
"length": 0,
"no_copy": 1,
"options": "Consultation",
"options": "Patient Encounter",
"permlevel": 0,
"precision": "",
"print_hide": 1,
@ -138,11 +142,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -168,11 +173,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -200,11 +206,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -230,11 +237,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -262,11 +270,12 @@
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -293,11 +302,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -325,11 +335,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -357,11 +368,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -389,11 +401,78 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "tongue",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Tongue",
"length": 0,
"no_copy": 0,
"options": "\nCoated\nVery Coated\nNormal\nFurry\nCuts",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "abdomen",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Abdomen",
"length": 0,
"no_copy": 0,
"options": "\nBloated\nFull\nFluid\nConstipated",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -419,11 +498,45 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "reflexes",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Reflexes",
"length": 0,
"no_copy": 0,
"options": "\nNormal\nHyper\nVery Hyper\nOne Sided",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -450,11 +563,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -482,11 +596,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -514,11 +629,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -545,11 +661,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -576,11 +693,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -607,11 +725,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -638,11 +757,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -670,11 +790,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -700,11 +821,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -731,11 +853,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -763,11 +886,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -794,7 +918,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"translatable": 0,
"unique": 0
}
],
@ -808,7 +932,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-05-16 22:42:54.580491",
"modified": "2018-07-16 14:04:09.604470",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Vital Signs",

View File

@ -14,7 +14,7 @@ erpnext.AppointmentAnalytics = frappe.views.TreeGridReport.extend({
title: __("Appointment Analytics"),
parent: $(wrapper).find('.layout-main'),
page: wrapper.page,
doctypes: ["Patient Appointment", "Physician", "Medical Department", "Appointment Type", "Patient"],
doctypes: ["Patient Appointment", "Healthcare Practitioner", "Medical Department", "Appointment Type", "Patient"],
tree_grid: { show: true }
});
@ -22,16 +22,16 @@ erpnext.AppointmentAnalytics = frappe.views.TreeGridReport.extend({
"Medical Department": {
label: __("Department"),
show: true,
item_key: "physician",
item_key: "practitioner",
parent_field: "department",
formatter: function(item) {
return item.name;
}
},
"Physician": {
label: __("Physician"),
"Healthcare Practitioner": {
label: __("Healthcare Practitioner"),
show: true,
item_key: "physician",
item_key: "practitioner",
formatter: function(item) {
return item.name;
}
@ -52,7 +52,7 @@ erpnext.AppointmentAnalytics = frappe.views.TreeGridReport.extend({
},
filters: [
{fieldtype:"Select", label: __("Tree Type"), fieldname: "tree_type",
options:["Physician", "Medical Department"], filter: function(val, item, opts, me) {
options:["Healthcare Practitioner", "Medical Department"], filter: function(val, item, opts, me) {
return me.apply_zero_filter(val, item, opts, me);}},
{fieldtype:"Select", label: __("Status"), fieldname: "status",
options:[
@ -64,10 +64,10 @@ erpnext.AppointmentAnalytics = frappe.views.TreeGridReport.extend({
{label: __("Cancelled"), value: "Cancelled"}]},
{fieldtype:"Select", label: __("Type"), link:"Appointment Type", fieldname: "type",
default_value: __("Select Type...")},
{fieldtype:"Select", label: __("Physician"), link:"Physician", fieldname: "physician",
default_value: __("Select Physician..."), filter: function(val, item, opts) {
{fieldtype:"Select", label: __("Healthcare Practitioner"), link:"Healthcare Practitioner", fieldname: "practitioner",
default_value: __("Select Healthcare Practitioner..."), filter: function(val, item, opts) {
return val == opts.default_value || item.name == val || item._show;
}, link_formatter: {filter_input: "physician"}},
}, link_formatter: {filter_input: "practitioner"}},
{fieldtype:"Select", label: __("Department"), link:"Medical Department", fieldname: "department",
default_value: __("Select Department..."), filter: function(val, item, opts) {
return val == opts.default_value || item.department == val || item._show;
@ -81,7 +81,7 @@ erpnext.AppointmentAnalytics = frappe.views.TreeGridReport.extend({
],
setup_filters: function() {
this._super();
this.trigger_refresh_on_change(["tree_type", "physician", "department", "status", "type"]);
this.trigger_refresh_on_change(["tree_type", "practitioner", "department", "status", "type"]);
// this.show_zero_check()
},
@ -96,10 +96,10 @@ erpnext.AppointmentAnalytics = frappe.views.TreeGridReport.extend({
}
if(!this.data || me.item_type != me.tree_type) {
var items = null;
if(me.tree_type=='Physician') {
items = frappe.report_dump.data["Physician"];
if(me.tree_type=='Healthcare Practitioner') {
items = frappe.report_dump.data["Healthcare Practitioner"];
} if(me.tree_type=='Medical Department') {
items = this.prepare_tree("Physician", "Medical Department");
items = this.prepare_tree("Healthcare Practitioner", "Medical Department");
}
me.item_type = me.tree_type;
me.parent_map = {};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,7 @@ def execute(filters=None):
data = []
for lab_test in lab_test_list:
row = [ lab_test.test_name, lab_test.patient, lab_test.physician, lab_test.invoice, lab_test.status, lab_test.result_date, lab_test.department]
row = [ lab_test.test_name, lab_test.patient, lab_test.practitioner, lab_test.invoice, lab_test.status, lab_test.result_date, lab_test.department]
data.append(row)
return columns, data
@ -27,7 +27,7 @@ def get_columns():
columns = [
_("Test") + ":Data:120",
_("Patient") + ":Link/Patient:180",
_("Doctor") + ":Link/Physician:120",
_("Healthcare Practitioner") + ":Link/Healthcare Practitioner:120",
_("Invoice") + ":Link/Sales Invoice:120",
_("Status") + ":Data:120",
_("Result Date") + ":Date:120",
@ -52,7 +52,7 @@ def get_conditions(filters):
def get_lab_test(filters):
conditions = get_conditions(filters)
return frappe.db.sql("""select name, patient, test_name, patient_name, status, result_date, physician, invoice, department
return frappe.db.sql("""select name, patient, test_name, patient_name, status, result_date, practitioner, invoice, department
from `tabLab Test`
where docstatus<2 %s order by submitted_date desc, name desc""" %
conditions, filters, as_dict=1)

View File

@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2017-06-07 16:03:06.781364",
"modified": "2018-07-16 13:10:47.940128",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "lab-test",
@ -77,13 +77,13 @@
"reqd": 0
},
{
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"label": "Doctor",
"label": "Healthcare Practitioner",
"max_length": 0,
"max_value": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"read_only": 0,
"reqd": 0
},

View File

@ -18,7 +18,7 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2017-06-07 15:57:27.196428",
"modified": "2018-07-16 13:11:08.626316",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "patient-appointments",
@ -43,13 +43,13 @@
"reqd": 1
},
{
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"label": "Physician",
"label": "Healthcare Practitioner",
"max_length": 0,
"max_value": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"read_only": 0,
"reqd": 1
},

View File

@ -0,0 +1,3 @@
frappe.ready(function() {
// bind events here
});

View File

@ -0,0 +1,87 @@
{
"accept_payment": 0,
"allow_comments": 0,
"allow_delete": 0,
"allow_edit": 1,
"allow_incomplete": 0,
"allow_multiple": 0,
"allow_print": 0,
"amount": 0.0,
"amount_based_on_field": 0,
"creation": "2018-07-03 19:33:23.332661",
"currency": "INR",
"doc_type": "Patient",
"docstatus": 0,
"doctype": "Web Form",
"idx": 0,
"introduction_text": "",
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2018-07-04 17:22:28.936442",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "personal-details",
"owner": "Administrator",
"payment_button_label": "Buy Now",
"published": 1,
"route": "personal-details",
"show_sidebar": 1,
"sidebar_items": [],
"success_url": "/personal-details",
"title": "Personal Details",
"web_form_fields": [
{
"fieldname": "patient_name",
"fieldtype": "Data",
"hidden": 0,
"label": "Full Name",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "sex",
"fieldtype": "Select",
"hidden": 0,
"label": "Gender",
"max_length": 0,
"max_value": 0,
"options": "\nMale\nFemale\nOther",
"read_only": 0,
"reqd": 1
},
{
"fieldname": "dob",
"fieldtype": "Date",
"hidden": 0,
"label": "Date of birth",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1
},
{
"fieldname": "mobile",
"fieldtype": "Data",
"hidden": 0,
"label": "Mobile",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0
},
{
"fieldname": "email",
"fieldtype": "Data",
"hidden": 0,
"label": "Email",
"max_length": 0,
"max_value": 0,
"options": "Email",
"read_only": 1,
"reqd": 0
}
]
}

View File

@ -0,0 +1,28 @@
from __future__ import unicode_literals
import frappe
from frappe import _
no_cache = 1
no_sitemap = 1
def get_context(context):
if frappe.session.user=='Guest':
frappe.throw(_("You need to be logged in to access this page"), frappe.PermissionError)
context.show_sidebar=True
if frappe.db.exists("Patient", {'email': frappe.session.user}):
patient = frappe.get_doc("Patient", {'email': frappe.session.user})
context.doc = patient
frappe.form_dict.new = 0
frappe.form_dict.name = patient.name
def get_patient():
return frappe.get_value("Patient",{"email": frappe.session.user}, "name")
def has_website_permission(doc, ptype, user, verbose=False):
if doc.name == get_patient():
return True
else:
return False

View File

@ -10,7 +10,7 @@
"amount_based_on_field": 0,
"creation": "2017-06-06 17:13:19.101374",
"currency": "INR",
"doc_type": "Consultation",
"doc_type": "Patient Encounter",
"docstatus": 0,
"doctype": "Web Form",
"idx": 0,
@ -18,13 +18,13 @@
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2017-06-20 11:56:05.132154",
"modified": "2018-07-16 13:11:28.057697",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "prescription",
"owner": "Administrator",
"payment_button_label": "Buy Now",
"print_format": "Consultation Print",
"print_format": "Encounter Print",
"published": 1,
"route": "prescription",
"show_sidebar": 1,
@ -33,13 +33,13 @@
"title": "Prescription",
"web_form_fields": [
{
"fieldname": "physician",
"fieldname": "practitioner",
"fieldtype": "Link",
"hidden": 0,
"label": "Doctor",
"label": "Healthcare Practitioner",
"max_length": 0,
"max_value": 0,
"options": "Physician",
"options": "Healthcare Practitioner",
"read_only": 0,
"reqd": 1
},
@ -56,10 +56,10 @@
},
{
"default": "Today",
"fieldname": "consultation_date",
"fieldname": "encounter_date",
"fieldtype": "Date",
"hidden": 0,
"label": "Consultation Date",
"label": "Encounter Date",
"max_length": 0,
"max_value": 0,
"read_only": 0,
@ -67,10 +67,10 @@
},
{
"default": "",
"fieldname": "consultation_time",
"fieldname": "encounter_time",
"fieldtype": "Data",
"hidden": 0,
"label": "Consultation Time",
"label": "Encounter Time",
"max_length": 0,
"max_value": 0,
"read_only": 0,
@ -99,7 +99,7 @@
"reqd": 0
},
{
"fieldname": "consultation_comment",
"fieldname": "encounter_comment",
"fieldtype": "Small Text",
"hidden": 0,
"label": "Review Details",

View File

@ -7,13 +7,13 @@ def get_context(context):
def get_list_context(context):
context.row_template = "erpnext/templates/includes/healthcare/prescription_row_template.html"
context.get_list = get_consultation_list
context.get_list = get_encounter_list
def get_consultation_list(doctype, txt, filters, limit_start, limit_page_length = 20, order_by='modified desc'):
def get_encounter_list(doctype, txt, filters, limit_start, limit_page_length = 20, order_by='modified desc'):
patient = get_patient()
consultations = frappe.db.sql("""select * from `tabConsultation`
encounters = frappe.db.sql("""select * from `tabPatient Encounter`
where patient = %s order by creation desc""", patient, as_dict = True)
return consultations
return encounters
def get_patient():
return frappe.get_value("Patient",{"email": frappe.session.user}, "name")

View File

@ -133,6 +133,7 @@ website_route_rules = [
]
standard_portal_menu_items = [
{"title": _("Personal Details"), "route": "/personal-details", "reference_doctype": "Patient", "role": "Patient"},
{"title": _("Projects"), "route": "/project", "reference_doctype": "Project"},
{"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation", "role": "Supplier"},
{"title": _("Supplier Quotation"), "route": "/supplier-quotations", "reference_doctype": "Supplier Quotation", "role": "Supplier"},
@ -145,7 +146,7 @@ standard_portal_menu_items = [
{"title": _("Timesheets"), "route": "/timesheets", "reference_doctype": "Timesheet", "role":"Customer"},
{"title": _("Timesheets"), "route": "/timesheets", "reference_doctype": "Timesheet", "role":"Customer"},
{"title": _("Lab Test"), "route": "/lab-test", "reference_doctype": "Lab Test", "role":"Patient"},
{"title": _("Prescription"), "route": "/prescription", "reference_doctype": "Consultation", "role":"Patient"},
{"title": _("Prescription"), "route": "/prescription", "reference_doctype": "Patient Encounter", "role":"Patient"},
{"title": _("Patient Appointment"), "route": "/patient-appointments", "reference_doctype": "Patient Appointment", "role":"Patient"},
{"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"},
{"title": _("Newsletter"), "route": "/newsletters", "reference_doctype": "Newsletter"},
@ -168,8 +169,9 @@ has_website_permission = {
"Issue": "erpnext.support.doctype.issue.issue.has_website_permission",
"Timesheet": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Lab Test": "erpnext.healthcare.web_form.lab_test.lab_test.has_website_permission",
"Consultation": "erpnext.healthcare.web_form.prescription.prescription.has_website_permission",
"Patient Appointment": "erpnext.healthcare.web_form.patient_appointments.patient_appointments.has_website_permission"
"Patient Encounter": "erpnext.healthcare.web_form.prescription.prescription.has_website_permission",
"Patient Appointment": "erpnext.healthcare.web_form.patient_appointments.patient_appointments.has_website_permission",
"Patient": "erpnext.healthcare.web_form.personal_details.personal_details.has_website_permission"
}
dump_report_map = "erpnext.startup.report_data_map.data_map"

View File

@ -555,4 +555,5 @@ execute:frappe.db.sql("update `tabDesktop Icon` set type = 'module' where module
erpnext.patches.v11_0.set_salary_component_properties
erpnext.patches.v11_0.set_user_permissions_for_department
erpnext.patches.v11_0.hr_ux_cleanups
erpnext.patches.v11_0.update_allow_transfer_for_manufacture
erpnext.patches.v11_0.update_allow_transfer_for_manufacture
erpnext.patches.v11_0.rename_healthcare_doctype_and_fields

View File

@ -0,0 +1,56 @@
import frappe
from frappe.model.rename_doc import rename_doc
from frappe.model.utils.rename_field import rename_field
from frappe.modules import scrub, get_doctype_module
field_rename_map = {
"Patient Encounter": [
["consultation_time", "encounter_time"],
["consultation_date", "encounter_date"],
["consultation_comment", "encounter_comment"],
["physician", "practitioner"]
],
"Fee Validity": [
["physician", "practitioner"]
],
"Lab Test": [
["physician", "practitioner"]
],
"Patient Appointment": [
["physician", "practitioner"],
["referring_physician", "referring_practitioner"]
],
"Procedure Prescription": [
["physician", "practitioner"]
]
}
doc_rename_map = {
"Physician Schedule Time Slot": "Healthcare Schedule Time Slot",
"Physician Schedule": "Practitioner Schedule",
"Physician Service Unit Schedule": "Practitioner Service Unit Schedule",
"Consultation": "Patient Encounter",
"Physician": "Healthcare Practitioner"
}
def execute():
for dt in doc_rename_map:
if frappe.db.exists('DocType', dt):
rename_doc('DocType', dt, doc_rename_map[dt], force=True)
for dn in field_rename_map:
if frappe.db.exists('DocType', dn):
frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn))
for dt, field_list in field_rename_map.items():
if frappe.db.exists('DocType', dt):
for field in field_list:
if frappe.db.has_column(dt, field[0]):
rename_field(dt, field[0], field[1])
if frappe.db.exists('DocType', 'Practitioner Service Unit Schedule'):
if frappe.db.has_column('Practitioner Service Unit Schedule', 'parentfield'):
frappe.db.sql("""
update `tabPractitioner Service Unit Schedule` set parentfield = 'practitioner_schedules'
where parentfield = 'physician_schedules' and parenttype = 'Healthcare Practitioner'
""")

View File

@ -60,7 +60,7 @@ def get_notification_config():
"Lab Test": {"docstatus": 0},
"Sample Collection": {"docstatus": 0},
"Patient Appointment": {"status": "Open"},
"Consultation": {"docstatus": 0}
"Patient Encounter": {"docstatus": 0}
},
"targets": {

View File

@ -298,14 +298,14 @@ data_map = {
}
},
"Patient Appointment": {
"columns": ["name", "appointment_type", "patient", "physician", "appointment_date", "department", "status", "company"],
"columns": ["name", "appointment_type", "patient", "practitioner", "appointment_date", "department", "status", "company"],
"order_by": "name",
"links": {
"physician": ["Physician", "name"],
"practitioner": ["Healthcare Practitioner", "name"],
"appointment_type": ["Appointment Type", "name"]
}
},
"Physician": {
"Healthcare Practitioner": {
"columns": ["name", "department"],
"order_by": "name",
"links": {

View File

@ -7,7 +7,7 @@
</span>
</div>
<div class="col-xs-3">
{{ doc.physician }}
{{ doc.practitioner }}
</div>
<div class="col-xs-2">
{% if doc.department %}{{ doc.department }}{% endif %}

View File

@ -10,7 +10,7 @@
{{ doc.test_name }}
</div>
<div class="col-xs-3">
{{ doc.physician }}
{{ doc.practitioner }}
</div>
<div class="col-xs-3 text-right small text-muted">
{{ frappe.format_date(doc.result_date) }}

View File

@ -5,10 +5,10 @@
{{ doc.name }}
</div>
<div class="col-xs-4">
{{ doc.physician }}
{{ doc.practitioner }}
</div>
<div class="col-xs-4 text-right small text-muted">
{{ frappe.format_date(doc.consultation_date) }}
{{ frappe.format_date(doc.encounter_date) }}
</div>
</div>
</a>