test: Patient Medical Record
This commit is contained in:
parent
aabcee4f8f
commit
60e558a019
File diff suppressed because it is too large
Load Diff
@ -105,7 +105,7 @@
|
||||
"description": "If unchecked, the item wont be appear in Sales Invoice, but can be used in group test creation. ",
|
||||
"fieldname": "is_billable",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is billable",
|
||||
"label": "Is Billable",
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
@ -114,7 +114,8 @@
|
||||
"fieldname": "lab_test_rate",
|
||||
"fieldtype": "Currency",
|
||||
"in_list_view": 1,
|
||||
"label": "Standard Selling Rate"
|
||||
"label": "Rate",
|
||||
"mandatory_depends_on": "eval:doc.is_billable == 1"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.lab_test_template_type == 'Single'",
|
||||
@ -239,8 +240,8 @@
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-01-21 21:02:16.108347",
|
||||
"modified_by": "ruchamahabal2@gmail.com",
|
||||
"modified": "2020-03-23 19:43:11.606254",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Healthcare",
|
||||
"name": "Lab Test Template",
|
||||
"owner": "Administrator",
|
||||
|
@ -3,8 +3,86 @@
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
|
||||
# test_records = frappe.get_test_records('Patient Medical Record')
|
||||
import frappe
|
||||
from frappe.utils import nowdate
|
||||
from erpnext.healthcare.doctype.patient_appointment.test_patient_appointment import create_encounter, create_healthcare_docs, create_appointment
|
||||
|
||||
class TestPatientMedicalRecord(unittest.TestCase):
|
||||
pass
|
||||
def setUp(self):
|
||||
frappe.db.set_value('Healthcare Settings', None, 'enable_free_follow_ups', 0)
|
||||
frappe.db.set_value('Healthcare Settings', None, 'automate_appointment_invoicing', 1)
|
||||
|
||||
def test_medical_record(self):
|
||||
patient, medical_department, practitioner = create_healthcare_docs()
|
||||
appointment = create_appointment(patient, practitioner, nowdate(), invoice=1)
|
||||
encounter = create_encounter(appointment)
|
||||
# check for encounter
|
||||
medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': encounter.name})
|
||||
self.assertTrue(medical_rec)
|
||||
|
||||
vital_signs = create_vital_signs(appointment)
|
||||
# check for vital signs
|
||||
medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': vital_signs.name})
|
||||
self.assertTrue(medical_rec)
|
||||
|
||||
appointment = create_appointment(patient, practitioner, nowdate(), invoice=1, procedure_template=1)
|
||||
procedure = create_procedure(appointment)
|
||||
procedure.start_procedure()
|
||||
procedure.complete_procedure()
|
||||
# check for clinical procedure
|
||||
medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': procedure.name})
|
||||
self.assertTrue(medical_rec)
|
||||
|
||||
template = create_lab_test_template(medical_department)
|
||||
lab_test = create_lab_test(template, patient)
|
||||
# check for lab test
|
||||
medical_rec = frappe.db.exists('Patient Medical Record', {'status': 'Open', 'reference_name': lab_test.name})
|
||||
self.assertTrue(medical_rec)
|
||||
|
||||
|
||||
def create_procedure(appointment):
|
||||
if appointment:
|
||||
procedure = frappe.new_doc('Clinical Procedure')
|
||||
procedure.procedure_template = appointment.procedure_template
|
||||
procedure.appointment = appointment.name
|
||||
procedure.patient = appointment.patient
|
||||
procedure.practitioner = appointment.practitioner
|
||||
procedure.medical_department = appointment.department
|
||||
procedure.start_dt = appointment.appointment_date
|
||||
procedure.start_time = appointment.appointment_time
|
||||
procedure.save()
|
||||
procedure.submit()
|
||||
return procedure
|
||||
|
||||
def create_vital_signs(appointment):
|
||||
vital_signs = frappe.new_doc('Vital Signs')
|
||||
vital_signs.patient = appointment.patient
|
||||
vital_signs.signs_date = appointment.appointment_date
|
||||
vital_signs.signs_time = appointment.appointment_time
|
||||
vital_signs.temperature = 38.5
|
||||
vital_signs.save()
|
||||
vital_signs.submit()
|
||||
return vital_signs
|
||||
|
||||
def create_lab_test_template(medical_department):
|
||||
if frappe.db.exists('Lab Test Template', 'Blood Test'):
|
||||
return 'Blood Test'
|
||||
|
||||
template = frappe.new_doc('Lab Test Template')
|
||||
template.lab_test_name = 'Blood Test'
|
||||
template.lab_test_code = 'Blood Test'
|
||||
template.lab_test_group = 'Services'
|
||||
template.department = medical_department
|
||||
template.is_billable = 1
|
||||
template.lab_test_rate = 2000
|
||||
template.save()
|
||||
return template.name
|
||||
|
||||
def create_lab_test(template, patient):
|
||||
lab_test = frappe.new_doc('Lab Test')
|
||||
lab_test.patient = patient
|
||||
lab_test.patient_sex = frappe.db.get_value('Patient', patient, 'sex')
|
||||
lab_test.template = template
|
||||
lab_test.save()
|
||||
lab_test.submit()
|
||||
return lab_test
|
@ -333,7 +333,6 @@ def check_fee_validity(appointment):
|
||||
validity = frappe.db.exists('Fee Validity', {
|
||||
'practitioner': appointment.practitioner,
|
||||
'patient': appointment.patient,
|
||||
'status': 'Pending',
|
||||
'valid_till': ('>=', appointment.appointment_date)
|
||||
})
|
||||
if not validity:
|
||||
|
Loading…
x
Reference in New Issue
Block a user