109 lines
3.2 KiB
JavaScript
109 lines
3.2 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/patient.js"
|
|
window.api = api
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
noreg:'',
|
|
search: '',
|
|
search_no_lab: '',
|
|
search_status:0,
|
|
search_error_message:'',
|
|
search_dialog_is_active: false,
|
|
patients: [],
|
|
total_patient: 0,
|
|
selected_patient: {
|
|
mr : '-',
|
|
name : '-',
|
|
dob : '-',
|
|
phone : '-'
|
|
},
|
|
},
|
|
mutations: {
|
|
update_search_dialog_is_active(state,status) {
|
|
state.search_dialog_is_active = status
|
|
},
|
|
update_search_error_message(state,status) {
|
|
state.search_error_message = status
|
|
},
|
|
update_noreg(state, val) {
|
|
state.noreg=val
|
|
},
|
|
update_search(state, val) {
|
|
state.search=val
|
|
},
|
|
update_search_no_lab(state, val) {
|
|
state.search_no_lab=val
|
|
},
|
|
update_search_status(state, status) {
|
|
state.search_status = status
|
|
},
|
|
update_patients(state, data) {
|
|
for (let i in data.records) {
|
|
data.records[i].vmenu = false
|
|
|
|
let menu_items = [
|
|
{ code: '01', title: 'Cetak Resep Obat' },
|
|
{ code: '02', title: 'Cetak Antrian Lab' },
|
|
{ code: '03', title: 'Click Resume Pasien' }
|
|
]
|
|
|
|
if (data.records[i].C_OrderHeaderIsLab == "N")
|
|
menu_items.splice(1,1)
|
|
|
|
if (data.records[i].C_OrderHeaderIsReceipt == "N")
|
|
menu_items.splice(0,1)
|
|
|
|
data.records[i].menu_items = menu_items
|
|
}
|
|
|
|
state.patients= data.records
|
|
state.total_patient = data.total
|
|
|
|
|
|
},
|
|
|
|
trigger_patients_vmenu(state, idx) {
|
|
let p = state.patients
|
|
p[idx].vmenu = !p[idx].vmenu
|
|
state.patients = p
|
|
},
|
|
|
|
update_selected_patient(state,val) {
|
|
state.selected_patient=val
|
|
},
|
|
|
|
reset_selected_patient(state) {
|
|
state.selected_patient = { mr : '-', name : '-', dob : '-', phone : '-' }
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context,prm) {
|
|
context.commit("update_search_status",1)
|
|
try {
|
|
let status = context.rootState.status.selected_status.M_StatusID ?
|
|
context.rootState.status.selected_status.M_StatusID : 0
|
|
let resp= await api.search(context.state.search_no_lab, context.state.search, status)
|
|
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 = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_patients",data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
}
|
|
}
|
|
}
|