[domain] Healthcare (#10664)
* Medical module for erpnext
* Changes in core for Medical module
* patient registration updated
* fix - appointment invioce - fields missing
* pages- indicator instead of bg-color
* Lab Test field renamed service type
* Department added Lab Test
* procedure name in prescription
* fixes sample collection
* filter disabled patient
* fix patient admission
* updated patient age
* availability check msg updated
* fixes, removed procedure from invoice
* sample print renamed
* fixes, validation
* service desk physician in filter
* refactor scheduler
* Appointment -field property - set only once = 1
* Appointment - Mark closed and pending buttons removed
* Appointment - readonly = 1 if value set
* Appointment - availabilty
* Appointment - Cancel - info - cancel invoice
* Appointment - set pending appointments
* Dosage form - new DT
* Drug Prescription - Dosage form added
* Facility - Floor - removed from Fecility
* Floor - removed
* Lab Test Template - item creation validation
* Procedure - Create Procedure
* Procedure Appointment - new DT
* Service Unit - Floor reference removed
* Zone Fcilities - Unused DT removed
* Appointment Desk - fixed
* Service Desk - method pointing from procedure changed to procedure_appointment
* Consultation print - got featured
* Consultation - removed patient refernce to procedure prescription
* Procedure Prescription - removed patient refernce
* Lab Test - Changed field properties and value
* Lab Test - field property changed
* Lab Test - methods rewrite - lab test doc creation
* Lab Test - create lab test from invoice and consultaion - got changed
* Button History changed to Medical Record
* Service Desk - Updated
* Notification - Procedure Appointment
* fix-get procedure prescription
* fix field added to test prescription
* msgprint on invoice creation
* fix data on install
* Merge branch erpnext/develop
* fixes- minor
* Setup wizard - Create Sensitivity
* Appointment - Validate and Save if there is no schedule for Physician
* Consultation - Button create vital signs and medical record
* Review Type - New DocType
* Review Detail and Treatment Plan - Childs - Consultation
* Patient Medical Record - field Attach doc
* Consultation - New Fields
* Consultation - Manage new Fields - Medical record add action
* Patient Relation - Child DocType - Patient
* Patient - Patient Relation added
* Patient - collapsible = 1
* Laboratory Settings - fields - message for lab test
* Laboratory Settings - get message for lab test
* SMS text for lab test and invoice test report
* Procedure Stock Detail - Stock detail for Procedure and Template
* Template Stage Detail - Stage detail for Procedure Template
* Procedure Stage Detail - Stage detail for Procedure
* Service Unit - field - warehouse
* Scheduler - msg - content changed
* Laboratory Settings - defualt - msg content
* Invoice Test Report - msg print
* Print Format-Changed-Consultation-Invoice Test Report-Lab Test
* OP Settings - Expnse Account for Stock Entry in Procedure
* Procedure and Procedure Template - Manage Stock Stage and Sample Collection
* Procedure Appointment - Manage Stock and Stage
* Lab Test - fixed - resource not find
* Invoice Test Report - fixed - resource not find
* Procedure - doc reload after insert
* Patient Medical Record - fixed - refernce missed
* Create Vital Signs -on client side
* Rename module Medical to Healthcare
* Remove In Patient (IP) Feature.
* Rename - Procedure to Clinical Procedure
* Remove spaces in Naming Series
* Rename Duration to Drug Prescription Duration
* Duration to Drug Prescription Duration
* Merge All Settings to Healthcare Settings
* Healthcare settings - import fixed
* Procedure related documents are removed
* Appointment Desk and Sevrvice Desk are removed
* Consultation - minimal
* Consultation - minimal
* Consultation - minimal - patient detials in collapsible section
* Message Print to Alerts
* Patient - some fields removed
* Patient - create consultation - message print to alerts
* Consultation - show patient details updated
* Setup wizard - Duration to Drug Prescritpion Duration
* Healthcare Settings - patient registration - fee collection
* Lab Test - Create Sales Invoice bug fixed
* Healthcare menu rearranged
* Healthcare Settings - Optimised and Rearragnged
* Healthcare Settings - Expense account removed
* Receivable account removed from patient
* Patient - Optimised and Rearragnged
* Removed Referring Physician
* Healthcare Settings - bold headings removed
* Physician - Patient - Fields are Segregated
* Remove Service Unit
* Remove - Service Type
* Consultation invoice
* Lab Test - invoice
* Patient - Invoice
* Rename Appointment to Patient Appointment
* wip
* Patient Dashboard, Physician Form cleanup
* Dosage renamed to Prescription Dosage
* Renamed Drug Prescription Duration to Prescription Duration
* Patient Appointment booking modal
* Patient Age - calculate by dob
* Remove - scheduler
* Consultation - Appointment to Patient Appointment
* Patient Dashboard - rearranged
* Patient Appointment
* Removed rer_physician from lab test and consultation
* Patient Appontment Changes
* Appointment and Consultation - optimized
* Patient Appointment - fee validity code optimized
* Consultation and Patient Appointment - Invoice validate two side
* fix: #13 remove relation to admission
* Healthcare - Patient Portal
* fix import error
* domain Healthcare added on install
* Removed - Invoice Test Report
* Physician Schedule - menu
* Consultation - patient details - re write
* New Doctype-Medical Code
* Consultation - Daignosis codification
* Medical Code - Codification - Settings
* Medical Code Standard - Medical Code - Codification - Settings
* fix appointment calendar
* fix appointment analytics
* Menu Medical Code Standard
* New Doctype - Medical Code Standard
* Set Physician Role insted of IP Physician and OP Physician Role
* fixed some json files
* Medical code - permission to physician
* Unused Childs - Work Schedule and User List - Removed
* Label Procedure to Lab Test
* Lab Test and Patient - code optimised
* Add Item Groups - setup wizard
* Healthcare Settings - add Role - Medical Administrator
* Healthcare - Demo setup - Make Demo
* Fee Validity - Logic Test
* Test Fee Validity - Optimised
* Healthcare Doctypes - Restricted to Domain Healthcare
* Domainify - remove Healthcare Roles - Other Domains
* Healthcare doctypes - beta checked
* Codacy fixes
* Codacy - fixes
* Codacy - fixes
* Codacy - fixes
* Codacy - fixes
* Codacy - fixes
* Lab Test - print hide =1 for some fields
* Consultation - Codification field label to Medical Coding
* Codacy fixes - import frappe and etc.
* Codacy fixes - import frappe in test_vital_signs
* Codacy fixes
* Codacy fixes
* Codacy fixes and remove delete perm for patient
* send_sms - import form frappe
* Healthcare Settings
* Lab Prescription - Consultation - Test Code - read_only = 0
* Portal fixes
* Patient Appointment - filter physician - if has schedule
* Physician - IP Charge - Removed
* test - files
* Web Form - Patient Profile - removed
* Role Medical Administrator to Healthcare Administrator
* WIP healthcare documentation
* Coday - fixes
* Travis - fixes
* Lab Test Report - menu
* Reorder Healthcare settings - group lab config to bottom
* Sample Collection - New - allow Sample and patient Selection
* Rate - similar behaviour and Label as in Item Standard Selling Rate
* Healthcare documentation
* Lab Test Samples to Lab Test sample
* Commplaints to Complaint
* Commplaints to Complaint
* Antibiotics to Antibiotic
* Appointment Token Number - remove
* View - Medical record
* Codacy fixes
* update healthcare docs
* Cleanup Docs - Search, quick entry, trsck change, etc.
* [minor] ux changes
diff --git a/erpnext/demo/setup/healthcare.py b/erpnext/demo/setup/healthcare.py
new file mode 100644
index 0000000..d645e30
--- /dev/null
+++ b/erpnext/demo/setup/healthcare.py
@@ -0,0 +1,166 @@
+# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe, json
+from frappe.utils.make_random import get_random
+import datetime
+from erpnext.demo.setup.setup_data import import_json
+from frappe.utils import getdate
+from erpnext.healthcare.doctype.lab_test.lab_test import create_test_from_template
+
+def setup_data():
+ frappe.flags.mute_emails = True
+ make_masters()
+ make_patient()
+ make_lab_test()
+ make_consulation()
+ make_appointment()
+ consulation_on_appointment()
+ lab_test_on_consultation()
+ frappe.db.commit()
+ frappe.clear_cache()
+
+def make_masters():
+ import_json("Physician")
+ import_drug()
+ frappe.db.commit()
+
+def make_patient():
+ file_path = get_json_path("Patient")
+ with open(file_path, "r") as open_file:
+ patient_data = json.loads(open_file.read())
+ count = 1
+
+ for d in enumerate(patient_data):
+ patient = frappe.new_doc("Patient")
+ patient.patient_name = d[1]['patient_name'].title()
+ patient.sex = d[1]['gender']
+ patient.blood_group = "A Positive"
+ patient.date_of_birth = datetime.datetime(1990, 3, 25)
+ patient.email_id = d[1]['patient_name'] + "_" + patient.date_of_birth.strftime('%m/%d/%Y') + "@example.com"
+ if count <5:
+ patient.insert()
+ frappe.db.commit()
+ count+=1
+
+def make_appointment():
+ i = 1
+ while i <= 4:
+ physician = get_random("Physician")
+ department = frappe.get_value("Physician", physician, "department")
+ patient = get_random("Patient")
+ patient_sex = frappe.get_value("Patient", patient, "sex")
+ appointment = frappe.new_doc("Patient Appointment")
+ startDate = datetime.datetime.now()
+ for x in random_date(startDate,0):
+ appointment_datetime = x
+ appointment.appointment_datetime = appointment_datetime
+ appointment.appointment_time = appointment_datetime
+ appointment.appointment_date = appointment_datetime
+ appointment.patient = patient
+ appointment.patient_sex = patient_sex
+ appointment.physician = physician
+ appointment.department = department
+ appointment.save(ignore_permissions = True)
+ i += 1
+
+def make_consulation():
+ for i in xrange(3):
+ physician = get_random("Physician")
+ department = frappe.get_value("Physician", physician, "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)
+
+def consulation_on_appointment():
+ for i in xrange(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)
+
+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
+ 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,
+ 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
+
+def make_lab_test():
+ physician = get_random("Physician")
+ 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)
+
+def lab_test_on_consultation():
+ 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)
+ i += 1
+
+def set_lab_test(patient, patient_sex, physician, template, rx=None):
+ lab_test = frappe.new_doc("Lab Test")
+ lab_test.physician = physician
+ 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):
+ i = 1
+ while i <= 2:
+ test_rx = consultation.append("test_prescription")
+ test_rx.test_code = get_random("Lab Test Template")
+ i += 1
+ return consultation
+
+def append_drug_rx(consultation):
+ 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.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
+
+def random_date(start,l):
+ current = start
+ while l >= 0:
+ curr = current + datetime.timedelta(minutes=60)
+ yield curr
+ l-=1
+
+def import_drug():
+ frappe.flags.in_import = True
+ data = json.loads(open(frappe.get_app_path('erpnext', 'demo', 'data', 'drug_list.json')).read())
+ for d in data:
+ doc = frappe.new_doc("Item")
+ doc.update(d)
+ doc.insert()
+ frappe.flags.in_import = False
+
+def get_json_path(doctype):
+ return frappe.get_app_path('erpnext', 'demo', 'data', frappe.scrub(doctype) + '.json')
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index cec425c..c4df777 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -184,7 +184,8 @@
user.add_roles('HR User', 'HR Manager', 'Accounts User', 'Accounts Manager',
'Stock User', 'Stock Manager', 'Sales User', 'Sales Manager', 'Purchase User',
'Purchase Manager', 'Projects User', 'Manufacturing User', 'Manufacturing Manager',
- 'Support Team', 'Academics User')
+ 'Support Team', 'Academics User', 'Physician', 'Healthcare Administrator', 'Laboratory User',
+ 'Nursing User', 'Patient')
if not frappe.db.get_global('demo_hr_user'):
user = frappe.get_doc('User', 'CharmaineGaudreau@example.com')
@@ -387,5 +388,3 @@
frappe.db.commit()
frappe.flags.in_import = False
-
-