134 lines
3.7 KiB
JavaScript
134 lines
3.7 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/re_patient.js"
|
|
window.api = api
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
order_id:0,
|
|
search: '',
|
|
nolab: '',
|
|
sdate: null,
|
|
edate: null,
|
|
|
|
search_status:0,
|
|
search_error_message:'',
|
|
search_dialog_is_active: false,
|
|
|
|
patients: [],
|
|
total_patient: 0,
|
|
total_patient_page: 0,
|
|
curr_patient_page: 1,
|
|
selected_patient: { },
|
|
|
|
|
|
// PX
|
|
total_px: 0,
|
|
pxs: []
|
|
},
|
|
mutations: {
|
|
update_search_dialog_is_active(state,status) {
|
|
state.search_dialog_is_active = status
|
|
},
|
|
update_search_error_message(state,status) {
|
|
state.search_error_message = status
|
|
},
|
|
|
|
update_search(state,val) {
|
|
state.search=val
|
|
},
|
|
|
|
update_nolab(state, val) {
|
|
state.nolab = val
|
|
},
|
|
|
|
update_search_status(state,status) {
|
|
state.search_status = status
|
|
},
|
|
|
|
update_patients(state, data) {
|
|
state.patients= data.records
|
|
state.total_patient = data.total
|
|
state.total_patient_page = data.total_page
|
|
},
|
|
|
|
update_curr_patient_page(state, data) {
|
|
state.curr_patient_page = data
|
|
},
|
|
|
|
update_selected_patient(state,val) {
|
|
state.selected_patient=val
|
|
},
|
|
|
|
update_id(state, id) {
|
|
state.order_id = id
|
|
},
|
|
|
|
update_pxs(state, pxs) {
|
|
state.pxs = pxs.records
|
|
},
|
|
|
|
update_sdate(state, date) {
|
|
state.sdate = date
|
|
},
|
|
|
|
update_edate(state, date) {
|
|
state.edate = date
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp= await api.search(one_token(), context.state.nolab, context.state.search, context.state.curr_patient_page)
|
|
|
|
if (resp.status != "OK") {
|
|
|
|
context.commit("update_search_status", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_status",2)
|
|
context.commit("update_search_error_message","")
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total,
|
|
total_page: resp.data.total_page
|
|
}
|
|
context.commit("update_patients", data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
// async search_px(context) {
|
|
// context.commit("update_search_status", 1)
|
|
// try {
|
|
// let resp= await api.search_px(context.state.selected_worklist.T_WorklistID,
|
|
// context.state.sdate,
|
|
// context.state.edate)
|
|
|
|
// if (resp.status != "OK") {
|
|
|
|
// context.commit("update_search_status", 3)
|
|
// context.commit("update_search_error_message", resp.message)
|
|
// } else {
|
|
// context.commit("update_search_status",2)
|
|
// context.commit("update_search_error_message","")
|
|
// let data = {
|
|
// records : resp.data.records,
|
|
// total: resp.data.total
|
|
// }
|
|
// context.commit("update_pxs", data)
|
|
// }
|
|
// } catch(e) {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",e.message )
|
|
// }
|
|
// }
|
|
}
|
|
}
|