diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index ea944678087..804b05b9b52 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -1042,276 +1042,3 @@ var select_loyalty_program = function(frm, loyalty_programs) {
dialog.show();
}
-
-// Healthcare
-var get_healthcare_services_to_invoice = function(frm) {
- var me = this;
- let selected_patient = '';
- var dialog = new frappe.ui.Dialog({
- title: __("Get Items from Healthcare Services"),
- fields:[
- {
- fieldtype: 'Link',
- options: 'Patient',
- label: 'Patient',
- fieldname: "patient",
- reqd: true
- },
- { fieldtype: 'Section Break' },
- { fieldtype: 'HTML', fieldname: 'results_area' }
- ]
- });
- var $wrapper;
- var $results;
- var $placeholder;
- dialog.set_values({
- 'patient': frm.doc.patient
- });
- dialog.fields_dict["patient"].df.onchange = () => {
- var patient = dialog.fields_dict.patient.input.value;
- if(patient && patient!=selected_patient){
- selected_patient = patient;
- var method = "healthcare.healthcare.utils.get_healthcare_services_to_invoice";
- var args = {patient: patient, company: frm.doc.company};
- var columns = (["service", "reference_name", "reference_type"]);
- get_healthcare_items(frm, true, $results, $placeholder, method, args, columns);
- }
- else if(!patient){
- selected_patient = '';
- $results.empty();
- $results.append($placeholder);
- }
- }
- $wrapper = dialog.fields_dict.results_area.$wrapper.append(`
`);
- $results = $wrapper.find('.results');
- $placeholder = $(`
-
-
-
-
-
`);
- $results.on('click', '.list-item--head :checkbox', (e) => {
- $results.find('.list-item-container .list-row-check')
- .prop("checked", ($(e.target).is(':checked')));
- });
- set_primary_action(frm, dialog, $results, true);
- dialog.show();
-};
-
-var get_healthcare_items = function(frm, invoice_healthcare_services, $results, $placeholder, method, args, columns) {
- var me = this;
- $results.empty();
- frappe.call({
- method: method,
- args: args,
- callback: function(data) {
- if(data.message){
- $results.append(make_list_row(columns, invoice_healthcare_services));
- for(let i=0; i
- ${
- head ? `${__(frappe.model.unscrub(column))}`
-
- :(column !== "name" ? `${__(result[column])}`
- : `
- ${__(result[column])}`)
- }
- `;
- })
-
- let $row = $(``);
-
- $row = list_row_data_items(head, $row, result, invoice_healthcare_services);
- return $row;
-};
-
-var set_primary_action= function(frm, dialog, $results, invoice_healthcare_services) {
- var me = this;
- dialog.set_primary_action(__('Add'), function() {
- let checked_values = get_checked_values($results);
- if(checked_values.length > 0){
- if(invoice_healthcare_services) {
- frm.set_value("patient", dialog.fields_dict.patient.input.value);
- }
- frm.set_value("items", []);
- add_to_item_line(frm, checked_values, invoice_healthcare_services);
- dialog.hide();
- }
- else{
- if(invoice_healthcare_services){
- frappe.msgprint(__("Please select Healthcare Service"));
- }
- else{
- frappe.msgprint(__("Please select Drug"));
- }
- }
- });
-};
-
-var get_checked_values= function($results) {
- return $results.find('.list-item-container').map(function() {
- let checked_values = {};
- if ($(this).find('.list-row-check:checkbox:checked').length > 0 ) {
- checked_values['dn'] = $(this).attr('data-dn');
- checked_values['dt'] = $(this).attr('data-dt');
- checked_values['item'] = $(this).attr('data-item');
- if($(this).attr('data-rate') != 'undefined'){
- checked_values['rate'] = $(this).attr('data-rate');
- }
- else{
- checked_values['rate'] = false;
- }
- if($(this).attr('data-income-account') != 'undefined'){
- checked_values['income_account'] = $(this).attr('data-income-account');
- }
- else{
- checked_values['income_account'] = false;
- }
- if($(this).attr('data-qty') != 'undefined'){
- checked_values['qty'] = $(this).attr('data-qty');
- }
- else{
- checked_values['qty'] = false;
- }
- if($(this).attr('data-description') != 'undefined'){
- checked_values['description'] = $(this).attr('data-description');
- }
- else{
- checked_values['description'] = false;
- }
- return checked_values;
- }
- }).get();
-};
-
-var get_drugs_to_invoice = function(frm) {
- var me = this;
- let selected_encounter = '';
- var dialog = new frappe.ui.Dialog({
- title: __("Get Items from Prescriptions"),
- fields:[
- { fieldtype: 'Link', options: 'Patient', label: 'Patient', fieldname: "patient", reqd: true },
- { fieldtype: 'Link', options: 'Patient Encounter', label: 'Patient Encounter', fieldname: "encounter", reqd: true,
- description:'Quantity will be calculated only for items which has "Nos" as UoM. You may change as required for each invoice item.',
- get_query: function(doc) {
- return {
- filters: {
- patient: dialog.get_value("patient"),
- company: frm.doc.company,
- docstatus: 1
- }
- };
- }
- },
- { fieldtype: 'Section Break' },
- { fieldtype: 'HTML', fieldname: 'results_area' }
- ]
- });
- var $wrapper;
- var $results;
- var $placeholder;
- dialog.set_values({
- 'patient': frm.doc.patient,
- 'encounter': ""
- });
- dialog.fields_dict["encounter"].df.onchange = () => {
- var encounter = dialog.fields_dict.encounter.input.value;
- if(encounter && encounter!=selected_encounter){
- selected_encounter = encounter;
- var method = "healthcare.healthcare.utils.get_drugs_to_invoice";
- var args = {encounter: encounter};
- var columns = (["drug_code", "quantity", "description"]);
- get_healthcare_items(frm, false, $results, $placeholder, method, args, columns);
- }
- else if(!encounter){
- selected_encounter = '';
- $results.empty();
- $results.append($placeholder);
- }
- }
- $wrapper = dialog.fields_dict.results_area.$wrapper.append(``);
- $results = $wrapper.find('.results');
- $placeholder = $(`
-
-
-
-
-
`);
- $results.on('click', '.list-item--head :checkbox', (e) => {
- $results.find('.list-item-container .list-row-check')
- .prop("checked", ($(e.target).is(':checked')));
- });
- set_primary_action(frm, dialog, $results, false);
- dialog.show();
-};
-
-var list_row_data_items = function(head, $row, result, invoice_healthcare_services) {
- if(invoice_healthcare_services){
- head ? $row.addClass('list-item--head')
- : $row = $(`
-
`).append($row);
- }
- else{
- head ? $row.addClass('list-item--head')
- : $row = $(`
-
`).append($row);
- }
- return $row
-};
-
-var add_to_item_line = function(frm, checked_values, invoice_healthcare_services){
- if(invoice_healthcare_services){
- frappe.call({
- doc: frm.doc,
- method: "set_healthcare_services",
- args:{
- checked_values: checked_values
- },
- callback: function() {
- frm.trigger("validate");
- frm.refresh_fields();
- }
- });
- }
- else{
- for(let i=0; i 1){
- frappe.model.set_value(si_item.doctype, si_item.name, 'qty', parseFloat(checked_values[i]['qty']));
- }
- }
- frm.refresh_fields();
- }
-};