266 lines
8.9 KiB
JavaScript
266 lines
8.9 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: new Date().toISOString().substr(0, 10),
|
|
edate: null,
|
|
|
|
search_status:0,
|
|
search_error_message:'',
|
|
search_dialog_is_active: false,
|
|
selected_status_validasi: { code: 'ALL' , name : 'Semua Hasil'},
|
|
|
|
patients: [],
|
|
total_patient: 0,
|
|
total_patient_page: 0,
|
|
curr_patient_page: 1,
|
|
selected_patient: { },
|
|
validation_note: '',
|
|
validation_note_internal: '',
|
|
|
|
|
|
// PX
|
|
total_px: 0,
|
|
pxs: [],
|
|
|
|
// Print
|
|
print_dialog: false,
|
|
rpt_url: '',
|
|
|
|
dialog_req: false,
|
|
dialog_note: false,
|
|
info_req: {req_fo:[],req_spec_col:[],req_spec_ver:[],req_samp_ver:[],req_pre_an:[]},
|
|
dialog_confirm_local: false,
|
|
waiting_progress: false,
|
|
test_refers: [],
|
|
error_message: '',
|
|
dialog_success: false,
|
|
dialog_error: false,
|
|
dialog_confirm_local: false,
|
|
},
|
|
mutations: {
|
|
update_dialog_confirm_local(state,status) {
|
|
state.dialog_confirm_local = status
|
|
},
|
|
update_waiting_progress(state,status) {
|
|
state.waiting_progress = status
|
|
},
|
|
update_test_refers(state,data) {
|
|
state.test_refers = data
|
|
},
|
|
update_error_message(state,data) {
|
|
state.error_message = data
|
|
},
|
|
update_dialog_success(state,status) {
|
|
state.dialog_success = status
|
|
},
|
|
update_dialog_error(state,status) {
|
|
state.dialog_error = status
|
|
},
|
|
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_validation_note(state,val) {
|
|
state.validation_note=val
|
|
},
|
|
update_validation_note_internal(state,val) {
|
|
state.validation_note_internal=val
|
|
},
|
|
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_selected_status_validasi(state,val) {
|
|
state.selected_status_validasi=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
|
|
},
|
|
|
|
update_print_dialog(state, v) {
|
|
state.print_dialog = v
|
|
},
|
|
|
|
update_rpt_url(state, v) {
|
|
let user = window.one_user()
|
|
state.rpt_url = '/birt/frameset?__report=report/onelab/lab/rpt_test_not_print_val.rptdesign&__format=pdf&username=' + user.M_UserUsername + '&PID=' + v + '&ts='+Math.floor(Date.now() / 1000)
|
|
},
|
|
|
|
update_info_req(state, v) {
|
|
state.info_req = v
|
|
},
|
|
|
|
update_dialog_req(state, v) {
|
|
state.dialog_req = v
|
|
},
|
|
|
|
update_dialog_note(state, v) {
|
|
state.dialog_note= v
|
|
}
|
|
},
|
|
actions: {
|
|
async save_note(context) {
|
|
let resp = await api.save_note(one_token(), context.state.selected_patient.T_OrderHeaderID,
|
|
context.state.validation_note,context.state.validation_note_internal)
|
|
if (resp.staus != 'OK' ) {
|
|
return false
|
|
} else {
|
|
return true
|
|
}
|
|
},
|
|
async send_to_adm(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp = await api.send_to_adm(one_token(), context.state.selected_patient.T_OrderHeaderID)
|
|
let patients = context.state.patients
|
|
let patient = context.state.selected_patient
|
|
patient.T_OrderHeaderAddOnReadyPrint = 'P'
|
|
context.commit('update_selected_patient',patient)
|
|
let idx = _.findIndex(patients, { 'T_OrderHeaderID' : patient.T_OrderHeaderID } )
|
|
if (idx > -1 ) {
|
|
patients[idx].T_OrderHeaderAddOnReadyPrint = 'P'
|
|
let data = {
|
|
records: patients,
|
|
total_patient_page : conext.state.total_patient_page,
|
|
total_patient : context.state.total_patient
|
|
}
|
|
context.commit("update_patients", patients)
|
|
}
|
|
context.commit("update_search_status", 0)
|
|
} catch(e) {
|
|
context.commit("update_search_status", 3)
|
|
}
|
|
},
|
|
async search(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let inp_no = context.state.search
|
|
let company_id = 0
|
|
if (context.rootState.company.company)
|
|
company_id = context.rootState.company.company.CorporateID
|
|
let resp= await api.search(one_token(), context.state.sdate, inp_no , context.state.curr_patient_page, company_id,
|
|
context.state.selected_status_validasi.code)
|
|
|
|
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)
|
|
|
|
if (data.records.length < 1) {
|
|
context.commit('update_selected_patient', null)
|
|
context.commit('re_px/update_pxs', [], {root:true})
|
|
}
|
|
else {
|
|
context.commit('update_selected_patient', data.records[0])
|
|
context.commit('re_px/update_id', data.records[0].T_OrderHeaderID, {root:true})
|
|
context.dispatch('re_px/search', null, {root:true})
|
|
|
|
context.dispatch('info_req')
|
|
}
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async info_req(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp= await api.info_req(one_token(), context.state.selected_patient.T_OrderHeaderID)
|
|
|
|
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","")
|
|
context.commit("update_validation_note", resp.data.validation_note)
|
|
context.commit("update_validation_note_internal", resp.data.validation_internal)
|
|
context.commit('update_info_req', resp.data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status", 3)
|
|
context.commit("update_search_error_message", e.message )
|
|
}
|
|
},
|
|
async uploadCpone(context) {
|
|
context.commit("update_waiting_progress", true)
|
|
try{
|
|
let prm = context.state.selected_patient
|
|
prm.token = one_token()
|
|
let resp = await api.uploadCpone(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_waiting_progress", false)
|
|
context.commit("update_error_message", resp.message)
|
|
context.commit("update_dialog_error", true)
|
|
} else {
|
|
context.commit("update_waiting_progress", false)
|
|
context.commit("update_dialog_success", true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_waiting_progress", false)
|
|
context.commit("update_error_message", e.message)
|
|
context.commit("update_dialog_error", true)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|