290 lines
11 KiB
JavaScript
290 lines
11 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/patient.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id:-1,
|
|
search_patient: 0,
|
|
search_error_message: '',
|
|
patients: [],
|
|
patient_address: [],
|
|
doctor_address: [],
|
|
total_patient: 0,
|
|
selected_patient: {},
|
|
now_prm:{},
|
|
save_status: 0,
|
|
btn_save_seen: true,
|
|
pgrs_save: false,
|
|
save_error_message: '',
|
|
open_dialog_verification: false,
|
|
msg_info_verification: "",
|
|
no_save: 0,
|
|
open_alert_verification: false,
|
|
msg_alert_verification: "Yakin, belum disimpan lhoooo ?",
|
|
msg_action:'',
|
|
dialog_action:false,
|
|
show_right:'N',
|
|
verifications:[],
|
|
snackbar:{value:false,timeout:4000,text:''},
|
|
name:'',
|
|
nolab:'',
|
|
disabled_button:false,
|
|
dialoglist:false,
|
|
lookup:0,
|
|
barcodes:[],
|
|
show_simpan_tolak:false,
|
|
selected_status:{id:'P',name:'Siap diemail'},
|
|
current_page:1,
|
|
start_date:moment(new Date()).format('YYYY-MM-DD')
|
|
},
|
|
mutations: {
|
|
update_last_id(state, data) {
|
|
state.last_id = data
|
|
},
|
|
update_start_date(state, data) {
|
|
state.start_date = data
|
|
},
|
|
update_current_page(state, data) {
|
|
state.current_page = data
|
|
},
|
|
update_selected_status(state, data) {
|
|
state.selected_status = data
|
|
},
|
|
update_show_simpan_tolak(state, data) {
|
|
state.show_simpan_tolak = data
|
|
},
|
|
update_barcodes(state, data) {
|
|
state.barcodes = data
|
|
},
|
|
update_lookup(state, data) {
|
|
state.lookup = data
|
|
},
|
|
update_dialoglist(state, data) {
|
|
state.dialoglist = data
|
|
},
|
|
update_disabled_button(state, data) {
|
|
state.disabled_button = data
|
|
},
|
|
update_name(state, val) {
|
|
state.name = val
|
|
},
|
|
update_nolab(state, val) {
|
|
state.nolab = val
|
|
},
|
|
update_snackbar(state, patient) {
|
|
state.snackbar = patient
|
|
},
|
|
update_now_prm(state, patient) {
|
|
state.now_prm = patient
|
|
},
|
|
update_search_error_message(state, patient) {
|
|
state.search_error_message = patient
|
|
},
|
|
update_search_patient(state, patient) {
|
|
state.search_patient = patient
|
|
},
|
|
update_patients(state, data) {
|
|
state.patients = data.records
|
|
state.total_patient = data.total
|
|
},
|
|
update_selected_patient(state, val) {
|
|
state.selected_patient = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_btn_save_seen(state, val) {
|
|
state.btn_save_seen = val
|
|
},
|
|
update_pgrs_save(state, val) {
|
|
state.pgrs_save = val
|
|
},
|
|
update_dialog_action(state, val) {
|
|
state.dialog_action = val },
|
|
update_msg_action(state, val) {
|
|
state.msg_action = val
|
|
},
|
|
update_save_error_message(state, msg) {
|
|
state.save_error_message = ''
|
|
},
|
|
update_open_dialog_verification(state, val) {
|
|
state.open_dialog_verification = val
|
|
},
|
|
update_msg_info_verification(state, val) {
|
|
state.msg_info_verification = val
|
|
},
|
|
update_no_save(state, val) {
|
|
state.no_save = val
|
|
},
|
|
update_open_alert_verification(state, val) {
|
|
state.open_alert_verification = val
|
|
},
|
|
update_msg_alert_verification(state, val) {
|
|
state.msg_alert_verification = val
|
|
},
|
|
update_show_right(state, patient) {
|
|
state.show_right = patient
|
|
},
|
|
update_verifications(state, value) {
|
|
state.verifications = value
|
|
},
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_patient", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_patients", data)
|
|
//context.commit("update_total_patient", data.total)
|
|
if(prm.lastid == -1){
|
|
context.commit("update_selected_patient", data.records[0])
|
|
var pat = data.records[0]
|
|
context.dispatch("getstatuspergroup",pat)
|
|
}
|
|
else{
|
|
context.commit("update_selected_patient", data.records[prm.lastid])
|
|
var pat = data.records[prm.lastid]
|
|
context.dispatch("getstatuspergroup",pat)
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async lookup_barcodes(context,prm) {
|
|
context.commit("update_lookup",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.lookup_barcodes(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup",3)
|
|
} else {
|
|
context.commit("update_lookup",2)
|
|
let data = {
|
|
records : resp.data.records
|
|
}
|
|
context.commit("update_barcodes",data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_lookup",3)
|
|
console.log(e)
|
|
}
|
|
|
|
},
|
|
async getstatuspergroup(context,prm) {
|
|
context.commit("update_lookup",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getstatuspergroup(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup",3)
|
|
} else {
|
|
context.commit("update_lookup",2)
|
|
let data = {
|
|
records : resp.data.records
|
|
}
|
|
context.commit("done/update_info_bill",data.records['info_bill'],{root:true})
|
|
context.commit("done/update_info_deliveries",data.records['info_deliveries'],{root:true})
|
|
context.commit("done/update_info_test",data.records['info_test'],{root:true})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_lookup",3)
|
|
console.log(e)
|
|
}
|
|
|
|
},
|
|
async save(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
context.commit("update_btn_save_seen", false)
|
|
context.commit("update_pgrs_save", true)
|
|
try {
|
|
let resp = await api.save(one_token(),prm.patient, prm.status)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("update_no_save", 0)
|
|
context.commit("update_btn_save_seen", true)
|
|
context.commit("update_pgrs_save", false)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
let msg = data.records.message
|
|
|
|
context.commit("update_msg_info_verification", msg)
|
|
context.commit("update_open_dialog_verification", true)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async verify(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
context.commit("update_btn_save_seen", false)
|
|
context.commit("update_pgrs_save", true)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.verify(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_btn_save_seen", true)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("update_no_save", 0)
|
|
context.commit("update_btn_save_seen", true)
|
|
context.commit("update_pgrs_save", false)
|
|
context.commit("disabled_button", false)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
let msg = data.records.message
|
|
if(prm.act === 'Y')
|
|
context.commit("update_dialog_action", false)
|
|
else
|
|
context.commit("update_dialoglist", false)
|
|
|
|
var snackbar = {value:true,timeout:4000,text:msg}
|
|
context.commit("update_snackbar",snackbar)
|
|
var xprm = {
|
|
name:prm.name,
|
|
nolab: prm.nolab,
|
|
//status: prm.status
|
|
}
|
|
context.dispatch("search",xprm)
|
|
context.dispatch("done/search",prm.done_search,{root:true})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_btn_save_seen", true)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
}
|
|
}
|
|
} |