Flatten nested repos
This commit is contained in:
176
test/vuex/one-mcu-registration/modules/area.js
Normal file
176
test/vuex/one-mcu-registration/modules/area.js
Normal file
@@ -0,0 +1,176 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/area.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
|
||||
provinces: [],
|
||||
cities: [],
|
||||
districts: [],
|
||||
villages: [],
|
||||
|
||||
total_provinces: 0,
|
||||
total_cities: 0,
|
||||
total_districts: 0,
|
||||
total_villages: 0,
|
||||
|
||||
total_display: 0,
|
||||
|
||||
selected_province: {},
|
||||
selected_city: {},
|
||||
selected_district: {},
|
||||
selected_village: {}
|
||||
},
|
||||
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_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_area(state, data) {
|
||||
state[data.type] = data.records
|
||||
state['total_'+data.type] = data.total
|
||||
state.total_display = data.total_display
|
||||
|
||||
for (let i in data.records) {
|
||||
if (data.records[i].is_default == "Y") {
|
||||
|
||||
if (["provinces", "districts", "villages"].indexOf(data.type) > -1)
|
||||
state['selected_'+ data.type.substring(0, data.type.length-1) ] = data.records[i]
|
||||
|
||||
else if (data.type == "cities")
|
||||
state['selected_city'] = data.records[i]
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
update_selected_area(state, val) {
|
||||
state['selected_'+val.type] = val.val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_province(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp = await api.search_province(context.state.search)
|
||||
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_display: resp.data.total_display,
|
||||
type: 'provinces'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.dispatch("search_city")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_city(context) {
|
||||
// City
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp = await api.search_city(context.state.selected_province.M_ProvinceID, context.state.search)
|
||||
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_display: resp.data.total_display,
|
||||
type: 'cities'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.commit("update_search_status", 1)
|
||||
context.dispatch("search_district")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_district(context) {
|
||||
// City
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp = await api.search_district(context.state.selected_city.M_CityID, context.state.search)
|
||||
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_display: resp.data.total_display,
|
||||
type: 'districts'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.commit("update_search_status", 1)
|
||||
context.dispatch("search_kelurahan")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_kelurahan(context) {
|
||||
// City
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp = await api.search_kelurahan(context.state.selected_district.M_DistrictID, context.state.search)
|
||||
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_display: resp.data.total_display,
|
||||
type: 'villages'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.commit("update_search_status", 1)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
107
test/vuex/one-mcu-registration/modules/company.js
Normal file
107
test/vuex/one-mcu-registration/modules/company.js
Normal file
@@ -0,0 +1,107 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/company.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
companies: [],
|
||||
total_company: 0,
|
||||
selected_company: {},
|
||||
selected_mou: {},
|
||||
|
||||
selected_px_tab: 'px'
|
||||
},
|
||||
mutations: {
|
||||
update_selected_px_tab(state,tab) {
|
||||
state.selected_px_tab = tab
|
||||
},
|
||||
|
||||
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_selected_mou(state,val) {
|
||||
state.selected_mou = val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_companies(state,data) {
|
||||
state.companies= data.records
|
||||
state.total_company= data.total
|
||||
},
|
||||
update_selected_company(state,val) {
|
||||
state.selected_company=val
|
||||
},
|
||||
|
||||
reset_company(state) {
|
||||
state.companies = []
|
||||
state.total_company = 0
|
||||
state.search = ""
|
||||
state.selected_company = {}
|
||||
state.selected_mou = {}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.search)
|
||||
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_companies",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_default(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_default()
|
||||
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_companies", data)
|
||||
context.commit("update_selected_company", data.records[0])
|
||||
|
||||
for(let i in data.records[0].mou) {
|
||||
if (data.records[0].mou[i].M_MouIsDefault == "Y")
|
||||
context.commit("update_selected_mou", data.records[0].mou[i])
|
||||
}
|
||||
|
||||
// search px
|
||||
context.dispatch('px/search', null, {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
test/vuex/one-mcu-registration/modules/delivery.js
Normal file
87
test/vuex/one-mcu-registration/modules/delivery.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/delivery.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
deliveries: [],
|
||||
patient_id: 0,
|
||||
doctor_id: 0,
|
||||
order_id: 0,
|
||||
|
||||
checked_id: []
|
||||
},
|
||||
mutations: {
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_deliveries(state,data) {
|
||||
for (var i in data) {
|
||||
if (state.checked_id.indexOf(data[i].idx) > -1)
|
||||
data[i].selected = true
|
||||
else
|
||||
data[i].selected = false
|
||||
}
|
||||
|
||||
state.deliveries = data
|
||||
},
|
||||
update_deliveries_2(state) {
|
||||
for (var i in state.deliveries) {
|
||||
if (state.checked_id.indexOf(state.deliveries[i].idx) > -1)
|
||||
state.deliveries[i].selected = true
|
||||
else
|
||||
state.deliveries[i].selected = false
|
||||
}
|
||||
// state.deliveries= data
|
||||
},
|
||||
update_selected_delivery(state,val) {
|
||||
state.selected_delivery=val
|
||||
},
|
||||
update_params(state, val) {
|
||||
if (typeof val.p_id !== 'undefined')
|
||||
state.patient_id = val.p_id;
|
||||
if (typeof val.o_id !== 'undefined')
|
||||
state.order_id = val.o_id;
|
||||
if (typeof val.d_id !== 'undefined')
|
||||
state.doctor_id = val.d_id;
|
||||
},
|
||||
update_checked_id(state, val) {
|
||||
state.checked_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(store.state.delivery.order_id,
|
||||
store.state.delivery.patient_id,
|
||||
store.state.delivery.doctor_id,
|
||||
context.rootState.company.selected_company.M_CompanyID)
|
||||
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
|
||||
}
|
||||
context.commit("update_deliveries",data.records)
|
||||
var deliveries = data.records
|
||||
context.commit("update_checked_id",deliveries[0].idx)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
140
test/vuex/one-mcu-registration/modules/doctor.js
Normal file
140
test/vuex/one-mcu-registration/modules/doctor.js
Normal file
@@ -0,0 +1,140 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/doctor.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
doctors: [],
|
||||
total_doctor: 0,
|
||||
selected_doctor: {},
|
||||
selected_address: {},
|
||||
|
||||
doctors_pj: [],
|
||||
selected_doctor_pj : {},
|
||||
search_pj_status: 0,
|
||||
search_pj_error_message: "",
|
||||
|
||||
mounted: 0
|
||||
},
|
||||
mutations: {
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_doctors(state,data) {
|
||||
state.doctors = data.records
|
||||
state.total_doctor= data.total
|
||||
},
|
||||
update_selected_doctor(state,doc) {
|
||||
state.selected_doctor= doc
|
||||
|
||||
if (!doc) return
|
||||
state.selected_address = {}
|
||||
|
||||
if (doc.address)
|
||||
if (doc.address.length> 0) {
|
||||
state.selected_address = doc.address[0]
|
||||
}
|
||||
},
|
||||
update_selected_address(state,addr) {
|
||||
state.selected_address = addr
|
||||
},
|
||||
update_search_pj_error_message(state,status) {
|
||||
state.search_pj_error_message = status
|
||||
},
|
||||
update_search_pj_status(state,status) {
|
||||
state.search_pj_status = status
|
||||
},
|
||||
update_doctors_pj(state,data) {
|
||||
state.doctors_pj = data.records
|
||||
let flag_found = false
|
||||
data.records.forEach(function(d) {
|
||||
if (d.M_DoctorIsDefaultPJ == 'Y' ) {
|
||||
state.selected_doctor_pj = d
|
||||
flag_found = true
|
||||
}
|
||||
})
|
||||
if (! flag_found & data.records.length > 0 ) state.selected_doctor_pj = data.records[0]
|
||||
},
|
||||
update_selected_doctor_pj(state,doc) {
|
||||
state.selected_doctor_pj = doc
|
||||
},
|
||||
|
||||
increment_mounted(state, n) {
|
||||
state.mounted = state.mounted + n;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_pj(context) {
|
||||
context.commit("update_search_pj_status",1)
|
||||
try {
|
||||
let resp= await api.searchPj()
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_pj_status",3)
|
||||
context.commit("update_search_pj_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_pj_status",2)
|
||||
context.commit("update_search_pj_error_message","")
|
||||
let data = {
|
||||
total : resp.data.total,
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_doctors_pj",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_pj_status",3)
|
||||
context.commit("update_search_pj_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.search)
|
||||
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 = {
|
||||
total : resp.data.total,
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_doctors",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async statussaved(context,prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.statussaved(prm)
|
||||
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","")
|
||||
|
||||
window.location = '/one-ui/test/vuex/one-mcu-pre-register/'
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
test/vuex/one-mcu-registration/modules/history.js
Normal file
69
test/vuex/one-mcu-registration/modules/history.js
Normal file
@@ -0,0 +1,69 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/history.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
noreg:'',
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
histories: [],
|
||||
|
||||
history_dialog: false
|
||||
},
|
||||
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_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_histories(state, data) {
|
||||
state.histories = data.records
|
||||
},
|
||||
|
||||
update_history_dialog(state, v) {
|
||||
state.history_dialog = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp = await api.search(context.rootState.patient.selected_patient.M_PatientID)
|
||||
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
|
||||
}
|
||||
context.commit("update_histories", data)
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
test/vuex/one-mcu-registration/modules/language.js
Normal file
51
test/vuex/one-mcu-registration/modules/language.js
Normal file
@@ -0,0 +1,51 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/language.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
languages: [],
|
||||
selected_language: {},
|
||||
},
|
||||
mutations: {
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_languages(state,data) {
|
||||
state.languages= data.records
|
||||
if (data.records.length > 0) state.selected_language = data.records[0]
|
||||
},
|
||||
update_selected_language(state,val) {
|
||||
state.selected_language=val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search()
|
||||
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
|
||||
}
|
||||
context.commit("update_languages",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
322
test/vuex/one-mcu-registration/modules/order.js
Normal file
322
test/vuex/one-mcu-registration/modules/order.js
Normal file
@@ -0,0 +1,322 @@
|
||||
// 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: 'N',
|
||||
|
||||
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'
|
||||
},
|
||||
mutations: {
|
||||
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 detail = [];
|
||||
var req = [];
|
||||
var header = {
|
||||
patient_id: context.rootState.patient.selected_patient.M_PatientID,
|
||||
age: context.rootState.patient.selected_patient.patient_age,
|
||||
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,
|
||||
doctor_note: "",
|
||||
fo_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,
|
||||
queue: context.state.queue,
|
||||
diagnose: context.state.diagnosa
|
||||
};
|
||||
|
||||
let dlv = context.rootState.delivery.deliveries
|
||||
for (var i in dlv) {
|
||||
if (dlv[i].selected == true) {
|
||||
let e = dlv[i].idx.split('-')
|
||||
delivery.push({
|
||||
delivery_id:e[0],
|
||||
delivery_type_id:e[1],
|
||||
address_id:e[2],
|
||||
note:dlv[i].note
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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, detail, req)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
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.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})
|
||||
}
|
||||
} 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
73
test/vuex/one-mcu-registration/modules/other.js
Normal file
73
test/vuex/one-mcu-registration/modules/other.js
Normal file
@@ -0,0 +1,73 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/other.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
|
||||
sex: [],
|
||||
total_sex: 0,
|
||||
selected_sex: {},
|
||||
|
||||
title: [],
|
||||
total_title: 0,
|
||||
selected_title: {},
|
||||
|
||||
mounted: 0
|
||||
},
|
||||
mutations: {
|
||||
update_search(state, val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_sex(state, data) {
|
||||
state.sex = data.records
|
||||
state.total_sex = data.total
|
||||
},
|
||||
update_selected_sex(state, doc) {
|
||||
state.selected_sex = doc
|
||||
if (doc.title) {
|
||||
state.title = doc.title
|
||||
} else {
|
||||
state.title = []
|
||||
}
|
||||
},
|
||||
update_selected_title(state, doc) {
|
||||
state.selected_title = doc
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
||||
async search_sex(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_sex(context.state.search)
|
||||
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 = {
|
||||
total : resp.data.total,
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_sex", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
228
test/vuex/one-mcu-registration/modules/patient.js
Normal file
228
test/vuex/one-mcu-registration/modules/patient.js
Normal file
@@ -0,0 +1,228 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patient.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
noreg:'',
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
total_display: 0,
|
||||
selected_patient: {},
|
||||
|
||||
patient_new: {},
|
||||
patient_new_dialog_is_active: false,
|
||||
|
||||
idtypes: [],
|
||||
selected_idtype: {}
|
||||
},
|
||||
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_noreg(state,val) {
|
||||
state.noreg=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=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_display = data.total_display
|
||||
},
|
||||
update_selected_patient(state,val) {
|
||||
var now = moment(new Date())
|
||||
var dob = moment(new Date(val.M_PatientDOB))
|
||||
var year = now.diff(dob,'years')
|
||||
dob.add(year,'years')
|
||||
var month = now.diff(dob,'months')
|
||||
dob.add(month,'months')
|
||||
var day = now.diff(dob,'days')
|
||||
if (isNaN(year)) val.patient_age = ''
|
||||
else val.patient_age = `${year} tahun ${month} bulan ${day} hari`
|
||||
|
||||
state.selected_patient=val
|
||||
// store.state.patientaddress.patient_id = val.M_PatientID
|
||||
|
||||
// photo
|
||||
|
||||
},
|
||||
|
||||
update_patient_new(state, v) {
|
||||
state.patient_new = v
|
||||
},
|
||||
|
||||
update_patient_new_dialog_is_active(state, v) {
|
||||
state.patient_new_dialog_is_active = v
|
||||
},
|
||||
|
||||
update_idtypes(state, v) {
|
||||
state.idtypes = v.records
|
||||
},
|
||||
|
||||
update_selected_idtype(state, v) {
|
||||
state.selected_idtype = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.noreg,context.state.search)
|
||||
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_display: resp.data.total_display
|
||||
}
|
||||
context.commit("update_patients",data)
|
||||
|
||||
if (prm)
|
||||
if (prm.use) {
|
||||
let pat = context.state.patients[prm.use_idx]
|
||||
context.commit('update_selected_patient', pat)
|
||||
context.commit('delivery/update_params', {p_id:pat.M_PatientID}, { root: true })
|
||||
context.dispatch('delivery/search', null, { root: true })
|
||||
|
||||
context.commit('photo/update_patient_id', pat.M_PatientID, {root: true})
|
||||
}
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async add_new(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let resp= await api.add_new(prm)
|
||||
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","")
|
||||
|
||||
if (prm.use) {
|
||||
context.commit('update_noreg', resp.data.noreg)
|
||||
context.commit('update_search', '')
|
||||
|
||||
context.dispatch('search', {use:true, use_idx:0})
|
||||
}
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_idtype(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_idtype()
|
||||
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
|
||||
}
|
||||
|
||||
context.commit("update_idtypes", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async getinitialpatient(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
var prm = {token:one_token()}
|
||||
let resp= await api.getinitialpatient(prm)
|
||||
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
|
||||
}
|
||||
|
||||
//context.commit("update_idtypes", data)
|
||||
var pat = data.records[0]
|
||||
context.commit('update_selected_patient', pat)
|
||||
//context.commit('patient/update_search_dialog_is_active',false)
|
||||
|
||||
context.commit('order/update_patient_note', "",{root:true})
|
||||
let datacompany = {'records':pat.companies,total:pat.companies.length}
|
||||
context.commit('company/update_companies',datacompany,{root:true})
|
||||
context.commit('company/update_selected_company',pat.companies[0],{root:true})
|
||||
context.commit('company/update_selected_mou',pat.companies[0].mou[0],{root:true})
|
||||
context.commit('px/update_exist_selected_test', pat.xtests,{root:true})
|
||||
context.dispatch("px/search","",{root:true})
|
||||
|
||||
if (pat && pat.M_PatientNote )
|
||||
context.commit('order/update_patient_note', pat.M_PatientNote,{root:true})
|
||||
context.commit('order/update_catatan_fo', "",{root:true})
|
||||
|
||||
context.commit('patientaddress/testx', pat.M_PatientID,{root:true});
|
||||
context.dispatch('patientaddress/search','',{root:true})
|
||||
|
||||
context.commit('delivery/update_params', {p_id:pat.M_PatientID},{root:true})
|
||||
context.dispatch('delivery/search','',{root:true})
|
||||
|
||||
// clear search
|
||||
context.commit('update_search', '')
|
||||
|
||||
// Clear delivery
|
||||
context.commit('delivery/update_checked_id', [],{root:true})
|
||||
|
||||
// Photo module
|
||||
context.commit('photo/update_patient_id', pat.M_PatientID,{root:true})
|
||||
if (pat.M_PatientPhoto == null || pat.M_PatientPhoto == "")
|
||||
context.commit('photo/update_photo_url', 'https://www.sgm-inc.com/wp-content/uploads/2014/06/no-profile-male-img.gif',{root:true})
|
||||
else
|
||||
context.commit('photo/update_photo_url', pat.M_PatientPhoto + "?r=" + Math.round(Math.random() * 1000000000),{root:true})
|
||||
|
||||
// HISTORIES
|
||||
context.dispatch('history/search','',{root:true})
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
test/vuex/one-mcu-registration/modules/patientaddress.js
Normal file
86
test/vuex/one-mcu-registration/modules/patientaddress.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patientaddress.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
noreg:'',
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
total_display: 0,
|
||||
selected_patient: {},
|
||||
|
||||
address: [],
|
||||
patient_id: 0
|
||||
},
|
||||
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_noreg(state,val) {
|
||||
state.noreg=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=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_display = data.total_display
|
||||
},
|
||||
update_selected_patient(state,val) {
|
||||
state.selected_patient=val
|
||||
},
|
||||
|
||||
update_address(state, val) {
|
||||
state.address = val;
|
||||
},
|
||||
|
||||
testx(state, val) {
|
||||
state.patient_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context,prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.getAll(context.state.patient_id)
|
||||
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 = resp.data;
|
||||
context.commit("update_address",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async loadAddress(context, prm) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
tests (a) {
|
||||
alert(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
241
test/vuex/one-mcu-registration/modules/payment.js
Normal file
241
test/vuex/one-mcu-registration/modules/payment.js
Normal file
@@ -0,0 +1,241 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/payment.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
order_id: 0,
|
||||
|
||||
selected_patient: {
|
||||
order_no: '-',
|
||||
order_date: '-',
|
||||
order_mou: '-',
|
||||
order_company: '-',
|
||||
patient_name: '-',
|
||||
patient_mr: '-',
|
||||
doctor_sender: '-',
|
||||
doctor_sender_address: '-',
|
||||
doctor_pj: '-'
|
||||
},
|
||||
|
||||
order_detail: [
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
],
|
||||
order_delivery: [],
|
||||
|
||||
order_subtotal: 0,
|
||||
order_rounding: 0,
|
||||
order_total: 0,
|
||||
order_company: {
|
||||
is_bill: "N",
|
||||
min_dp: 0,
|
||||
min_dp_rp: 0,
|
||||
on_hold: "N",
|
||||
on_hold_text: ""
|
||||
},
|
||||
|
||||
payment_cash_amount: 0,
|
||||
payment_debit_amount: 0,
|
||||
payment_credit_amount: 0,
|
||||
|
||||
payments: [],
|
||||
payment_total: 0,
|
||||
|
||||
payment_id: 0,
|
||||
payment_number: '',
|
||||
finish_dialog_is_active: false,
|
||||
|
||||
paid: false
|
||||
},
|
||||
mutations: {
|
||||
update_order (state, data) {
|
||||
state.selected_patient = data.order_header
|
||||
state.order_detail = data.order_detail
|
||||
state.order_delivery = data.order_delivery
|
||||
|
||||
state.order_subtotal = data.order_header.order_subtotal
|
||||
state.order_rounding = data.order_header.order_rounding
|
||||
state.order_total = data.order_header.order_total
|
||||
|
||||
state.order_company = {
|
||||
is_bill: data.order_header.M_CompanyIsBill,
|
||||
min_dp: data.order_header.M_CompanyMinDP,
|
||||
min_dp_rp: Math.round(data.order_header.M_CompanyMinDP * data.order_header.order_total / 100),
|
||||
on_hold: data.order_header.M_CompanyIsAgingOnHold,
|
||||
on_hold_text: data.order_header.M_CompanyIsAgingOnHoldNote
|
||||
}
|
||||
},
|
||||
|
||||
update_order_id (state, id) {
|
||||
state.order_id = id
|
||||
},
|
||||
|
||||
update_payment(state, o) {
|
||||
if (o.type == 'cash')
|
||||
state.payment_cash_amount = o.amount
|
||||
if (o.type == 'debit')
|
||||
state.payment_debit_amount = o.amount
|
||||
if (o.type == 'credit')
|
||||
state.payment_credit_amount = o.amount
|
||||
},
|
||||
|
||||
update_payments(state, o) {
|
||||
state.payments = o
|
||||
|
||||
// Total payments
|
||||
let total = 0
|
||||
for (let i in o) {
|
||||
o[i].payment_actual = Math.round(o[i].payment_actual)
|
||||
total += o[i].payment_actual
|
||||
}
|
||||
|
||||
state.payment_total = total
|
||||
|
||||
// Calculate change
|
||||
for (let i in o) {
|
||||
o[i].payment_amount = o[i].payment_actual
|
||||
|
||||
if (o[i].payment_type_code == 'CASH') {
|
||||
o[i].payment_change = 0
|
||||
let chg = total - state.order_total;
|
||||
|
||||
if (chg > o[i].payment_actual)
|
||||
chg = o[i].payment_actual
|
||||
if (chg < 0)
|
||||
chg = 0
|
||||
|
||||
o[i].payment_change = chg
|
||||
|
||||
// re-calculate payment amount
|
||||
o[i].payment_amount = o[i].payment_actual - o[i].payment_change
|
||||
state.payment_total -= chg
|
||||
}
|
||||
}
|
||||
|
||||
state.payments = o
|
||||
},
|
||||
|
||||
reset_payment(state) {
|
||||
state.payment_total = 0
|
||||
},
|
||||
|
||||
update_finish_dialog_is_active(state, val) {
|
||||
state.finish_dialog_is_active = val
|
||||
},
|
||||
|
||||
update_payment_number(state, val) {
|
||||
state.payment_number = val
|
||||
},
|
||||
|
||||
update_payment_id(state, val) {
|
||||
state.payment_id = val
|
||||
},
|
||||
|
||||
update_paid(state, val) {
|
||||
state.paid = val
|
||||
},
|
||||
|
||||
update_order_company(state, val) {
|
||||
state.order_company = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async get_order(context, prm) {
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.get_order(prm)
|
||||
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 = resp.data.data
|
||||
context.commit("update_order", data)
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search(context, prm) {
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(prm)
|
||||
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 = resp.data
|
||||
context.commit("update_payments", data)
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async save(context) {
|
||||
var order_id = context.state.order_id;
|
||||
let payments = []
|
||||
let p = context.state.payments
|
||||
for (let i in context.state.payments) {
|
||||
if (Math.round(p[i].payment_amount) == 0)
|
||||
continue;
|
||||
|
||||
payments.push({
|
||||
type: p[i].payment_type_id,
|
||||
amount: p[i].payment_amount,
|
||||
actual: p[i].payment_actual,
|
||||
changes: p[i].payment_change,
|
||||
note: p[i].payment_note
|
||||
})
|
||||
}
|
||||
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.save(one_token(), order_id, payments)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
context.commit('update_payment_number', resp.data.data.payment_number)
|
||||
context.commit('update_payment_id', resp.data.data.payment_id)
|
||||
context.commit('update_finish_dialog_is_active', true)
|
||||
context.commit('update_paid', true)
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async print_nota (context, a) {
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/fo/rpt_t_003.rptdesign&PID='+a+'&username=admin&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_invoice (context, a) {
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&PID='+a+'&username=admin&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_control (context, a) {
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&PID='+a+'&username=admin&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
50
test/vuex/one-mcu-registration/modules/photo.js
Normal file
50
test/vuex/one-mcu-registration/modules/photo.js
Normal file
@@ -0,0 +1,50 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/photo.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
dialog_photo: false,
|
||||
photo_64: '',
|
||||
photo_url: 'https://www.sgm-inc.com/wp-content/uploads/2014/06/no-profile-male-img.gif',
|
||||
default_photo_url: 'https://www.sgm-inc.com/wp-content/uploads/2014/06/no-profile-male-img.gif',
|
||||
patient_id: 0
|
||||
},
|
||||
mutations: {
|
||||
update_dialog_photo (state, v) {
|
||||
state.dialog_photo = v
|
||||
},
|
||||
|
||||
update_photo_64 (state, data) {
|
||||
state.photo_64 = data
|
||||
},
|
||||
|
||||
update_photo_url (state, data) {
|
||||
state.photo_url = data
|
||||
},
|
||||
|
||||
update_patient_id (state, id) {
|
||||
state.patient_id = id
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async upload(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.upload(one_token(), context.state.patient_id, context.state.photo_64)
|
||||
|
||||
if (resp.status != "OK") {
|
||||
|
||||
} else {
|
||||
context.commit('update_photo_url', resp.data.photo_url);
|
||||
context.commit('update_dialog_photo', false)
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
520
test/vuex/one-mcu-registration/modules/px.js
Normal file
520
test/vuex/one-mcu-registration/modules/px.js
Normal file
@@ -0,0 +1,520 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/px.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
tests: [],
|
||||
total_test: 0,
|
||||
selected_test: [],
|
||||
exist_selected_test :[],
|
||||
search_panel: '',
|
||||
search_panel_status:0,
|
||||
panels: [],
|
||||
total_panel: 0,
|
||||
selected_panel: [],
|
||||
requirement: [],
|
||||
appx_schedule: '',
|
||||
|
||||
search_profile: '',
|
||||
profiles: [],
|
||||
total_profile: 0,
|
||||
|
||||
cito: {test:[], panel:[]},
|
||||
nat_test: [],
|
||||
|
||||
req_status: "X",
|
||||
reqs: []
|
||||
},
|
||||
mutations: {
|
||||
update_exist_selected_test(state,val) {
|
||||
state.exist_selected_test = val
|
||||
},
|
||||
update_requirement(state,val) {
|
||||
state.requirement = val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_selected_test(state,val) {
|
||||
// if (state.cito.length > 0) {
|
||||
for (var i in val) {
|
||||
val[i]['T_TestIsCito'] = 'N'
|
||||
if (state.cito.test.indexOf(val[i]['T_TestID']) > -1)
|
||||
val[i]['T_TestIsCito'] = 'Y'
|
||||
}
|
||||
// }
|
||||
|
||||
state.selected_test = val
|
||||
},
|
||||
update_mouCompanyID(state,val) {
|
||||
state.mouCompanyID=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_tests(state,data) {
|
||||
state.tests= data.records
|
||||
state.total_test= data.total
|
||||
},
|
||||
update_search_panel(state,val) {
|
||||
state.search_panel=val
|
||||
},
|
||||
update_search_panel_status(state,status) {
|
||||
state.search_panel_status = status
|
||||
},
|
||||
update_panels(state,data) {
|
||||
state.panels = data.records
|
||||
state.total_panel = data.total
|
||||
},
|
||||
update_selected_panel(state,val) {
|
||||
state.selected_panel= val
|
||||
},
|
||||
|
||||
update_cito(state, val) {
|
||||
let test = state.selected_test
|
||||
let cito = state.cito
|
||||
// if (val.length > 0) {
|
||||
|
||||
for (var i in test) {
|
||||
test[i]['T_TestIsCito'] = 'N'
|
||||
if (val.v.indexOf(test[i]['T_TestID']) > -1)
|
||||
test[i]['T_TestIsCito'] = 'Y'
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
cito[val.t] = val.v
|
||||
console.log(cito)
|
||||
// state.cito = cito
|
||||
state.selected_test = test
|
||||
},
|
||||
|
||||
update_appx_schedule(state, v) {
|
||||
state.appx_schedule = v
|
||||
},
|
||||
|
||||
update_search_profile(state, v) {
|
||||
state.search_profile = v
|
||||
},
|
||||
|
||||
update_profiles(state, data) {
|
||||
state.profiles = data.records
|
||||
state.total_profile = data.total
|
||||
},
|
||||
|
||||
update_nat_test(state) {
|
||||
let px = state.selected_test
|
||||
let nt = []
|
||||
for (let i in px) {
|
||||
for (let j in px[i].nat_test) {
|
||||
nt.push(px[i].nat_test[j])
|
||||
}
|
||||
}
|
||||
|
||||
state.nat_test = nt
|
||||
},
|
||||
|
||||
update_req_status(state, val) {
|
||||
state.req_status = val
|
||||
},
|
||||
|
||||
update_reqs(state, val) {
|
||||
state.reqs = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
delete_px (context, test) {
|
||||
let sel = context.state.selected_test
|
||||
sel.forEach(function(t, idx) {
|
||||
if(t.T_TestID == test.T_TestID && t.px_type == test.px_type) {
|
||||
sel.splice(idx,1)
|
||||
}
|
||||
});
|
||||
|
||||
context.commit("update_selected_test", sel)
|
||||
let tests = context.state.tests
|
||||
if (tests == undefined ) tests = []
|
||||
tests.push(test)
|
||||
|
||||
let dt = {
|
||||
records : tests,
|
||||
total: tests.length
|
||||
}
|
||||
|
||||
context.commit("update_tests", dt)
|
||||
context.dispatch("delete_req", test)
|
||||
// context.dispatch("update_req", null)
|
||||
context.dispatch("appx_schedule")
|
||||
context.commit('update_nat_test')
|
||||
},
|
||||
|
||||
delete_req(context, px) {
|
||||
let req = context.state.requirement
|
||||
for (let i in req) {
|
||||
let x = _.indexOf(req[i].px_id, px.T_TestID)
|
||||
if (x > -1)
|
||||
req[i].px_id.splice(x, 1)
|
||||
|
||||
if (req[i].px_id.length < 1)
|
||||
req.splice(i, 1)
|
||||
}
|
||||
|
||||
context.commit('update_requirement', req)
|
||||
},
|
||||
|
||||
// update_req(context, px) {
|
||||
|
||||
// let reqs = []
|
||||
// let tests = context.state.selected_test
|
||||
// tests.forEach( function(t) {
|
||||
// let label = t.T_TestRequirement
|
||||
// if (_.indexOf(reqs,label) == -1 ) reqs.push(label)
|
||||
// })
|
||||
|
||||
// let panels = context.state.selected_panel
|
||||
// panels.forEach( function(p) {
|
||||
// let tests = p.test
|
||||
// tests.forEach( function(t) {
|
||||
// let label = t.T_TestRequirement
|
||||
// if (_.indexOf(reqs,label) == -1 ) reqs.push(label)
|
||||
// })
|
||||
// })
|
||||
|
||||
// let requirement = context.state.requirement
|
||||
// let flag_update_requirement = false
|
||||
// if (reqs.length == 0 ) {
|
||||
// requirement = []
|
||||
// flag_update_requirement = true
|
||||
// }
|
||||
// requirement.forEach(function(r,idx) {
|
||||
// if ( _.indexOf(reqs,r.label) == -1) {
|
||||
// flag_update_requirement = true
|
||||
// requirement.splice(idx,1)
|
||||
// }
|
||||
// })
|
||||
|
||||
// if (flag_update_requirement) {
|
||||
// context.commit('update_requirement', requirement)
|
||||
// }
|
||||
|
||||
// },
|
||||
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let mouCompanyID = 0
|
||||
if (context.rootState.company.selected_mou.M_MouID) {
|
||||
mouCompanyID = context.rootState.company.selected_mou.M_MouID
|
||||
}
|
||||
let resp= await api.search(mouCompanyID,context.state.search)
|
||||
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
|
||||
}
|
||||
console.log(context.state.exist_selected_test)
|
||||
context.commit("update_tests",data)
|
||||
var exist_tests = context.state.exist_selected_test
|
||||
|
||||
if(exist_tests.length > 0){
|
||||
exist_tests.forEach(function(px,xidx) {
|
||||
if (px.px_type !== "PR" && px.px_type !== "PXR"){
|
||||
let nt = context.state.nat_test
|
||||
let found_nt = false
|
||||
for (let i in px.nat_test) {
|
||||
if (nt.indexOf(px.nat_test[i]) > -1)
|
||||
found_nt = true
|
||||
}
|
||||
|
||||
if (found_nt) {
|
||||
alert('Pemeriksaan tersebut sudah ada !')
|
||||
return
|
||||
}
|
||||
|
||||
let selected_test = context.state.selected_test
|
||||
selected_test.push(px)
|
||||
let tests = context.state.tests
|
||||
let p_idx = -1
|
||||
tests.forEach(function(t,idx) {
|
||||
if (t.T_TestID == px.T_TestID) {
|
||||
p_idx = idx
|
||||
}
|
||||
})
|
||||
if (p_idx >= 0 ) {
|
||||
_.pullAt(tests,[p_idx])
|
||||
let dt = {
|
||||
records: tests,
|
||||
total: tests.length
|
||||
}
|
||||
context.commit('update_tests',dt)
|
||||
}
|
||||
context.commit('update_selected_test',selected_test)
|
||||
|
||||
let req = px.requirement
|
||||
console.log(req)
|
||||
let reqs = context.state.requirement
|
||||
console.log(reqs)
|
||||
if (req.length > 0) {
|
||||
for(let i in req) {
|
||||
let found = false
|
||||
for(let j in reqs) {
|
||||
if (reqs[j]['req_id'] == req[i]['req_id'])
|
||||
found = j
|
||||
}
|
||||
|
||||
if (!found)
|
||||
reqs.push({
|
||||
px_id: [px.T_TestID],
|
||||
label: req[i]['req_name'],
|
||||
error_message: 'Hasil harus di isi',
|
||||
is_error: true,
|
||||
checked : false,
|
||||
note: '',
|
||||
req_id: req[i]['req_id']
|
||||
})
|
||||
else
|
||||
reqs[found].px_id.push(px.T_TestID)
|
||||
}
|
||||
|
||||
context.commit('update_requirement', reqs)
|
||||
}
|
||||
|
||||
context.dispatch('appx_schedule')
|
||||
if(xidx === ( exist_tests.length - 1)){
|
||||
context.commit('update_exist_selected_test',[])
|
||||
}
|
||||
}else{
|
||||
let nt = context.state.nat_test
|
||||
let found_nt = false
|
||||
for (let i in px.nat_test) {
|
||||
if (nt.indexOf(px.nat_test[i]) > -1)
|
||||
found_nt = true
|
||||
}
|
||||
|
||||
if (found_nt) {
|
||||
alert('Error')
|
||||
return
|
||||
}
|
||||
|
||||
let pxs = px.child_test
|
||||
|
||||
for (let i in pxs) {
|
||||
px = pxs[i]
|
||||
|
||||
let selected_test = context.state.selected_test
|
||||
let flag_found = false
|
||||
|
||||
selected_test.push(px)
|
||||
let tests = context.state.tests
|
||||
let p_idx = -1
|
||||
tests.forEach(function(t,idx) {
|
||||
if (t.T_TestID == px.T_TestID) {
|
||||
p_idx = idx
|
||||
}
|
||||
})
|
||||
|
||||
if (p_idx >= 0 ) {
|
||||
_.pullAt(tests,[p_idx])
|
||||
let dt = {
|
||||
records: tests,
|
||||
total: tests.length
|
||||
}
|
||||
context.commit('update_tests',dt)
|
||||
}
|
||||
|
||||
context.commit('update_selected_test', selected_test)
|
||||
|
||||
let req = px.requirement
|
||||
|
||||
let reqs = context.state.requirement
|
||||
if (req.length > 0) {
|
||||
for(let i in req) {
|
||||
let found = false
|
||||
for(let j in reqs) {
|
||||
if (reqs[j]['req_id'] == req[i]['req_id'])
|
||||
found = j
|
||||
}
|
||||
|
||||
if (!found)
|
||||
reqs.push({
|
||||
px_id: [px.T_TestID],
|
||||
label: req[i]['req_name'],
|
||||
error_message: 'Hasil harus di isi',
|
||||
is_error: true,
|
||||
checked : false,
|
||||
note: '',
|
||||
req_id: req[i]['req_id']
|
||||
})
|
||||
else
|
||||
reqs[found].px_id.push(px.T_TestID)
|
||||
}
|
||||
|
||||
context.commit('update_requirement', reqs)
|
||||
context.dispatch('appx_schedule')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async panel(context,prm) {
|
||||
context.commit("update_search_panel_status",1)
|
||||
try {
|
||||
let mouCompanyID = 0
|
||||
if (context.rootState.company.selected_mou.M_MouCompanyID) {
|
||||
mouCompanyID = context.rootState.company.selected_mou.M_MouCompanyID
|
||||
}
|
||||
let resp= await api.panel(mouCompanyID,context.state.search)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_panel_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_panels",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async profile(context) {
|
||||
context.commit("update_search_panel_status", 1)
|
||||
try {
|
||||
let mou_id = 0
|
||||
if (context.rootState.company.selected_mou.M_MouID) {
|
||||
mou_id = context.rootState.company.selected_mou.M_MouID
|
||||
}
|
||||
|
||||
let resp = await api.profile(mou_id, context.state.search_profile)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_panel_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_profiles", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async get_price(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let mou_id = context.rootState.company.selected_mou.M_MouID
|
||||
let resp = await api.get_price(prm.test_id, mou_id, prm.cito)
|
||||
|
||||
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 x = context.state.selected_test
|
||||
for (let i in x) {
|
||||
if (x[i].T_TestID == prm.test_id) {
|
||||
if (Math.round(resp.data.test_price) == 0) {
|
||||
x[i].T_TestIsCito = "N"
|
||||
let n = context.state.cito.test.indexOf(x[i].T_TestID)
|
||||
if (n > -1)
|
||||
context.state.cito.test.splice(n, 1)
|
||||
|
||||
let tests = context.state.tests
|
||||
if (tests == undefined ) tests = []
|
||||
tests.push(x[i])
|
||||
let dt = {
|
||||
records : tests,
|
||||
total: tests.length
|
||||
}
|
||||
context.commit("update_tests", dt)
|
||||
x.splice(i, 1);
|
||||
}
|
||||
|
||||
else {
|
||||
x[i].T_PriceAmount = resp.data.test_price
|
||||
x[i].T_PriceDisc = resp.data.test_disc
|
||||
x[i].T_PriceDiscRp = resp.data.test_discrp
|
||||
}
|
||||
}
|
||||
}
|
||||
context.commit("update_selected_test", x)
|
||||
context.commit("update_nat_test")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async appx_schedule(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let ids = []
|
||||
let pn_ids = []
|
||||
context.commit("update_appx_schedule", '-')
|
||||
|
||||
let pxs = context.state.selected_test
|
||||
for (let i in pxs) {
|
||||
if (pxs[i].px_type == 'PN')
|
||||
pn_ids.push(pxs[i].T_TestID)
|
||||
else
|
||||
ids.push(pxs[i].T_TestID)
|
||||
}
|
||||
|
||||
let resp = await api.appx_schedule(ids.join(','), pn_ids.join(','))
|
||||
|
||||
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_appx_schedule", resp.data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
test/vuex/one-mcu-registration/modules/supplies.js
Normal file
57
test/vuex/one-mcu-registration/modules/supplies.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/supplies.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
deliveries: [],
|
||||
patient_id: 0,
|
||||
order_id: 0
|
||||
},
|
||||
mutations: {
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_deliveries(state,data) {
|
||||
state.deliveries= data
|
||||
},
|
||||
update_selected_delivery(state,val) {
|
||||
state.selected_delivery=val
|
||||
},
|
||||
update_params(state, val) {
|
||||
if (val.p_id)
|
||||
state.patient_id = val.p_id;
|
||||
if (val.o_id)
|
||||
state.order_id = val.o_id;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(store.state.delivery.order_id, store.state.delivery.patient_id)
|
||||
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
|
||||
}
|
||||
context.commit("update_deliveries",data.records)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user