513 lines
19 KiB
JavaScript
513 lines
19 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/patient.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
lastidx:0,
|
|
lookup_status:0,
|
|
lookup_error_message:'',
|
|
search_patient: 0,
|
|
search_error_message: '',
|
|
start_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
end_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
search:'',
|
|
total_patiens: 0,
|
|
total_filter_patiens: 0,
|
|
total_patients_all:0,
|
|
patients: [],
|
|
total_patient: 0,
|
|
selected_patient: {totalbill:0},
|
|
save_error_message: '',
|
|
statuses:[],
|
|
selected_status:{},
|
|
open_alert_no_pay: false,
|
|
msg_alert_no_pay: "Loh ... Gak jadi bayar dong ?",
|
|
current_page:1,
|
|
total_page:0,
|
|
filters:[{id:'day',name:'Hari ini'},{id:'notsampled',name:'Belum sampling'},{id:'all',name:'Tampilkan semua'}],
|
|
selected_filter:{id:'day',name:'Hari ini'},
|
|
promise_dialog:false,
|
|
promises:[],
|
|
errors:[],
|
|
save_status:0,
|
|
save_error_message:'',
|
|
barcodes:[],
|
|
dialog_barcode:false,
|
|
autocomplete_status:0,
|
|
companies:[],
|
|
selected_company:{id:0,name:'Semua'},
|
|
dialog_details:false,
|
|
order_id:0,
|
|
noreg:'',
|
|
data_patient:[],
|
|
data_packet:[],
|
|
data_tests:[],
|
|
data_sample_lab:[],
|
|
data_sample_radiodiagnostic:[],
|
|
data_sample_electromedic:[],
|
|
data_sample_other:[],
|
|
dialog_scanner:false,
|
|
selected_patient:{},
|
|
sampletypes:[],
|
|
act_scan:'',
|
|
alert_msg:"",
|
|
alert_status:false,
|
|
isScanning:false,
|
|
html5QrCode:null,
|
|
stations:[],
|
|
selected_station:{},
|
|
locations:[],
|
|
selected_location:{},
|
|
get_data_status:0,
|
|
isdone:"X",
|
|
url_labnumber:""
|
|
},
|
|
mutations: {
|
|
update_url_labnumber(state, val) {
|
|
state.url_labnumber = val
|
|
},
|
|
update_isdone(state, val) {
|
|
state.isdone = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_locations(state, val) {
|
|
state.locations = val
|
|
},
|
|
update_selected_location(state, val) {
|
|
state.selected_location = val
|
|
},
|
|
update_stations(state, val) {
|
|
state.stations = val
|
|
},
|
|
update_selected_station(state, val) {
|
|
state.selected_station = val
|
|
},
|
|
update_html5QrCode(state, val) {
|
|
state.html5QrCode = val
|
|
},
|
|
update_isScanning(state, val) {
|
|
state.isScanning = val
|
|
},
|
|
update_alert_msg(state, val) {
|
|
state.alert_msg = val
|
|
},
|
|
update_alert_status(state, val) {
|
|
state.alert_status = val
|
|
},
|
|
update_act_scan(state, val) {
|
|
state.act_scan = val
|
|
},
|
|
update_sampletypes(state, val) {
|
|
state.sampletypes = val
|
|
},
|
|
update_selected_patient(state, val) {
|
|
state.selected_patient = val
|
|
},
|
|
update_dialog_scanner(state, val) {
|
|
state.dialog_scanner = val
|
|
},
|
|
update_data_sample_other(state, val) {
|
|
state.data_sample_other = val
|
|
},
|
|
update_data_sample_electromedic(state, val) {
|
|
state.data_sample_electromedic = val
|
|
},
|
|
update_data_sample_radiodiagnostic(state, val) {
|
|
state.data_sample_radiodiagnostic = val
|
|
},
|
|
update_data_sample_lab(state, val) {
|
|
state.data_sample_lab = val
|
|
},
|
|
update_data_tests(state, val) {
|
|
state.data_tests = val
|
|
},
|
|
update_data_packet(state, val) {
|
|
state.data_packet = val
|
|
},
|
|
update_data_patient(state, val) {
|
|
state.data_patient = val
|
|
},
|
|
update_order_id(state, val) {
|
|
state.order_id = val
|
|
},
|
|
update_noreg(state, val) {
|
|
state.noreg = val
|
|
},
|
|
update_dialog_details(state, val) {
|
|
state.dialog_details = val
|
|
},
|
|
update_companies(state, val) {
|
|
state.companies = val
|
|
},
|
|
update_selected_company(state, val) {
|
|
state.selected_company = val
|
|
},
|
|
update_dialog_barcode(state, val) {
|
|
state.dialog_barcode = val
|
|
},
|
|
update_statuses(state, val) {
|
|
state.statuses = val
|
|
},
|
|
update_total_patients_all(state, val) {
|
|
state.total_patients_all = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_save_error_message(state, val) {
|
|
state.save_error_message = val
|
|
},
|
|
update_lookup_error_message(state,val) {
|
|
state.lookup_error_message = val
|
|
},
|
|
update_lookup_status(state,status) {
|
|
state.lookup_status = status
|
|
},
|
|
update_promise_dialog(state, val) {
|
|
state.promise_dialog = val
|
|
},
|
|
update_promises(state, val) {
|
|
state.promises = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_lastidx(state, val) {
|
|
state.lastidx = val
|
|
},
|
|
update_selected_filter(state, val) {
|
|
state.selected_filter = val
|
|
},
|
|
update_filters(state, val) {
|
|
state.filters = val
|
|
},
|
|
update_total_page(state, val) {
|
|
state.total_page = val
|
|
},
|
|
|
|
update_total_patient(state, val) {
|
|
state.total_patient = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
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
|
|
},
|
|
update_selected_patient(state, val) {
|
|
state.selected_patient = val
|
|
},
|
|
update_start_date(state, val) {
|
|
state.start_date = val
|
|
},
|
|
update_autocomplete_status(state,val){
|
|
state.autocomplete_status = val
|
|
},
|
|
update_end_date(state, val) {
|
|
state.end_date = val
|
|
},
|
|
update_search(state, val) {
|
|
state.search = val
|
|
},
|
|
update_selected_status(state, val) {
|
|
state.selected_status = val
|
|
},
|
|
update_open_alert_no_pay(state, val) {
|
|
state.open_alert_no_pay = val
|
|
},
|
|
update_msg_alert_no_pay(state, val) {
|
|
state.msg_alert_no_pay = val
|
|
}
|
|
},
|
|
actions: {
|
|
async load_data(context) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
//console.log(prm)
|
|
let prm = {}
|
|
prm.order_id = context.state.order_id
|
|
prm.noreg = context.state.noreg
|
|
let resp = await api.search_patient(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_patient = resp.data.data_patient
|
|
let data_packet = resp.data.data_packet
|
|
let data_tests = resp.data.data_tests
|
|
let data_sample_lab = resp.data.data_sample_lab
|
|
let data_sample_radiodiagnostic = resp.data.data_sample_radiodiagnostic
|
|
let data_sample_electromedic = resp.data.data_sample_electromedic
|
|
let data_sample_other = resp.data.data_sample_other
|
|
|
|
|
|
context.commit("update_data_patient", data_patient)
|
|
context.commit("update_data_packet", data_packet)
|
|
context.commit("update_data_tests", data_tests)
|
|
context.commit("update_data_sample_lab", data_sample_lab)
|
|
context.commit("update_data_sample_radiodiagnostic", data_sample_radiodiagnostic)
|
|
context.commit("update_data_sample_electromedic", data_sample_electromedic)
|
|
context.commit("update_data_sample_other", data_sample_other)
|
|
|
|
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async scan_patient(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
//console.log(prm)
|
|
prm.token = one_token()
|
|
prm.station_id = context.state.selected_station.id
|
|
prm.location_id = context.state.selected_location.locationID
|
|
let resp = await api.scan_patient(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", "")
|
|
console.log("creturn")
|
|
console.log(_.isEmpty(resp.data.data_patient))
|
|
if(!_.isEmpty(resp.data.data_patient)){
|
|
console.log('Y')
|
|
context.commit("update_data_patient", resp.data.data_patient)
|
|
context.commit("update_data_packet", resp.data.data_packet)
|
|
context.commit("update_data_tests", resp.data.data_tests)
|
|
context.commit("update_data_sample_lab", resp.data.data_sample_lab)
|
|
}
|
|
else{
|
|
console.log('N')
|
|
context.commit("update_dialog_scanner", false)
|
|
context.commit("update_alert_msg", "Pasien dengan nomor lab "+prm.labnumber+" tidak ditemukan di station dan lokasi yang dipilih!")
|
|
context.commit("update_alert_status", true)
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async scan_barcode(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
//console.log(prm)
|
|
prm.token = one_token()
|
|
prm.station_id = context.state.selected_station.id
|
|
prm.location_id = context.state.selected_location.locationID
|
|
prm.patient = context.state.data_patient
|
|
let resp = await api.scanbarcode(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", "")
|
|
if(resp.data.status_log === "Y"){
|
|
console.log(resp.data)
|
|
|
|
if(resp.data.isdone === "N")
|
|
location.reload()
|
|
else
|
|
location.replace("/one-ui/test/vuex/cpone-doctor-klinik-mobile/")
|
|
|
|
}
|
|
else{
|
|
context.commit("update_alert_msg", "Barcode "+prm.barcode+" tidak ditemukan pada pasien ini, pastikan barcode yang discan sudah benar")
|
|
context.commit("update_alert_status", true)
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async lookup_statuses(context,prm) {
|
|
context.commit("update_lookup_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.lookup_statuses(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status",3)
|
|
context.commit("update_lookup_error_message",resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status",2)
|
|
context.commit("update_lookup_error_message","")
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_statuses",data.records)
|
|
//context.commit("update_promise_dialog",true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_lookup_status",3)
|
|
context.commit("update_lookup_error_message",e.message )
|
|
}
|
|
},
|
|
async getdatabarcodes(context,prm) {
|
|
context.commit("update_lookup_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getdatabarcodes(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status",3)
|
|
context.commit("update_lookup_error_message",resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status",2)
|
|
context.commit("update_lookup_error_message","")
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_barcodes",data.records)
|
|
context.commit("update_dialog_barcode",true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_lookup_status",3)
|
|
context.commit("update_lookup_error_message",e.message )
|
|
}
|
|
},
|
|
async serahkan(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.serahkan(prm)
|
|
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", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
var row_data = prm
|
|
row_data.status = 'D'
|
|
row_data.received_time = resp.data.records.received_time
|
|
var patients = context.state.patients
|
|
//console.log(patients)
|
|
//console.log(prm.last_idx)
|
|
//console.log(prm.last_detail_idx)
|
|
//console.log(patients.details)
|
|
patients[prm.spk_idx].details[prm.last_idx].details[prm.last_detail_idx] = row_data
|
|
context.commit("update_patients",patients)
|
|
context.commit("update_dialog_details", false)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchcompany(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchcompany(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status",3)
|
|
} else {
|
|
context.commit("update_autocomplete_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_companies",resp.data.records)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async getstations(context) {
|
|
context.commit("update_get_data_status", 1);
|
|
try {
|
|
let resp = await api.getstations(one_token());
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3);
|
|
} else {
|
|
context.commit("update_get_data_status", 2);
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total,
|
|
};
|
|
context.commit("update_stations", data.records.stations);
|
|
context.commit("update_selected_station", data.records.stations[0])
|
|
|
|
context.dispatch("getLocation", data.records.stations[0].id)
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
context.commit("update_get_data_status", 3);
|
|
}
|
|
},
|
|
async getLocation(context, prm) {
|
|
context.commit("update_get_data_status", 1);
|
|
try {
|
|
let param = { token: one_token(), station_id: prm };
|
|
let resp = await api.getLocation(param);
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3);
|
|
} else {
|
|
context.commit("update_get_data_status", 2);
|
|
|
|
context.commit("update_locations", resp.data.records);
|
|
context.commit("update_selected_location", resp.data.records[0]);
|
|
if(context.state.url_labnumber !== ""){
|
|
context.dispatch("scan_patient",{'labnumber':context.state.url_labnumber})
|
|
}
|
|
console.log(data);
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
context.commit("update_get_data_status", 3);
|
|
}
|
|
},
|
|
async skipaction(context) {
|
|
context.commit("update_get_data_status", 1);
|
|
try {
|
|
let param = {
|
|
token: one_token(),
|
|
order_id:context.state.data_patient.xid,
|
|
station_id:context.state.selected_station.id,
|
|
location_id:context.state.selected_location
|
|
}
|
|
let resp = await api.skipaction(param);
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3);
|
|
} else {
|
|
context.commit("update_get_data_status", 2);
|
|
|
|
location.replace("/one-ui/test/vuex/cpone-doctor-klinik-mobile/")
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
context.commit("update_get_data_status", 3);
|
|
}
|
|
},
|
|
}
|
|
}
|