<commit_before>import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from erpnext.domains.healthcare import data
from frappe.modules import scrub, get_doctype_module

sales_invoice_referenced_doc = {
	"Patient Appointment": "sales_invoice",
	"Patient Encounter": "invoice",
	"Lab Test": "invoice",
	"Lab Prescription": "invoice",
	"Sample Collection": "invoice"
}

def execute():
	healthcare_custom_field_in_sales_invoice()
	for si_ref_doc in sales_invoice_referenced_doc:
		if frappe.db.exists('DocType', si_ref_doc):
			frappe.reload_doc(get_doctype_module(si_ref_doc), 'doctype', scrub(si_ref_doc))

			if frappe.db.has_column(si_ref_doc, sales_invoice_referenced_doc[si_ref_doc]) \
			and frappe.db.has_column(si_ref_doc, 'invoiced'):
				# Set Reference DocType and Reference Docname
				doc_list = frappe.db.sql("""
							select name from `tab{0}`
							where {1} is not null
						""".format(si_ref_doc, sales_invoice_referenced_doc[si_ref_doc]))<commit_msg>Patch - redesign healthcare billing work flow - fix<commit_after>import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from erpnext.domains.healthcare import data
from frappe.modules import scrub, get_doctype_module

sales_invoice_referenced_doc = {
	"Patient Appointment": "sales_invoice",
	"Patient Encounter": "invoice",
	"Lab Test": "invoice",
	"Lab Prescription": "invoice",
	"Sample Collection": "invoice"
}

def execute():
	healthcare_custom_field_in_sales_invoice()
	frappe.reload_doc('accounts', 'doctype', 'sales_invoice_item')
	for si_ref_doc in sales_invoice_referenced_doc:
		if frappe.db.exists('DocType', si_ref_doc):
			frappe.reload_doc(get_doctype_module(si_ref_doc), 'doctype', scrub(si_ref_doc))

			if frappe.db.has_column(si_ref_doc, sales_invoice_referenced_doc[si_ref_doc]) \
			and frappe.db.has_column(si_ref_doc, 'invoiced'):
				# Set Reference DocType and Reference Docname
				doc_list = frappe.db.sql("""
							select name from `tab{0}`
							where {1} is not null
						""".format(si_ref_doc, sales_invoice_referenced_doc[si_ref_doc]))
{'fraction_non_alphanumeric': 0.10812086874409821, 'fraction_numerical': 0.0018885741265344666, 'mean_word_length': 6.110738255033557, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '373302', 'n_tokens_mistral': 833, 'n_tokens_neox': 761, 'n_words': 146}