297 lines
9.5 KiB
JavaScript
297 lines
9.5 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/order.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
search : '',
|
|
search_status: 0,
|
|
search_error_message: "",
|
|
|
|
total_order: 0,
|
|
selected_order: {},
|
|
|
|
order: {
|
|
order_id: 0,
|
|
order_number: "",
|
|
patient_id: 0,
|
|
patient_age: "",
|
|
diagnose_id: 0,
|
|
gcs_id: 0,
|
|
sistole: 0,
|
|
diastole: 0,
|
|
respiratory: 0,
|
|
temperature: 0,
|
|
pulse: 0,
|
|
weight: 0,
|
|
height: 0,
|
|
complaint: "",
|
|
suggestion: ""
|
|
},
|
|
|
|
// Dialogs
|
|
finish_dialog_is_active: false,
|
|
confirm_process_dialog_is_active: false,
|
|
lab_dialog_is_active: false,
|
|
med_dialog_is_active: false,
|
|
print_dialog_is_active: false,
|
|
|
|
queue_number: '-',
|
|
processed: false,
|
|
last_order_id: 0,
|
|
|
|
rpt_url: window.BASE_URL + '/one-ui/test/vuex/common/under-cons.pdf'
|
|
},
|
|
mutations: {
|
|
update_search(state,val) {
|
|
state.search=val
|
|
},
|
|
update_search_error_message(state,status) {
|
|
state.search_error_message = status
|
|
},
|
|
update_search_status(state,status) {
|
|
state.search_status = status
|
|
},
|
|
update_order(state,data) {
|
|
state.order = data
|
|
// state.total_order = data.total
|
|
},
|
|
|
|
update_order_d(state, data) {
|
|
let x = state.order
|
|
data.val = data.val.replace(/\<(br)\>/g, '\n')
|
|
x[data.type] = data.val
|
|
state.order = x
|
|
// state.total_order = data.total
|
|
},
|
|
|
|
update_selected_order(state,doc) {
|
|
state.selected_order = doc
|
|
},
|
|
|
|
update_finish_dialog_is_active(state, v) {
|
|
state.finish_dialog_is_active = v
|
|
},
|
|
|
|
update_confirm_process_dialog_is_active(state, v) {
|
|
state.confirm_process_dialog_is_active = v
|
|
},
|
|
|
|
update_lab_dialog_is_active(state, v) {
|
|
state.lab_dialog_is_active = v
|
|
},
|
|
|
|
update_med_dialog_is_active(state, v) {
|
|
state.med_dialog_is_active = v
|
|
},
|
|
|
|
update_print_dialog_is_active(state, v) {
|
|
state.print_dialog_is_active = v
|
|
},
|
|
|
|
update_queue_number(state, v) {
|
|
state.queue_number = v
|
|
},
|
|
|
|
update_processed(state, v) {
|
|
state.processed = v
|
|
},
|
|
|
|
update_last_order_id(state, v) {
|
|
state.last_order_id = v
|
|
},
|
|
|
|
update_rpt_url(state, v) {
|
|
state.rpt_url = v
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context) {
|
|
context.commit("update_search_status",1)
|
|
try {
|
|
let resp= await api.search(context.state.search)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",resp.message)
|
|
} else {
|
|
context.commit("update_search_status",2)
|
|
context.commit("update_search_error_message","")
|
|
let data = {
|
|
total : resp.data.total,
|
|
records : resp.data.records
|
|
}
|
|
context.commit("update_order", data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message", e.message )
|
|
}
|
|
},
|
|
|
|
async save(context) {
|
|
var order_id = context.rootState.patient.selected_patient.C_OrderHeaderID;
|
|
var med = [];
|
|
var lab = [];
|
|
|
|
var header = {
|
|
patient_id: context.rootState.patient.selected_patient.M_PatientID,
|
|
patient_age: context.rootState.patient.selected_patient.patient_age,
|
|
diagnose_id: context.rootState.diagnose.selected_diagnose.M_DiagnoseID,
|
|
gcs_id: context.rootState.gcs.selected_gcs.M_GcsID,
|
|
sistole: context.rootState.order.order.sistole,
|
|
diastole: context.rootState.order.order.diastole,
|
|
respiratory: context.rootState.order.order.respiratory,
|
|
temperature: context.rootState.order.order.temperature,
|
|
pulse: context.rootState.order.order.pulse,
|
|
weight: context.rootState.order.order.weight,
|
|
height: context.rootState.order.order.height,
|
|
complaint: context.rootState.order.order.complaint,
|
|
suggestion: context.rootState.order.order.suggestion
|
|
};
|
|
|
|
let meds = context.rootState.receipt.receipts
|
|
// let med = []
|
|
for (let j in meds ) {
|
|
if (meds[j].med_name != '')
|
|
med.push(meds[j])
|
|
}
|
|
|
|
var px_tmp = [];
|
|
var st = context.rootState.px.selected_test;
|
|
for (let i in st) {
|
|
px_tmp.push({
|
|
test_id: st[i]['T_TestID'],
|
|
test_cito: st[i]['T_TestIsCito'],
|
|
test_type: st[i]['px_type']
|
|
})
|
|
}
|
|
|
|
lab = px_tmp;
|
|
|
|
// context.commit("update_search_status",1)
|
|
try {
|
|
let resp= await api.save(order_id, header, med, lab, one_token())
|
|
|
|
if (resp.status != "200") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert('error')
|
|
} else {
|
|
console.log(resp)
|
|
context.commit('update_queue_number', resp.data.data.queue)
|
|
context.commit('update_finish_dialog_is_active', true)
|
|
|
|
context.commit('update_last_order_id', order_id)
|
|
context.dispatch('resetForm')
|
|
// context.commit("update_current_order", resp.data.data)
|
|
// context.commit('update_finish_dialog_is_active', true)
|
|
|
|
// context.commit('payment/update_order_id', resp.data.data.id, {root:true})
|
|
// context.dispatch('payment/get_order', resp.data.data.id, {root:true})
|
|
|
|
}
|
|
} catch(e) {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async process(context) {
|
|
var order_id = context.rootState.patient.selected_patient.C_OrderHeaderID;
|
|
|
|
try {
|
|
let resp= await api.process(order_id)
|
|
|
|
if (resp.status != "200") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert('error')
|
|
} else {
|
|
context.commit('update_confirm_process_dialog_is_active', false)
|
|
context.commit('update_processed', true)
|
|
|
|
let selected_patient = context.rootState.patient.selected_patient
|
|
selected_patient.M_StatusCode = "CLINIC.PROCESS"
|
|
context.commit('patient/update_selected_patient', selected_patient, {root:true})
|
|
|
|
let patients = context.rootState.patient.patients
|
|
let total = context.rootState.patient.total_patient
|
|
for (let i in patients)
|
|
if (patients[i].C_OrderHeaderID == selected_patient.C_OrderHeaderID)
|
|
patients[i].M_StatusCode = "CLINIC.PROCESS"
|
|
context.commit('patient/update_patients', {records:patients,total:total}, {root:true})
|
|
}
|
|
} catch(e) {
|
|
|
|
}
|
|
},
|
|
|
|
async resetForm(context) {
|
|
try {
|
|
context.commit('patient/reset_selected_patient', null, {root:true})
|
|
context.commit('update_processed', false)
|
|
context.dispatch('patient/search', null, {root:true})
|
|
context.commit('diagnose/reset_diagnose', null, {root:true})
|
|
context.commit('gcs/reset_gcs', null, {root:true})
|
|
context.commit('px/reset_px', null, {root:true})
|
|
context.commit('receipt/reset_receipt', null, {root:true})
|
|
|
|
context.commit('update_order', {
|
|
order_id: 0,
|
|
order_number: "",
|
|
patient_id: 0,
|
|
patient_age: "",
|
|
diagnose_id: 0,
|
|
gcs_id: 0,
|
|
sistole: 0,
|
|
diastole: 0,
|
|
respiratory: 0,
|
|
temperature: 0,
|
|
pulse: 0,
|
|
weight: 0,
|
|
height: 0,
|
|
complaint: "",
|
|
suggestion: ""
|
|
})
|
|
} catch(e) {
|
|
|
|
}
|
|
},
|
|
|
|
async print_queue (context, id) {
|
|
// context.commit('update_print_dialog_is_active', true)
|
|
|
|
var order_id = id;
|
|
|
|
try {
|
|
let resp= await api.get_one(order_id)
|
|
|
|
if (resp.status != "200") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert('error')
|
|
} else {
|
|
|
|
console.log(resp)
|
|
window.do_print_ticket(resp.data.data.C_OrderHeaderQueueJSON)
|
|
}
|
|
} catch(e) {
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async print_receipt (context, a) {
|
|
context.commit('update_rpt_url', window.BASE_URL + '/birt/run?__report=reports/klinik/rpt_c_001.rptdesign&PID='+a+'&username=admin&__format=pdf')
|
|
context.commit('update_print_dialog_is_active', true)
|
|
},
|
|
|
|
async print_resume (context, a) {
|
|
context.commit('update_rpt_url', window.BASE_URL + '/birt/run?__report=reports/klinik/rpt_c_002.rptdesign&PID='+a+'&username=admin&__format=pdf')
|
|
context.commit('update_print_dialog_is_active', true)
|
|
}
|
|
}
|
|
}
|