Flatten nested repos
This commit is contained in:
434
test/vuex/one-fo-registration-future/modules/order.js
Normal file
434
test/vuex/one-fo-registration-future/modules/order.js
Normal file
@@ -0,0 +1,434 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/order.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
order_id: 0,
|
||||
queue: "",
|
||||
is_from_clinic: false,
|
||||
|
||||
catatan_fo:'',
|
||||
diagnosa:'',
|
||||
patient_note: '',
|
||||
|
||||
finish_dialog_is_active: false,
|
||||
current_order: {},
|
||||
|
||||
received_sample: {flag:"N",time:""},
|
||||
|
||||
tabs : [
|
||||
{"label":"DEMOGRAFI", "icon":"opacity", "code":"01", "enabled":true},
|
||||
{"label":"PEMERIKSAAN", "icon":"verified_user", "code":"02", "enabled":true},
|
||||
{"label":"PEMBAYARAN", "icon":"motorcycle", "code":"03", "enabled":false}
|
||||
],
|
||||
|
||||
print_dialog_is_active: false,
|
||||
rpt_url: window.BASE_URL + '/one-ui/test/vuex/common/under-cons.pdf',
|
||||
dialog_start:true,
|
||||
status_start:'Y',
|
||||
time_start:undefined,
|
||||
elapsedTime:0,
|
||||
show_time:null,
|
||||
loading_process:false,
|
||||
booking_date:''
|
||||
},
|
||||
mutations: {
|
||||
update_booking_date(state,val) {
|
||||
state.booking_date=val
|
||||
},
|
||||
update_loading_process(state,val) {
|
||||
state.loading_process=val
|
||||
},
|
||||
update_show_time(state,val) {
|
||||
state.show_time=val
|
||||
},
|
||||
update_elapsedTime(state,val) {
|
||||
state.elapsedTime=val
|
||||
},
|
||||
update_dialog_start(state,val) {
|
||||
state.dialog_start=val
|
||||
},
|
||||
update_status_start(state,val) {
|
||||
state.status_start=val
|
||||
},
|
||||
update_time_start(state,val) {
|
||||
state.time_start=val
|
||||
},
|
||||
update_patient_note(state,val) {
|
||||
state.patient_note=val
|
||||
},
|
||||
update_catatan_fo(state,val) {
|
||||
state.catatan_fo=val
|
||||
},
|
||||
update_diagnosa(state,val) {
|
||||
state.diagnosa=val
|
||||
},
|
||||
update_finish_dialog_is_active(state, val) {
|
||||
state.finish_dialog_is_active = val
|
||||
},
|
||||
update_current_order(state, val) {
|
||||
state.current_order = val
|
||||
},
|
||||
|
||||
update_received_sample(state, val) {
|
||||
state.received_sample = val
|
||||
},
|
||||
|
||||
update_tab_enable(state, v) {
|
||||
state.tabs[v[0]].enabled = v[1]
|
||||
},
|
||||
|
||||
update_from_clinic(state, v) {
|
||||
state.is_from_clinic = v
|
||||
},
|
||||
|
||||
update_queue(state, v) {
|
||||
state.queue = v
|
||||
},
|
||||
|
||||
update_order_id(state, v) {
|
||||
state.order_id = v
|
||||
},
|
||||
|
||||
reset_form(state) {
|
||||
state.order_id = 0
|
||||
state.queue = ""
|
||||
state.is_from_clinic = false
|
||||
state.catatan_fo = ""
|
||||
state.diagnosa = ""
|
||||
state.patient_note = ""
|
||||
},
|
||||
|
||||
update_print_dialog_is_active(state, val) {
|
||||
state.print_dialog_is_active = val
|
||||
},
|
||||
|
||||
update_rpt_url(state, v) {
|
||||
state.rpt_url = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async save(context) {
|
||||
|
||||
var order_id = context.state.order_id;
|
||||
var delivery = [];
|
||||
var delivery_note = [];
|
||||
var detail = [];
|
||||
var req = [];
|
||||
console.log('lang_2')
|
||||
console.log(context.rootState.language.selected_language_2)
|
||||
var header = {
|
||||
booking_date:context.state.booking_date,
|
||||
patient_id: context.rootState.patient.selected_patient.M_PatientID,
|
||||
age: context.rootState.patient.selected_patient.patient_age,
|
||||
alias_doctor: context.rootState.doctor.doctor_alias,
|
||||
alias_doctor_address: context.rootState.doctor.doctor_alias_address,
|
||||
sender_doctor_id: context.rootState.doctor.selected_doctor.M_DoctorID,
|
||||
sender_address_id: context.rootState.doctor.selected_address.M_DoctorAddressID,
|
||||
pj_doctor_id: context.rootState.doctor.selected_doctor_pj.M_DoctorID,
|
||||
lang_id: context.rootState.language.selected_language.id,
|
||||
lang_si: context.rootState.language.selected_language.is_si,
|
||||
lang_id_2: context.rootState.language.selected_language_2 ? context.rootState.language.selected_language_2.id : 0,
|
||||
lang_si_2: context.rootState.language.selected_language_2 ? context.rootState.language.selected_language_2.is_si : "N",
|
||||
doctor_note: "",
|
||||
fo_note: context.state.catatan_fo,
|
||||
patient_note: context.state.patient_note,
|
||||
company_id: context.rootState.company.selected_company.M_CompanyID,
|
||||
mou_id: context.rootState.company.selected_mou.M_MouID,
|
||||
received_sample: context.rootState.order.received_sample.flag ?context.rootState.order.received_sample.flag:"N",
|
||||
received_sample_time: context.rootState.order.received_sample.time,
|
||||
queue: context.state.queue,
|
||||
diagnose: context.state.diagnosa,
|
||||
is_cito: context.rootState.px.is_cito,
|
||||
cito_id: context.rootState.px.selected_cito ? context.rootState.px.selected_cito.Nat_CitoID : 0,
|
||||
mcu_pre_id:order_id
|
||||
};
|
||||
|
||||
let xxdlv = context.rootState.delivery.data_deliveries
|
||||
let xdlv = _.filter(xxdlv, function(o) { return o.chex === 'Y' })
|
||||
let dlv = _.filter(xdlv, function(o) { return o.typeform === 'origin' })
|
||||
delivery_note = _.filter(xdlv, function(o) { return o.typeform === 'additional' })
|
||||
|
||||
dlv.forEach(function(value){
|
||||
delivery.push({
|
||||
delivery_id:value.delivery_id,
|
||||
delivery_code:value.delivery_code,
|
||||
delivery_type_id:value.delivery_type,
|
||||
address_id:value.address_id,
|
||||
note:value.description,
|
||||
noteplus:value.note,
|
||||
kelurahan:value.kelurahan
|
||||
})
|
||||
})
|
||||
|
||||
var px_tmp = [];
|
||||
var st = context.rootState.px.selected_test;
|
||||
for (let i in st) {
|
||||
let x = {
|
||||
t_id: st[i]['T_TestID'],
|
||||
t_price: st[i]['T_PriceAmount'],
|
||||
t_disc: st[i]['T_PriceDisc'],
|
||||
t_discrp: st[i]['T_PriceDiscRp'],
|
||||
t_cito: st[i]['T_TestIsCito'],
|
||||
t_req: 'N',
|
||||
t_reqnote: '',
|
||||
t_ispacket: st[i]['is_packet'],
|
||||
t_packetid: st[i]['packet_id'],
|
||||
t_packettype: st[i]['px_type']
|
||||
}
|
||||
|
||||
let rq = context.rootState.px.requirement
|
||||
for (let j in rq) {
|
||||
if (rq[j].label == st[i].T_TestRequirement) {
|
||||
x.t_req = (rq[j].checked ? 'Y' : 'N')
|
||||
x.t_reqnote = rq[j].note
|
||||
}
|
||||
}
|
||||
|
||||
px_tmp.push(x)
|
||||
}
|
||||
|
||||
detail = px_tmp;
|
||||
|
||||
// let _req = context.rootState.px.requirement
|
||||
// for (let _i in _req) {
|
||||
// req.push({req_id:_req[_i].req_id, req_label:_req[_i].label, checked:(_req[_i].checked?"Y":"N"), note:_req[_i].note, px_id:_req[_i].px_id})
|
||||
// }
|
||||
let req_status = context.rootState.px.req_status
|
||||
req = {
|
||||
status : req_status,
|
||||
reqs : req_status == 'Y' ? [] : context.rootState.px.reqs
|
||||
}
|
||||
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.save(one_token(), order_id, header, delivery, delivery_note, detail, req)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
// Dialog loading
|
||||
context.commit('update_loading_process', false)
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
|
||||
context.commit("update_current_order", resp.data.data)
|
||||
context.commit('update_finish_dialog_is_active', true)
|
||||
|
||||
context.commit('payment/update_order_id', resp.data.data.id, {root:true})
|
||||
context.commit("payment/update_order", resp.data,{root:true})
|
||||
//context.dispatch('payment/get_order', resp.data.data.id, {root:true})
|
||||
|
||||
// store.commit('change_tab', '03');
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async load_from_clinic(context) {
|
||||
let queue = context.state.queue;
|
||||
|
||||
try {
|
||||
let resp= await api.load_from_clinic(queue)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
if (resp.data.status != "OK") {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let data = resp.data.data
|
||||
context.commit('update_from_clinic', true)
|
||||
|
||||
context.commit('patient/update_selected_patient', data.patient, {root:true})
|
||||
context.commit('doctor/update_doctors', {records:[data.doctor], total:1}, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', data.doctor, {root:true})
|
||||
context.commit('doctor/update_search', data.doctor.search, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.commit('delivery/update_params', {p_id:data.patient.M_PatientID}, {root:true})
|
||||
context.commit('delivery/update_params', {d_id:data.doctor.M_DoctorID}, {root:true})
|
||||
|
||||
|
||||
// Company
|
||||
let search = data.company.search
|
||||
delete(data.company.search)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_companies', {records:[data.company], total:1}, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_search', search, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_selected_company', data.company, {root:true}) }, 0)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_selected_mou', data.company.mou[0], {root:true}) }, 0)
|
||||
// setTimeout(function() { context.commit('company/selected_xx', data.company.mou[0], {root:true}) }, 0)
|
||||
|
||||
// PX
|
||||
// context.commit("px/update_selected_test", data.test, {root:true})
|
||||
// context.commit("px/update_requirement", data.req, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.dispatch('delivery/search', null, {root:true})
|
||||
|
||||
// PX
|
||||
context.dispatch('px/search_pxs_clinic', data.order_id, {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async load(context) {
|
||||
let id = context.state.order_id;
|
||||
|
||||
try {
|
||||
let resp = await api.load(id)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
if (resp.data.status != "OK") {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = resp.data.data
|
||||
|
||||
|
||||
|
||||
context.commit('patient/update_selected_patient', data.patient, {root:true})
|
||||
context.commit('doctor/update_doctors', {records:[data.doctor], total:1}, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', data.doctor, {root:true})
|
||||
context.commit('doctor/update_search', data.doctor.search, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.commit('delivery/update_params', {p_id:data.patient.M_PatientID}, {root:true})
|
||||
context.commit('delivery/update_params', {d_id:data.doctor.M_DoctorID}, {root:true})
|
||||
|
||||
|
||||
// Company
|
||||
let search = data.company.search
|
||||
delete(data.company.search)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_companies', {records:[data.company], total:1}, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_search', search, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_selected_company', data.company, {root:true}) }, 0)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_selected_mou', data.company.mou[0], {root:true}) }, 0)
|
||||
// setTimeout(function() { context.commit('company/selected_xx', data.company.mou[0], {root:true}) }, 0)
|
||||
|
||||
context.commit('update_received_sample', data.order.rec_sample);
|
||||
|
||||
// PX
|
||||
context.commit("px/update_selected_test", data.test, {root:true})
|
||||
context.commit("px/update_requirement", data.req, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.dispatch('delivery/search', null, {root:true})
|
||||
|
||||
// Enable tab
|
||||
context.commit('update_tab_enable', [2, true])
|
||||
|
||||
setTimeout(function() {
|
||||
context.commit('update_from_clinic', false)
|
||||
}, 15000)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async reset_form(context) {
|
||||
context.commit("reset_form")
|
||||
context.commit("patient/update_selected_patient", {}, {root:true})
|
||||
context.commit("doctor/update_doctors", {records:[], total:0}, {root:true})
|
||||
context.commit("doctor/update_selected_doctor", {}, {root:true})
|
||||
context.commit("doctor/update_selected_doctor_pj", {}, {root:true})
|
||||
|
||||
// context.commit("delivery/update_deliveries", [], {root:true})
|
||||
// context.commit("delivery/update_selected_delivery", {}, {root:true})
|
||||
context.commit("delivery/update_params", {p_id:0, d_id:0, o_id:0}, {root:true})
|
||||
context.dispatch("delivery/search", null, {root:true})
|
||||
|
||||
context.commit("px/update_selected_test", [], {root:true})
|
||||
context.commit("px/update_requirement", [], {root:true})
|
||||
|
||||
// Company
|
||||
context.commit("company/reset_company")
|
||||
},
|
||||
async load_preregister(context,prm) {
|
||||
//context.commit("update_search_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.load_preregister(prm)
|
||||
//alert("dasdasd")
|
||||
// console.log(resp)
|
||||
|
||||
// context.commit("update_search_status",2)
|
||||
// context.commit("update_search_error_message","")
|
||||
// alert("aaaaaaaaaaaaaa")
|
||||
//console.log("dasdasdasd")
|
||||
let data = {
|
||||
records : resp.data.records
|
||||
}
|
||||
console.log(resp)
|
||||
var rst = resp.data.data.records
|
||||
console.log(rst)
|
||||
context.commit('patient/update_selected_patient', rst['patient'], {root:true})
|
||||
let doctors = []
|
||||
doctors.push(rst['selected_doctor'])
|
||||
console.log(doctors)
|
||||
context.commit('doctor/update_doctors', {records:doctors,total:doctors.length}, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', doctors[0], {root:true})
|
||||
context.commit('doctor/update_selected_address', rst['selected_address'], {root:true})
|
||||
console.log(rst['companies'])
|
||||
context.commit('company/update_companies', {records:rst['companies'],total:1}, {root:true})
|
||||
console.log(context.rootState.company.companies)
|
||||
context.commit('company/update_selected_company', rst['selected_company'], {root:true})
|
||||
context.commit('company/update_selected_mou', rst['selected_mou'], {root:true})
|
||||
context.commit('delivery/update_data_deliveries', rst['data_deliveries'], {root:true})
|
||||
//context.commit('history/update_history_dialog',false,{root:true})
|
||||
context.dispatch('px/search',{}, {root:true})
|
||||
|
||||
|
||||
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async get_time_start(context, prm) {
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.get_time_start(prm)
|
||||
if (resp.data.status != "OK") {
|
||||
|
||||
} else {
|
||||
context.commit('update_dialog_start',false)
|
||||
context.commit('update_show_time', resp.data.data.records)
|
||||
context.commit('update_status_start','Y')
|
||||
if(prm.pre_id){
|
||||
context.dispatch("load_preregister",{id:context.state.order_id})
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user