687 lines
26 KiB
JavaScript
687 lines
26 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: [{ name: 'Belum Lunas', value: 'N' }, { name: 'Lunas', value: 'Y' }, { name: 'Semua', value: 'A' }],
|
|
selected_status: { name: 'Belum Lunas', value: 'N' },
|
|
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' },
|
|
doctors: [],
|
|
selected_doctor: { id: 0, name: 'Semua' },
|
|
dialog_timeline_delivery: false,
|
|
timeline_delivery: [],
|
|
dialog_update_dob: false,
|
|
show_form_dob: 'N',
|
|
data_patient: {},
|
|
alert_success: false,
|
|
msg_success: "",
|
|
filter_tests: [],
|
|
selected_filter_test: {},
|
|
dialogQrCode: false,
|
|
urlQrCode: '',
|
|
dialogQrCodePatient: false,
|
|
urlQrCodePatient: '',
|
|
branchList: [],
|
|
selectedBranch: {
|
|
id: 0,
|
|
code: 0,
|
|
name: 'Semua'
|
|
},
|
|
detail_item:[],
|
|
loading_result:false,
|
|
dialog_result:false,
|
|
selected_detail_process:{},
|
|
data_result_log:[],
|
|
dialog_result_log:false,
|
|
data_resume_individu_log:[],
|
|
dialog_resume_individu_log:false,
|
|
dialog_attachment:false,
|
|
attachment_files:null,
|
|
show_progrees_upload:false,
|
|
errors_upload:[],
|
|
formData:null,
|
|
dialog_error:false
|
|
},
|
|
mutations: {
|
|
update_dialog_error(state, val) {
|
|
state.dialog_error = val
|
|
},
|
|
update_formData(state, val) {
|
|
state.formData = val
|
|
},
|
|
update_errors_upload(state, val) {
|
|
state.errors_upload = val
|
|
},
|
|
update_show_progrees_upload(state, val) {
|
|
state.show_progrees_upload = val
|
|
},
|
|
update_attachment_files(state, val) {
|
|
state.attachment_files = val
|
|
},
|
|
update_dialog_attachment(state, val) {
|
|
state.dialog_attachment = val
|
|
},
|
|
update_dialog_resume_individu_log(state, val) {
|
|
state.dialog_resume_individu_log = val
|
|
},
|
|
update_data_resume_individu_log(state, val) {
|
|
state.data_resume_individu_log = val
|
|
},
|
|
update_dialog_result_log(state, val) {
|
|
state.dialog_result_log = val
|
|
},
|
|
update_data_result_log(state, val) {
|
|
state.data_result_log = val
|
|
},
|
|
update_selected_detail_process(state, val) {
|
|
state.selected_detail_process = val
|
|
},
|
|
update_dialog_result(state, val) {
|
|
state.dialog_result = val
|
|
},
|
|
update_loading_result(state, val) {
|
|
state.loading_result = val
|
|
},
|
|
update_detail_item(state, val) {
|
|
state.detail_item = val
|
|
},
|
|
update_filter_tests(state, val) {
|
|
state.filter_tests = val
|
|
},
|
|
update_selected_filter_test(state, val) {
|
|
state.selected_filter_test = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_data_patient(state, val) {
|
|
state.data_patient = val
|
|
},
|
|
update_show_form_dob(state, val) {
|
|
state.show_form_dob = val
|
|
},
|
|
update_dialog_update_dob(state, val) {
|
|
state.dialog_update_dob = val
|
|
},
|
|
update_timeline_delivery(state, val) {
|
|
state.timeline_delivery = val
|
|
},
|
|
update_dialog_timeline_delivery(state, val) {
|
|
state.dialog_timeline_delivery = val
|
|
},
|
|
update_companies(state, val) {
|
|
state.companies = val
|
|
},
|
|
update_selected_company(state, val) {
|
|
state.selected_company = val
|
|
},
|
|
update_doctors(state, val) {
|
|
state.doctors = val
|
|
},
|
|
update_selected_doctor(state, val) {
|
|
state.selected_doctor = val
|
|
},
|
|
update_dialog_barcode(state, val) {
|
|
state.dialog_barcode = val
|
|
},
|
|
update_barcodes(state, val) {
|
|
state.barcodes = 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.records
|
|
state.total_patient = data.total
|
|
state.total_page = data.total
|
|
state.total_patients = data.total
|
|
state.total_filter_patients = data.total_filter
|
|
},
|
|
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
|
|
},
|
|
update_dialogQrCode(state, val) {
|
|
state.dialogQrCode = val
|
|
},
|
|
update_urlQrCode(state, val) {
|
|
state.urlQrCode = val
|
|
},
|
|
update_dialogQrCodePatient(state, val) {
|
|
state.dialogQrCodePatient = val
|
|
},
|
|
update_urlQrCodePatient(state, val) {
|
|
state.urlQrCodePatient = val
|
|
},
|
|
update_branchList(state, val) {
|
|
state.branchList = val
|
|
},
|
|
update_selectedBranch(state, val) {
|
|
state.selectedBranch = val
|
|
},
|
|
},
|
|
actions: {
|
|
async uploadattachment(context,prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
//prm.id = context.state.selected_fna.id
|
|
// prm.token = one_token()
|
|
let resp = await api.uploadattachment(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_show_progrees_upload", false)
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_formData", null)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_formData", null)
|
|
context.commit("update_dialog_attachment", false)
|
|
|
|
context.commit("update_attachment_files", data.records)
|
|
context.commit("update_show_progrees_upload", false)
|
|
if(resp.data.errors && resp.data.errors.length > 0){
|
|
console.log(resp.data.errors)
|
|
context.commit("update_errors_upload", resp.data.errors)
|
|
context.commit("update_dialog_error", true)
|
|
}
|
|
let xprm = {
|
|
startdate: context.state.start_date,
|
|
enddate: context.state.end_date,
|
|
search: context.state.search,
|
|
doctorid: context.state.selected_doctor.id,
|
|
doctorcode: context.state.selected_doctor.code,
|
|
companyid: context.state.selected_company.id,
|
|
testid: context.state.selected_filter_test.id,
|
|
current_page: context.state.current_page,
|
|
lastidx: context.state.lastidx,
|
|
}
|
|
context.dispatch("search", xprm)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_show_progrees_upload", false)
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async search(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
console.log(prm)
|
|
prm.token = one_token()
|
|
prm.branchid = context.state.selectedBranch.id
|
|
let data = {
|
|
records: [],
|
|
total: 0,
|
|
total_filter: 0
|
|
}
|
|
context.commit("update_patients", data)
|
|
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,
|
|
total_filter: resp.data.total_filter
|
|
}
|
|
console.log("")
|
|
console.log(data.records)
|
|
context.commit("update_patients", data)
|
|
context.commit("update_total_page", data.total)
|
|
context.commit("update_total_patients_all", resp.data.total_all)
|
|
|
|
if (prm.lastidx === -1) {
|
|
context.commit("update_selected_patient", data.records[0])
|
|
|
|
}
|
|
else {
|
|
context.commit("update_selected_patient", data.records[prm.lastidx])
|
|
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async lookup_promises(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookup_promises(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_promises", 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
|
|
}
|
|
data.records.push({
|
|
"id": "x1",
|
|
"type": "qrcode",
|
|
"T_SampleTypeID": "qr",
|
|
"T_BarcodeLabID": "-",
|
|
"T_BarcodeLabBarcode": "-",
|
|
"orderid": "0",
|
|
"T_BarcodeLabCounter": "0",
|
|
"T_SampleTypeName": "Qrcode",
|
|
"chex": false
|
|
})
|
|
data.records.push({
|
|
"id": "x2",
|
|
"type": "qrcode",
|
|
"T_SampleTypeID": "qrpasien",
|
|
"T_BarcodeLabID": "-",
|
|
"T_BarcodeLabBarcode": "-",
|
|
"orderid": "0",
|
|
"T_BarcodeLabCounter": "0",
|
|
"T_SampleTypeName": "Qrcode Pasien",
|
|
"chex": false
|
|
})
|
|
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 getdatadob(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getdatadob(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_data_patient", data.records)
|
|
context.commit("update_show_form_dob", resp.data.status)
|
|
context.commit("update_dialog_update_dob", true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async removeFile(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.removefile(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 xprm = {
|
|
startdate: context.state.start_date,
|
|
enddate: context.state.end_date,
|
|
search: context.state.search,
|
|
doctorid: context.state.selected_doctor.id,
|
|
doctorcode: context.state.selected_doctor.code,
|
|
companyid: context.state.selected_company.id,
|
|
testid: context.state.selected_filter_test.id,
|
|
current_page: context.state.current_page,
|
|
lastidx: context.state.lastidx,
|
|
}
|
|
context.dispatch("search", xprm)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async gettimelinedelivery(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.gettimelinedelivery(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_timeline_delivery", data.records)
|
|
context.commit("update_dialog_timeline_delivery", true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async savepromises(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.save_promises(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
|
|
}
|
|
context.commit("update_promises", data.records)
|
|
context.commit("update_promise_dialog", false)
|
|
var xsearch = prm.search
|
|
|
|
context.dispatch("search", xsearch)
|
|
}
|
|
} 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 getbranch(context) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.getbranch({ token: one_token() })
|
|
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_branchList", resp.data.records)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async get_detail_tests(context,prm) {
|
|
//context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getdetailtests(prm)
|
|
console.log(resp)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_loading_result", false)
|
|
alert("Gagal mengambil data")
|
|
} else {
|
|
context.commit("update_loading_result", false)
|
|
context.commit("update_detail_item", resp.data.records)
|
|
context.commit("update_dialog_result",true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async get_data_result_log(context,prm) {
|
|
//context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getdataresultlog(prm)
|
|
console.log(resp)
|
|
if (resp.status != "OK") {
|
|
//context.commit("update_loading_result", false)
|
|
alert("Gagal mengambil data")
|
|
} else {
|
|
//context.commit("update_loading_result", false)
|
|
context.commit("update_data_result_log", resp.data.records)
|
|
context.commit("update_dialog_result_log",true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
|
|
async get_resume_individu_log(context,prm) {
|
|
//context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getresumeindividulog(prm)
|
|
console.log(resp)
|
|
if (resp.status != "OK") {
|
|
//context.commit("update_loading_result", false)
|
|
alert("Gagal mengambil data")
|
|
} else {
|
|
//context.commit("update_loading_result", false)
|
|
context.commit("update_data_resume_individu_log", resp.data.records)
|
|
context.commit("update_dialog_resume_individu_log",true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async searchdoctor(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchdoctor(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_doctors", resp.data.records)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async searchtest(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchtest(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_filter_tests", resp.data.records)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async updatedob(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
prm.orderid = context.state.selected_patient.T_OrderHeaderID
|
|
prm.token = one_token()
|
|
let resp = await api.updatedob(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_dialog_update_dob", false)
|
|
var msg = "Terima kasih telah meng-update tanggal lahir, jadi gak bingung dong kalo mau ultah"
|
|
if (prm.status === 'Y') {
|
|
msg = "Terima kasih, Mimin akan melanjutkan request ini ke bagian proses"
|
|
}
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_alert_success", true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
}
|
|
}
|
|
}
|