342 lines
12 KiB
JavaScript
342 lines
12 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/re_patient.js"
|
|
window.api = api
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
order_id:0,
|
|
search: '',
|
|
nolab: '',
|
|
sdate: new Date().toISOString().substr(0, 10),
|
|
edate: null,
|
|
|
|
search_status:0,
|
|
search_error_message:'',
|
|
search_dialog_is_active: false,
|
|
|
|
patients: [],
|
|
total_patient: 0,
|
|
total_patient_page: 0,
|
|
curr_patient_page: 1,
|
|
selected_patient: { },
|
|
total_day:0,
|
|
total_susulan:0,
|
|
|
|
// PX
|
|
total_px: 0,
|
|
pxs: [],
|
|
|
|
// Print
|
|
print_dialog: false,
|
|
rpt_url: '',
|
|
|
|
dialog_req: false,
|
|
info_req: {req_fo:[],req_spec_col:[],req_spec_ver:[],req_samp_ver:[],req_pre_an:[]},
|
|
url_print:'',
|
|
deliveries:[],
|
|
selected_delivery:{id:'0',name:'Semua'},
|
|
bar_chx_all:false,
|
|
indeterminatex:false,
|
|
current_page:1,
|
|
selected_patients:[],
|
|
snackbar:{status:false,color:'success',timeout:3000,text:""},
|
|
groups:[],
|
|
selected_group:{},
|
|
open_dialog_info:false,
|
|
msg_info:'',
|
|
print_count:0
|
|
},
|
|
mutations: {
|
|
update_print_count(state,val) {
|
|
state.print_count=val
|
|
},
|
|
update_open_dialog_info(state,val) {
|
|
state.open_dialog_info=val
|
|
},
|
|
update_msg_info(state,val) {
|
|
state.msg_info=val
|
|
},
|
|
update_selected_group(state,val) {
|
|
state.selected_group=val
|
|
},
|
|
update_groups(state,val) {
|
|
state.groups=val
|
|
},
|
|
update_snackbar(state,val) {
|
|
state.snackbar=val
|
|
},
|
|
update_selected_patients(state,val) {
|
|
state.selected_patients=val
|
|
},
|
|
update_total_day(state,val) {
|
|
state.total_day=val
|
|
},
|
|
update_total_susulan(state,val) {
|
|
state.total_susulan=val
|
|
},
|
|
update_current_page(state,val) {
|
|
state.current_page=val
|
|
},
|
|
update_indeterminatex(state,val) {
|
|
state.indeterminatex=val
|
|
},
|
|
update_bar_chx_all(state,val) {
|
|
state.bar_chx_all=val
|
|
},
|
|
update_deliveries(state,val) {
|
|
state.deliveries=val
|
|
},
|
|
update_selected_delivery(state,val) {
|
|
state.selected_delivery=val
|
|
},
|
|
update_url_print(state,val) {
|
|
state.url_print=val
|
|
},
|
|
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_search(state,val) {
|
|
state.search=val
|
|
},
|
|
|
|
update_nolab(state, val) {
|
|
state.nolab = val
|
|
},
|
|
|
|
update_search_status(state,status) {
|
|
state.search_status = status
|
|
},
|
|
|
|
update_patients(state, data) {
|
|
state.patients= data.records
|
|
state.total_patient = data.total
|
|
state.total_patient_page = data.total_page
|
|
},
|
|
|
|
update_curr_patient_page(state, data) {
|
|
state.curr_patient_page = data
|
|
},
|
|
|
|
update_selected_patient(state,val) {
|
|
state.selected_patient=val
|
|
},
|
|
|
|
update_id(state, id) {
|
|
state.order_id = id
|
|
},
|
|
|
|
update_pxs(state, pxs) {
|
|
state.pxs = pxs.records
|
|
},
|
|
|
|
update_sdate(state, date) {
|
|
state.sdate = date
|
|
},
|
|
|
|
update_edate(state, date) {
|
|
state.edate = date
|
|
},
|
|
|
|
update_print_dialog(state, v) {
|
|
state.print_dialog = v
|
|
},
|
|
|
|
update_rpt_url(state, v) {
|
|
let user = window.one_user()
|
|
state.rpt_url = '/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username='+user.M_UserUsername+'%20&PID='+v+'&ts='+Math.floor(Date.now() / 1000)
|
|
},
|
|
|
|
update_info_req(state, v) {
|
|
state.info_req = v
|
|
},
|
|
|
|
update_dialog_req(state, v) {
|
|
state.dialog_req = v
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let inp_no = context.state.search
|
|
let company_id = 0
|
|
if (context.rootState.company.company)
|
|
company_id = context.rootState.company.company.M_CompanyID
|
|
|
|
let resp= await api.search(one_token(), context.state.sdate, inp_no , context.state.curr_patient_page, company_id,context.state.selected_delivery.id,context.state.current_page)
|
|
|
|
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,
|
|
total_page: resp.data.total_page
|
|
}
|
|
context.commit("update_patients", data)
|
|
context.commit("update_total_day", resp.data.total_day)
|
|
context.commit("update_total_susulan", resp.data.total_susulan)
|
|
|
|
if (data.records.length < 1) {
|
|
context.commit('update_selected_patient', null)
|
|
//context.commit('re_px/update_pxs', [], {root:true})
|
|
}
|
|
else {
|
|
context.commit('update_selected_patient', data.records[0])
|
|
context.commit('re_px/update_id', data.records[0].T_OrderHeaderID, {root:true})
|
|
//let user = one_user()
|
|
let item = data.records[0]
|
|
|
|
//let rpt = "rpt_test"
|
|
//if(item.ready_print === 'N')
|
|
//rpt = "rpt_test_not_print"
|
|
//var xurl = "/birt/frameset?__report=report/one/lab/"+rpt+".rptdesign&__format=pdf&username="+user.M_UserUsername+"&PID="+item.T_OrderHeaderID+"&tm="+Date.now()
|
|
//context.commit('update_url_print', xurl)
|
|
var xrecords = data.records
|
|
xrecords.forEach((el)=>{
|
|
if(context.state.bar_chx_all == true)
|
|
el.chex = true
|
|
else{
|
|
el.chex = false
|
|
}
|
|
})
|
|
|
|
var xdata = {
|
|
records:xrecords,
|
|
total:resp.data.total,
|
|
total_page:resp.data.total_page
|
|
}
|
|
|
|
context.commit("update_patients", xdata)
|
|
context.dispatch('getdeliveries',{id:item.T_OrderHeaderID,promise_date:item.T_OrderPromiseDateTime})
|
|
|
|
}
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async info_req(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp= await api.info_req(one_token(), context.state.selected_patient.T_OrderHeaderID)
|
|
|
|
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","")
|
|
|
|
context.commit('update_info_req', resp.data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status", 3)
|
|
context.commit("update_search_error_message", e.message )
|
|
}
|
|
},
|
|
async releaseresult(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
// console.log(prm)
|
|
let resp= await api.releaseresult(one_token(),context.state.sdate,context.state.selected_patients,context.state.bar_chx_all,context.state.selected_delivery)
|
|
|
|
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","")
|
|
context.commit("update_bar_chx_all", false)
|
|
var snackbar = {status:true,color:"success",timeout:3000,text:"Laporan berhasil diserahkan"}
|
|
context.commit("update_snackbar",snackbar)
|
|
context.dispatch("search")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status", 3)
|
|
context.commit("update_search_error_message", e.message )
|
|
}
|
|
},
|
|
|
|
async get_deliverytype(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp= await api.getdeliverytype(one_token())
|
|
|
|
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","")
|
|
|
|
context.commit('update_deliveries', resp.data.records)
|
|
context.commit('update_selected_delivery', resp.data.records[0])
|
|
context.dispatch("search")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status", 3)
|
|
context.commit("update_search_error_message", e.message )
|
|
}
|
|
},
|
|
async getdeliveries(context,prm) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getdeliveries(prm)
|
|
|
|
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","")
|
|
|
|
context.commit('update_deliveries', resp.data.records['deliveries'])
|
|
context.commit('update_groups', resp.data.records['groups'])
|
|
context.commit('update_print_count', resp.data.records['print_count'])
|
|
if(resp.data.records['groups'].length > 0){
|
|
var selected_group = resp.data.records['groups'][0]
|
|
context.commit('update_selected_group', selected_group)
|
|
if(selected_group.type === 'rpt'){
|
|
let user = one_user()
|
|
var xurl = "/birt/frameset?__report=report/one/lab/"+selected_group.rpt+".rptdesign&__format=pdf&username="+user.M_UserUsername+"&PID="+prm.id+"&tm="+Date.now()
|
|
console.log(xurl)
|
|
context.commit('update_url_print', xurl)
|
|
}
|
|
}
|
|
else{
|
|
let msg = "<p>Sebenarnya sudah ada rencana buat ke semeru, semakin hari malah terlupakan</p><p>Sudah dicari kemana-mana tidak ketemu, maaf ayem sori tiada hasil yang ditampilkan</p>"
|
|
context.commit("update_msg_info",msg)
|
|
context.commit("update_open_dialog_info", true)
|
|
}
|
|
|
|
|
|
//context.dispatch("search")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status", 3)
|
|
context.commit("update_search_error_message", e.message )
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|