394 lines
15 KiB
JavaScript
394 lines
15 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,
|
|
data_survey:{},
|
|
status_selesai:false,
|
|
photo_qr:""
|
|
},
|
|
mutations: {
|
|
update_photo_qr(state, val) {
|
|
state.photo_qr = val
|
|
},
|
|
update_status_selesai(state, val) {
|
|
state.status_selesai = val
|
|
},
|
|
update_data_survey(state, val) {
|
|
state.data_survey = 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
|
|
let data_survey = resp.data.data_survey
|
|
|
|
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)
|
|
context.commit("update_data_survey", data_survey)
|
|
//https://devcpone.aplikasi.web.id/one-media/one-qrpatient/patient_qr_R2407110001.png
|
|
let photo_qr = "/one-media/one-qrpatient/patient_qr_"+data_patient.labnumber+".png"
|
|
context.commit("update_photo_qr", photo_qr)
|
|
|
|
let status_selesai = true
|
|
|
|
if(data_sample_lab.length > 0){
|
|
data_sample_lab.forEach(data => {
|
|
if(data.is_received === 'N')
|
|
status_selesai = false
|
|
})
|
|
}
|
|
|
|
if(data_sample_radiodiagnostic.length > 0){
|
|
data_sample_radiodiagnostic.forEach(data => {
|
|
if(data.is_received === 'N')
|
|
status_selesai = false
|
|
})
|
|
}
|
|
|
|
if(data_sample_electromedic.length > 0){
|
|
data_sample_electromedic.forEach(data => {
|
|
if(data.is_received === 'N')
|
|
status_selesai = false
|
|
})
|
|
}
|
|
|
|
if(data_sample_other.length > 0){
|
|
data_sample_other.forEach(data => {
|
|
if(data.is_received === 'N')
|
|
status_selesai = false
|
|
})
|
|
}
|
|
|
|
if(!_.isEmpty(data_survey)){
|
|
status_selesai = false
|
|
}
|
|
context.commit("update_status_selesai", status_selesai)
|
|
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async search(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
//console.log(prm)
|
|
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
|
|
}
|
|
console.log(data.records)
|
|
context.commit("update_patients", data.records)
|
|
if(data.records.length > 0)
|
|
context.commit("update_selected_patient", data.records[0])
|
|
}
|
|
} 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)
|
|
}
|
|
}
|
|
}
|
|
}
|