138 lines
5.9 KiB
JavaScript
138 lines
5.9 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/patient.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
search_patient: 0,
|
|
search_error_message: '',
|
|
patients: [],
|
|
patient_address: [],
|
|
doctor_address: [],
|
|
total_patient: 0,
|
|
selected_patient: {},
|
|
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 ?"
|
|
},
|
|
mutations: {
|
|
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_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
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
let resp = await api.search(one_token(), prm.nolab, prm.name, prm.status)
|
|
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_selected_patient", data.records[0])
|
|
context.commit("verification/update_verification_patient", data.records[0]['verification_patient'], { root: true })
|
|
context.commit("verification/update_verification_doctor", data.records[0]['verification_doctor'], { root: true })
|
|
context.commit("verification/update_verification_delivery", data.records[0]['verification_delivery'], { root: true })
|
|
context.commit("verification/update_verification_payment", data.records[0]['verification_payment'], { root: true })
|
|
context.commit("verification/update_verification_supplies", data.records[0]['verification_supplies'], { root: true })
|
|
|
|
context.commit("verification/update_verification_barcode", data.records[0]['verification_barcode'], { root: true })
|
|
context.commit("verification/update_verification_company_mou", data.records[0]['verification_companymou'], { root: true })
|
|
context.commit("verification/update_verification_px", data.records[0]['verification_px'], { root: true })
|
|
context.commit("px/update_moucompany", data.records[0], { root: true })
|
|
context.commit("verification/update_verification_info", data.records[0]['verification_info'], { root: true })
|
|
|
|
context.commit("delivery/update_address_patient", data.records[0]['address_patient'], { root: true })
|
|
context.commit("delivery/update_address_doctor", data.records[0]['address_doctor'], { root: true })
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
} |