Flatten nested repos
This commit is contained in:
229
test/vuex/cpone-card-reader/modules/area.js
Normal file
229
test/vuex/cpone-card-reader/modules/area.js
Normal file
@@ -0,0 +1,229 @@
|
||||
// 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
|
||||
|
||||
if (["provinces", "districts", "villages"].indexOf(data.type) > -1)
|
||||
state['selected_'+ data.type.substring(0, data.type.length-1) ] = null
|
||||
else if (data.type == "cities")
|
||||
state['selected_city'] = null
|
||||
|
||||
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)
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'city'})
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'district'})
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'village'})
|
||||
context.commit("update_selected_area", {type:'city',val:null})
|
||||
context.commit("update_selected_area", {type:'district',val:null})
|
||||
context.commit("update_selected_area", {type:'village',val:null})
|
||||
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'
|
||||
}
|
||||
|
||||
// EDIT DATA
|
||||
if (context.rootState.patient.edit) {
|
||||
let pid = context.rootState.patient.selected_patient.M_ProvinceID
|
||||
for (let i in data.records)
|
||||
if (data.records[i].M_ProvinceID == pid) data.records[i].is_default = "Y"
|
||||
else data.records[i].is_default = "N"
|
||||
}
|
||||
|
||||
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)
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'district'})
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'village'})
|
||||
context.commit("update_selected_area", {type:'district',val:null})
|
||||
context.commit("update_selected_area", {type:'village',val:null})
|
||||
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'
|
||||
}
|
||||
|
||||
// EDIT DATA
|
||||
if (context.rootState.patient.edit) {
|
||||
let pid = context.rootState.patient.selected_patient.M_CityID
|
||||
for (let i in data.records)
|
||||
if (data.records[i].M_CityID == pid) data.records[i].is_default = "Y"
|
||||
else data.records[i].is_default = "N"
|
||||
}
|
||||
|
||||
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)
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'village'})
|
||||
context.commit("update_selected_area", {type:'village',val:null})
|
||||
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'
|
||||
}
|
||||
|
||||
// EDIT DATA
|
||||
if (context.rootState.patient.edit) {
|
||||
let pid = context.rootState.patient.selected_patient.M_DistrictID
|
||||
for (let i in data.records)
|
||||
if (data.records[i].M_DistrictID == pid) data.records[i].is_default = "Y"
|
||||
else data.records[i].is_default = "N"
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
|
||||
// EDIT DATA
|
||||
if (context.rootState.patient.edit) {
|
||||
let pid = context.rootState.patient.selected_patient.M_KelurahanID
|
||||
for (let i in data.records)
|
||||
if (data.records[i].M_KelurahanID == pid) data.records[i].is_default = "Y"
|
||||
else data.records[i].is_default = "N"
|
||||
}
|
||||
|
||||
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 )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
118
test/vuex/cpone-card-reader/modules/company.js
Normal file
118
test/vuex/cpone-card-reader/modules/company.js
Normal file
@@ -0,0 +1,118 @@
|
||||
// 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',
|
||||
show_alias_doctor:false
|
||||
},
|
||||
mutations: {
|
||||
update_show_alias_doctor(state,tab) {
|
||||
state.show_alias_doctor = tab
|
||||
},
|
||||
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) {
|
||||
let cmou = data.records[0].mou[i]
|
||||
if (cmou.M_MouIsDefault == "Y") {
|
||||
context.commit("update_selected_mou", cmou)
|
||||
context.dispatch("delivery/search_deliveries", {type:'mou',id:cmou.M_MouID}, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// search px
|
||||
console.log("mulai search")
|
||||
context.dispatch('px/search', null, {root:true})
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
134
test/vuex/cpone-card-reader/modules/delivery.js
Normal file
134
test/vuex/cpone-card-reader/modules/delivery.js
Normal file
@@ -0,0 +1,134 @@
|
||||
// 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,
|
||||
mou_id: 0,
|
||||
data_deliveries:[],
|
||||
selected_data_delivery:[],
|
||||
checked_id: []
|
||||
},
|
||||
mutations: {
|
||||
update_data_deliveries(state,value){
|
||||
state.data_deliveries = value
|
||||
},
|
||||
update_selected_data_delivery(state,value){
|
||||
state.selected_data_delivery = value
|
||||
},
|
||||
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;
|
||||
if (typeof val.m_id !== 'undefined')
|
||||
state.mou_id = val.m_id;
|
||||
|
||||
|
||||
},
|
||||
update_checked_id(state, val) {
|
||||
state.checked_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
console.log(context.rootState.company.selected_company)
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.order_id,
|
||||
context.state.patient_id,
|
||||
context.state.doctor_id,
|
||||
context.state.mou_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
|
||||
}
|
||||
let deliveries = resp.data.records
|
||||
if(deliveries.length > 0)
|
||||
context.commit("update_deliveries",deliveries)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async search_deliveries(context,prm) {
|
||||
console.log(context.rootState.company.selected_company)
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.search_deliveries(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
|
||||
}
|
||||
let deliveries = resp.data.records
|
||||
|
||||
var existing_deliveries = context.state.data_deliveries
|
||||
var exclude_type = _.filter(existing_deliveries, function(o) { return o.type !== prm.type })
|
||||
if(deliveries.length > 0){
|
||||
deliveries.forEach(function(delivery) {
|
||||
exclude_type.push(delivery)
|
||||
})
|
||||
}
|
||||
context.commit("update_data_deliveries",exclude_type)
|
||||
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
133
test/vuex/cpone-card-reader/modules/doctor.js
Normal file
133
test/vuex/cpone-card-reader/modules/doctor.js
Normal file
@@ -0,0 +1,133 @@
|
||||
// 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: {},
|
||||
doctor_alias:'',
|
||||
doctor_alias_address:'',
|
||||
doctors_pj: [],
|
||||
selected_doctor_pj : {},
|
||||
search_pj_status: 0,
|
||||
search_pj_error_message: "",
|
||||
show_doctor_alert:true,
|
||||
mounted: 0
|
||||
},
|
||||
mutations: {
|
||||
update_doctor_alias(state,val) {
|
||||
state.doctor_alias=val
|
||||
},
|
||||
update_doctor_alias_address(state,val) {
|
||||
state.doctor_alias_address=val
|
||||
},
|
||||
update_show_doctor_alert(state,val) {
|
||||
state.show_doctor_alert=val
|
||||
},
|
||||
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) {
|
||||
console.log("BRI1")
|
||||
console.log(doc)
|
||||
state.selected_doctor= doc
|
||||
|
||||
if (!doc) return
|
||||
state.selected_address = null
|
||||
|
||||
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 )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
285
test/vuex/cpone-card-reader/modules/doctor_new.js
Normal file
285
test/vuex/cpone-card-reader/modules/doctor_new.js
Normal file
@@ -0,0 +1,285 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/doctor.js"
|
||||
import * as area from "../api/area.js"
|
||||
import * as other from "../api/other.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
|
||||
sexs: [],
|
||||
selected_sex: null,
|
||||
param_name: '',
|
||||
param_prefix1: '',
|
||||
param_prefix2: '',
|
||||
param_sufix1: '',
|
||||
param_sufix2: '',
|
||||
param_sufix3: '',
|
||||
param_hp: '',
|
||||
param_note: '',
|
||||
param_address: '',
|
||||
|
||||
provinces: [],
|
||||
selected_province: null,
|
||||
cities: [],
|
||||
selected_city: null,
|
||||
districts: [],
|
||||
selected_district: null,
|
||||
villages: [],
|
||||
selected_village: null,
|
||||
dialog_new: false,
|
||||
|
||||
adhoc: false
|
||||
},
|
||||
|
||||
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_dialog_new(state, d) {
|
||||
state.dialog_new = d
|
||||
},
|
||||
|
||||
update_sexs(state, d) {
|
||||
state.sexs = d.records
|
||||
},
|
||||
|
||||
update_selected_sex(state, d) {
|
||||
state.selected_sex = d
|
||||
},
|
||||
|
||||
update_provinces(state, d) {
|
||||
state.provinces = d.records
|
||||
state.cities = []
|
||||
state.districts = []
|
||||
state.villages = []
|
||||
state.selected_city = null
|
||||
state.selected_district = null
|
||||
state.selected_village = null
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_province = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_province(state, d) {
|
||||
state.selected_province = d
|
||||
},
|
||||
|
||||
update_districts(state, d) {
|
||||
state.districts = d.records
|
||||
state.villages = []
|
||||
state.selected_village = null
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_district = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_district(state, d) {
|
||||
state.selected_district = d
|
||||
},
|
||||
|
||||
update_cities(state, d) {
|
||||
state.cities = d.records
|
||||
state.districts = []
|
||||
state.villages = []
|
||||
state.selected_district = null
|
||||
state.selected_village = null
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_city = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_city(state, d) {
|
||||
state.selected_city = d
|
||||
},
|
||||
|
||||
update_villages(state, d) {
|
||||
state.villages = d.records
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_village = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_village(state, d) {
|
||||
state.selected_village = d
|
||||
},
|
||||
|
||||
update_param(state, d) {
|
||||
state['param_'+d.param] = d.val
|
||||
},
|
||||
|
||||
update_adhoc(state, d) {
|
||||
state.adhoc = d
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async save(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let d = {
|
||||
name: context.state.param_name,
|
||||
prefix1: context.state.param_prefix1,
|
||||
prefix2: context.state.param_prefix2,
|
||||
sufix1: context.state.param_sufix1,
|
||||
sufix2: context.state.param_sufix2,
|
||||
sufix3: context.state.param_sufix3,
|
||||
sex: context.state.selected_sex.M_SexID,
|
||||
hp: context.state.param_hp,
|
||||
note: context.state.param_note,
|
||||
address: context.state.param_address,
|
||||
village: context.state.selected_village.M_KelurahanID
|
||||
}
|
||||
|
||||
let resp = await api.save(one_token(), d)
|
||||
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_adhoc', true)
|
||||
context.commit('doctor/update_doctors', data, {root:true})
|
||||
context.commit('doctor/update_search', data.records[0].M_DoctorRealName, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', data.records[0], {root:true})
|
||||
context.commit('delivery/update_params', {d_id:data.records[0].M_DoctorID}, {root:true})
|
||||
context.dispatch('delivery/search', null, {root:true})
|
||||
|
||||
context.commit('update_dialog_new', false)
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async search_sex(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await other.search_sex()
|
||||
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_sexs', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_province(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_province()
|
||||
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_provinces', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_city(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_city(context.state.selected_province.M_ProvinceID)
|
||||
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_cities', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_district(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_district(context.state.selected_city.M_CityID)
|
||||
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_districts', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_village(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_kelurahan(context.state.selected_district.M_DistrictID)
|
||||
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_villages', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
112
test/vuex/cpone-card-reader/modules/history.js
Normal file
112
test/vuex/cpone-card-reader/modules/history.js
Normal file
@@ -0,0 +1,112 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/history.js"
|
||||
import doctor from "./doctor.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
|
||||
},
|
||||
|
||||
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", resp.data.records)
|
||||
context.commit('update_history_dialog',true)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async get_databyorder_id(context,prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.get_databyorder_id(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
|
||||
}
|
||||
console.log(data.records.status)
|
||||
if(data.records.status === 'N'){
|
||||
context.commit('update_message_error', 'satu...dua...tiga permen manis rasanya, coba cek agreement sepertinya sudah kadaluarsa', {root:true})
|
||||
context.commit('update_dialog_error', true, {root:true})
|
||||
}
|
||||
else{
|
||||
var rst = data.records.data
|
||||
//console.log(rst)
|
||||
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})
|
||||
context.commit('company/update_companies', {records:rst['companies'],total:rst['companies'].length}, {root:true})
|
||||
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_pxs', prm.order_id, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
test/vuex/cpone-card-reader/modules/language.js
Normal file
78
test/vuex/cpone-card-reader/modules/language.js
Normal file
@@ -0,0 +1,78 @@
|
||||
// 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: [],
|
||||
languages_2: [],
|
||||
selected_language: {},
|
||||
selected_language_2: null
|
||||
},
|
||||
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
|
||||
let x = Object.assign([], state.languages)
|
||||
if (data.records.length > 0) {
|
||||
state.selected_language = data.records[0]
|
||||
x.splice(0, 1)
|
||||
}
|
||||
|
||||
state.languages_2 = x
|
||||
},
|
||||
|
||||
update_selected_language(state, val) {
|
||||
state.selected_language = val
|
||||
|
||||
let x = Object.assign([], state.languages)
|
||||
let idx = 999
|
||||
if (val)
|
||||
if (val.id)
|
||||
for (let i in x)
|
||||
if (x[i].id == val.id && x[i].is_si == val.is_si)
|
||||
idx = i
|
||||
|
||||
x.splice(idx, 1)
|
||||
state.languages_2 = x
|
||||
state.selected_language_2 = null
|
||||
},
|
||||
|
||||
update_selected_language_2(state, val) {
|
||||
state.selected_language_2 = 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 )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
790
test/vuex/cpone-card-reader/modules/order.js
Normal file
790
test/vuex/cpone-card-reader/modules/order.js
Normal file
@@ -0,0 +1,790 @@
|
||||
// 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',
|
||||
dialog_start: true,
|
||||
status_start: 'Y',
|
||||
time_start: undefined,
|
||||
elapsedTime: 0,
|
||||
show_time: null,
|
||||
loading_process: false,
|
||||
stest: [],
|
||||
mcuid: 0,
|
||||
preid: 0,
|
||||
patientBarcode: [],
|
||||
url_preregister : '',
|
||||
url_register: '',
|
||||
in_saving: false,
|
||||
loading_data_patient: false
|
||||
},
|
||||
mutations: {
|
||||
update_loading_data_patient(state, val) {
|
||||
state.loading_data_patient = val
|
||||
},
|
||||
update_in_saving(state, val) {
|
||||
state.in_saving = val
|
||||
},
|
||||
update_url_preregister(state, val) {
|
||||
state.url_preregister = val
|
||||
},
|
||||
update_url_register(state, val) {
|
||||
state.url_register = val
|
||||
},
|
||||
update_patientBarcode(state, val) {
|
||||
state.patientBarcode = val
|
||||
},
|
||||
update_preid(state, val) {
|
||||
state.preid = val
|
||||
},
|
||||
update_mcuid(state, val) {
|
||||
state.mcuid = val
|
||||
},
|
||||
update_stest(state, val) {
|
||||
state.stest = 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 preid = context.state.preid;
|
||||
var mcuid = context.state.mcuid;
|
||||
console.log(mcuid);
|
||||
var delivery = [];
|
||||
var delivery_note = [];
|
||||
var detail = [];
|
||||
var req = [];
|
||||
var test_detail = [];
|
||||
var tests = context.state.stest;
|
||||
console.log('lang_2')
|
||||
console.log(context.rootState.language.selected_language_2)
|
||||
var header = {
|
||||
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: 0,
|
||||
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.CorporateID,
|
||||
mou_id: 0,
|
||||
received_sample: context.rootState.order.received_sample,
|
||||
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,
|
||||
branch_id: context.rootState.patient.selected_patient.branch_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 = {
|
||||
ss_price_id: st[i]['Ss_PriceMouID'],
|
||||
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(), mcuid, preid, order_id, header, delivery, delivery_note, detail, req, tests)
|
||||
|
||||
console.log('save respon' , resp.data)
|
||||
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 })
|
||||
|
||||
if(resp.data.data.tipe == 'new'){
|
||||
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 })
|
||||
}else{
|
||||
alert('Data telah terdaftar')
|
||||
var p_url = resp.data.data.url
|
||||
var url_string = window.location.href
|
||||
var url = new URL(url_string);
|
||||
var mcuid = url.searchParams.get("mcuid")
|
||||
location.replace("/one-ui/" + p_url +"?mcuid="+mcuid)
|
||||
}
|
||||
|
||||
|
||||
//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
|
||||
|
||||
|
||||
if (id !== -1)
|
||||
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 })
|
||||
if (rst['patient']['M_PatientPhoto']) {
|
||||
context.commit('photo/update_photo_url', rst['patient']['M_PatientPhoto'], { 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('selesai doctor')
|
||||
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 })
|
||||
console.log('selesai company')
|
||||
context.commit('delivery/update_data_deliveries', rst['data_deliveries'], { root: true })
|
||||
console.log('selesai delivery')
|
||||
context.commit('update_stest', rst['tests'])
|
||||
console.log('selesai test 1')
|
||||
//context.commit('history/update_history_dialog',false,{root:true})
|
||||
//context.dispatch('px/search', {}, { root: true })
|
||||
if (rst['tests']) {
|
||||
rst['tests'].forEach(function (test) {
|
||||
context.dispatch('selectPx', test)
|
||||
});
|
||||
|
||||
}
|
||||
console.log('selesai load')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async selectPx(context, px) {
|
||||
// console.log(context)
|
||||
var in_selectPx = false
|
||||
console.log(px)
|
||||
//debugger
|
||||
console.log("start select px")
|
||||
if (!window.one_token()) {
|
||||
//context.commit('update_message_error', 'Maaf, koneksi Anda sempat terputus silahkan Log Out dan Login kembali',{root:true})
|
||||
//context.commit('update_dialog_error', true,{root:true})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
console.log(in_selectPx)
|
||||
// START LOADING
|
||||
//context.commit('update_dialog_loading', true)
|
||||
console.log('px type ' + px.px_type)
|
||||
|
||||
// IF PROFILE
|
||||
if (px.px_type == "PR" || px.px_type == "PXR")
|
||||
return context.dispatch('selectProfile', px)
|
||||
|
||||
|
||||
// SEARCH NAT TEST
|
||||
let nt = context.rootState.px.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 !')
|
||||
// END LOADING
|
||||
//context.commit('update_dialog_loading', false,{root:true})
|
||||
return
|
||||
}
|
||||
|
||||
//if (in_selectPx) return
|
||||
in_selectPx = true
|
||||
let selected_test = context.rootState.px.selected_test
|
||||
let flag_found = false
|
||||
selected_test.forEach(function (t, idx) {
|
||||
if (t.T_TestID == px.T_TestID) {
|
||||
selected_test[idx] = px
|
||||
flag_found = true
|
||||
}
|
||||
})
|
||||
if (!flag_found) {
|
||||
selected_test.push(px)
|
||||
let tests = context.rootState.px.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('px/update_tests', dt, { root: true })
|
||||
}
|
||||
}
|
||||
context.commit('px/update_selected_test', selected_test, { root: true })
|
||||
console.log('load data patient px')
|
||||
context.commit('update_loading_data_patient', true)
|
||||
if (px.px_type !== "PN") {
|
||||
let req = px.requirement
|
||||
let reqs = context.rootState.px.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('px/update_requirement', reqs, { root: true })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
context.dispatch('px/appx_schedule', {}, { root: true })
|
||||
|
||||
in_selectPx = false
|
||||
context.commit('px/update_nat_test', {}, { root: true })
|
||||
context.commit('update_loading_data_patient', true)
|
||||
console.log('load data patient px')
|
||||
|
||||
// END LOADING
|
||||
if (px.px_type == "PN")
|
||||
//context.commit('update_loading_data_patient', false)
|
||||
context.dispatch('px/packet_reqs', { pxs: px.child_test }, { root: true })
|
||||
//context.commit('update_dialog_loading', false,{root:true})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
in_selectPx = false
|
||||
}
|
||||
},
|
||||
|
||||
async selectProfile(context, px) {
|
||||
|
||||
try {
|
||||
var in_selectPx = false
|
||||
// SEARCH NAT TEST
|
||||
let nt = context.rootState.px.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 !')
|
||||
// END LOADING
|
||||
// context.commit('update_dialog_loading', false,{root:true})
|
||||
return
|
||||
}
|
||||
|
||||
let pxs = px.child_test
|
||||
|
||||
for (let i in pxs) {
|
||||
px = pxs[i]
|
||||
|
||||
let selected_test = context.rootState.px.selected_test
|
||||
let flag_found = false
|
||||
|
||||
selected_test.push(px)
|
||||
let tests = context.rootState.px.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('px/update_tests', dt, { root: true })
|
||||
}
|
||||
|
||||
context.commit('px/update_selected_test', selected_test, { root: true })
|
||||
|
||||
let req = px.requirement
|
||||
|
||||
let reqs = context.rootState.px.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('px/update_requirement', reqs, { root: true })
|
||||
}
|
||||
}
|
||||
|
||||
context.dispatch('px/appx_schedule', { root: true })
|
||||
//in_selectPx = false
|
||||
context.commit('px/update_nat_test', { root: true })
|
||||
console.log('load data patient profile')
|
||||
context.commit('update_loading_data_patient', true)
|
||||
|
||||
// END LOADING
|
||||
//context.commit('update_dialog_loading', false,{root:true})
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
// END LOADING
|
||||
//context.commit('update_dialog_loading', false,{root:true})
|
||||
// in_selectPx = false
|
||||
}
|
||||
},
|
||||
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 {
|
||||
var t_orderid = resp.data.data.orderid
|
||||
var url_preregister = resp.data.data.url_preregister
|
||||
var url_register = resp.data.data.url_register
|
||||
console.log(t_orderid)
|
||||
console.log(url_preregister)
|
||||
console.log(url_register)
|
||||
|
||||
context.commit('update_url_preregister', url_preregister)
|
||||
context.commit('update_url_register', url_register)
|
||||
if(t_orderid > 0){
|
||||
alert('Data telah terdaftar !!!')
|
||||
var url_string = window.location.href
|
||||
var url = new URL(url_string);
|
||||
var mcuid = url.searchParams.get("mcuid")
|
||||
location.replace("/one-ui/" +url_preregister +"?mcuid="+mcuid)
|
||||
|
||||
}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) {
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
async getbarcode(context, prm) {
|
||||
context.commit("update_get_data_status", 1)
|
||||
try {
|
||||
prm.token = one_token();
|
||||
console.log(prm);
|
||||
let resp = await api.lookupbarcodes(prm)
|
||||
if (resp.status != "OK") {
|
||||
// context.commit("update_get_data_status", 3)
|
||||
var snackbar = context.state.snackbar
|
||||
snackbar.color = 'red'
|
||||
snackbar.value = true
|
||||
snackbar.multi_line = 'single-line'
|
||||
snackbar.text = 'Gagal get barcode'
|
||||
context.commit("update_snackbar", snackbar)
|
||||
} else {
|
||||
context.commit("update_get_data_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
let barcodes = resp.data.records
|
||||
context.commit("update_patientBarcode", data.records)
|
||||
let arrprm = [];
|
||||
let arrprmst = [];
|
||||
for (let index = 0; index < barcodes.length; index++) {
|
||||
const e = barcodes[index];
|
||||
arrprm.push(e.T_BarcodeLabBarcode)
|
||||
if (e.type === 'nonlab') {
|
||||
arrprmst.push(e.T_SampleTypeID)
|
||||
console.log('print so')
|
||||
console.log("nolab so ganti group")
|
||||
console.log("param ganti")
|
||||
console.log("balik lagi")
|
||||
// one_print_barcode_so(e.T_SampleTypeID)
|
||||
}
|
||||
}
|
||||
if (arrprm.length > 0) {
|
||||
//one_print_barcode_pk(arrprm.join(","));
|
||||
}
|
||||
|
||||
if (arrprmst.length > 0) {
|
||||
one_print_barcode_sov1(arrprmst.join(","));
|
||||
}
|
||||
// let inp = {};
|
||||
// inp.id = prm.id;
|
||||
// inp.no_lab = prm.no_lab;
|
||||
// inp.name = prm.name;
|
||||
// inp.register_date = prm.register_date;
|
||||
// one_print_qrcode(inp);
|
||||
// // console.log("Input prm")
|
||||
// // console.log(inp)
|
||||
// console.log("print barcode new")
|
||||
// console.log(inp)
|
||||
// one_print_qrcode_patient(inp);
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
// context.commit("update_get_data_status", 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
190
test/vuex/cpone-card-reader/modules/other.js
Normal file
190
test/vuex/cpone-card-reader/modules/other.js
Normal file
@@ -0,0 +1,190 @@
|
||||
// 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: {},
|
||||
|
||||
banks: [],
|
||||
accounts: [],
|
||||
cards: [],
|
||||
|
||||
religions: [],
|
||||
total_religion: 0,
|
||||
selected_religion: {},
|
||||
|
||||
mounted: 0
|
||||
},
|
||||
mutations: {
|
||||
update_title(state, val) {
|
||||
state.title=val
|
||||
},
|
||||
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
|
||||
},
|
||||
|
||||
update_banks(state, d) {
|
||||
state.banks = d.records
|
||||
},
|
||||
|
||||
update_cards(state, d) {
|
||||
state.cards = d.records
|
||||
},
|
||||
|
||||
update_accounts(state, d) {
|
||||
state.accounts = d.records
|
||||
},
|
||||
|
||||
update_religion(state, data) {
|
||||
state.religions = data.records
|
||||
state.total_religion = data.total
|
||||
},
|
||||
|
||||
update_selected_religion(state, doc) {
|
||||
state.selected_religion = 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 )
|
||||
}
|
||||
},
|
||||
|
||||
async search_religion(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_religion(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_religion", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_bank(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_bank(context.state.search, null, "Y")
|
||||
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_banks", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_card(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_bank(context.state.search, "Y")
|
||||
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_cards", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_accounts(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_accounts(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
|
||||
}
|
||||
context.commit("update_accounts", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
221
test/vuex/cpone-card-reader/modules/patient.js
Normal file
221
test/vuex/cpone-card-reader/modules/patient.js
Normal file
@@ -0,0 +1,221 @@
|
||||
// 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: {},
|
||||
current_page:1,
|
||||
edit: false,
|
||||
dialog_birthday:false,
|
||||
show_more:true,
|
||||
loading:false
|
||||
},
|
||||
mutations: {
|
||||
update_loading(state,status) {
|
||||
state.loading = status
|
||||
},
|
||||
update_show_more(state,status) {
|
||||
state.show_more = status
|
||||
},
|
||||
update_current_page(state,status) {
|
||||
state.current_page = status
|
||||
},
|
||||
update_dialog_birthday(state,status) {
|
||||
state.dialog_birthday = 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_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
|
||||
},
|
||||
|
||||
update_edit(state, v) {
|
||||
state.edit = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
//context.commit("update_loading",true)
|
||||
let resp= await api.search(context.state.noreg,context.state.search,context.state.current_page)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_loading",false)
|
||||
if (prm && prm.use)
|
||||
context.commit("update_patients",{records : [],total:0})
|
||||
|
||||
if(data.records.length > 0){
|
||||
if(context.state.patients.length > 0){
|
||||
var data_before = context.state.patients
|
||||
var idx_last = data_before.length - 1
|
||||
data_before[idx_last].divider = 'Y'
|
||||
data.records.forEach(function(entry) {
|
||||
data_before.push(entry)
|
||||
})
|
||||
context.commit("update_patients",{records : data_before,total:data_before.length})
|
||||
}
|
||||
else{
|
||||
context.commit("update_patients",data)
|
||||
}
|
||||
|
||||
context.commit("update_show_more",true)
|
||||
}
|
||||
else{
|
||||
context.commit("update_show_more",false)
|
||||
context.commit("update_current_page",1)
|
||||
}
|
||||
|
||||
if (prm)
|
||||
if (prm.use) {
|
||||
let pat = context.state.patients[prm.use_idx]
|
||||
console.log(pat)
|
||||
context.commit('update_selected_patient', pat)
|
||||
if(pat.info.birthday == 'Y')
|
||||
context.commit('update_dialog_birthday', true)
|
||||
|
||||
context.commit('order/update_patient_note', pat.M_PatientNote, {root:true})
|
||||
context.dispatch('delivery/search_deliveries',{type:'patient',id:pat.M_PatientID},{root:true})
|
||||
|
||||
context.commit('photo/update_patient_id', pat.M_PatientID, {root: true})
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_loading",false)
|
||||
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
|
||||
if (context.state.edit){
|
||||
resp = await api.edit(prm, context.state.selected_patient.M_PatientID)
|
||||
|
||||
}
|
||||
else
|
||||
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 )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
test/vuex/cpone-card-reader/modules/patientaddress.js
Normal file
86
test/vuex/cpone-card-reader/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)
|
||||
}
|
||||
}
|
||||
}
|
||||
322
test/vuex/cpone-card-reader/modules/payment.js
Normal file
322
test/vuex/cpone-card-reader/modules/payment.js
Normal file
@@ -0,0 +1,322 @@
|
||||
// 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,
|
||||
savepayment: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_savepayment (state, id) {
|
||||
state.savepayment = 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) {
|
||||
context.state.savepayment = true
|
||||
console.log('disabled payment')
|
||||
console.log(context.state.savepayment)
|
||||
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,
|
||||
card: p[i].payment_card_id,
|
||||
edc: p[i].payment_edc_id,
|
||||
account: p[i].payment_account_id
|
||||
})
|
||||
}
|
||||
|
||||
// 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')
|
||||
context.state.savepayment = false
|
||||
} else {
|
||||
context.state.savepayment = false
|
||||
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) {
|
||||
let usr = one_user()
|
||||
console.log("yesy nota")
|
||||
console.log(usr)
|
||||
let ts = Date.now() / 1000 | 0
|
||||
let x = context.rootState.company.selected_mou
|
||||
let rpt_url = '/birt/run?__report=report/one/fo/rpt_t_003.rptdesign&PID='+a+'&username='+usr.M_StaffName+'&__format=pdf&ts='+ts
|
||||
if (x.M_MouIsBill == 'Y')
|
||||
rpt_url = '/birt/run?__report=report/one/fo/rpt_t_006.rptdesign&__format=pdf&username='+usr.M_StaffName+'&PID='+a+'&ts='+ts
|
||||
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + rpt_url, {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_notain (context, a) {
|
||||
let usr = one_user()
|
||||
console.log("yesy nota")
|
||||
console.log(usr)
|
||||
let ts = Date.now() / 1000 | 0
|
||||
let x = context.rootState.company.selected_mou
|
||||
let rpt_url = '/birt/run?__report=report/one/fo/rpt_t_003i.rptdesign&PID='+a+'&username='+usr.M_StaffName+'&__format=pdf&ts='+ts
|
||||
if (x.M_MouIsBill == 'Y')
|
||||
rpt_url = '/birt/run?__report=report/one/fo/rpt_t_006.rptdesign&__format=pdf&username='+usr.M_StaffName+'&PID='+a+'&ts='+ts
|
||||
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + rpt_url, {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_invoice (context, a) {
|
||||
let usr = one_user()
|
||||
console.log("yesy invoice")
|
||||
console.log(usr)
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&PID='+a+'&username='+usr.M_StaffName+'&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_control_xx (context, a) {
|
||||
let usr = one_user()
|
||||
console.log("yesy control")
|
||||
console.log(usr)
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&PID='+a+'&username='+usr.M_StaffName+'&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
async reset (context, prm) {
|
||||
try {
|
||||
//alert("acacadvadv")
|
||||
prm.token = one_token()
|
||||
let resp= await api.endshowtime(prm)
|
||||
if (resp.data.status != "OK") {
|
||||
//alert('stop')
|
||||
} else {
|
||||
var url_string = window.location.href
|
||||
var url = new URL(url_string);
|
||||
var pre_id = url.searchParams.get("pre_id")
|
||||
var mcuid = url.searchParams.get("mcuid")
|
||||
var type = url.searchParams.get("type")
|
||||
console.log(pre_id)
|
||||
//alert('cdcadscsdvds')
|
||||
|
||||
if (pre_id != null) {
|
||||
//console.log('haaaaaaaaaaaaaakeeeee')
|
||||
if(type == null)
|
||||
location.replace("/one-ui/" +prm.url +"?mcuid="+mcuid)
|
||||
else
|
||||
location.replace("/one-ui/" +prm.url +"?mcuid="+mcuid)
|
||||
}
|
||||
else{
|
||||
location.replace("/one-ui/" +prm.url +"?mcuid="+mcuid)
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
async print_control (context, prm) {
|
||||
let usr = one_user()
|
||||
console.log("yesy control")
|
||||
console.log(usr)
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&PID='+prm.order_id+'&username='+usr.M_StaffName+'&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
304
test/vuex/cpone-card-reader/modules/payment.js--
Normal file
304
test/vuex/cpone-card-reader/modules/payment.js--
Normal file
@@ -0,0 +1,304 @@
|
||||
// 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,
|
||||
savepayment: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_savepayment (state, id) {
|
||||
state.savepayment = 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) {
|
||||
context.state.savepayment = true
|
||||
console.log('disabled payment')
|
||||
console.log(context.state.savepayment)
|
||||
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,
|
||||
card: p[i].payment_card_id,
|
||||
edc: p[i].payment_edc_id,
|
||||
account: p[i].payment_account_id
|
||||
})
|
||||
}
|
||||
|
||||
// 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')
|
||||
context.state.savepayment = false
|
||||
} else {
|
||||
context.state.savepayment = false
|
||||
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) {
|
||||
let usr = one_user()
|
||||
console.log("yesy nota")
|
||||
console.log(usr)
|
||||
let ts = Date.now() / 1000 | 0
|
||||
let x = context.rootState.company.selected_mou
|
||||
let rpt_url = '/birt/run?__report=report/one/fo/rpt_t_003.rptdesign&PID='+a+'&username='+usr.M_UserUsername+'&__format=pdf&ts='+ts
|
||||
if (x.M_MouIsBill == 'Y')
|
||||
rpt_url = '/birt/run?__report=report/one/fo/rpt_t_006.rptdesign&__format=pdf&username='+usr.M_UserUsername+'&PID='+a+'&ts='+ts
|
||||
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + rpt_url, {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_notain (context, a) {
|
||||
let usr = one_user()
|
||||
console.log("yesy nota")
|
||||
console.log(usr)
|
||||
let ts = Date.now() / 1000 | 0
|
||||
let x = context.rootState.company.selected_mou
|
||||
let rpt_url = '/birt/run?__report=report/one/fo/rpt_t_003i.rptdesign&PID='+a+'&username='+usr.M_UserUsername+'&__format=pdf&ts='+ts
|
||||
if (x.M_MouIsBill == 'Y')
|
||||
rpt_url = '/birt/run?__report=report/one/fo/rpt_t_006.rptdesign&__format=pdf&username='+usr.M_UserUsername+'&PID='+a+'&ts='+ts
|
||||
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + rpt_url, {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_invoice (context, a) {
|
||||
let usr = one_user()
|
||||
console.log("yesy invoice")
|
||||
console.log(usr)
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&PID='+a+'&username='+usr.M_UserUsername+'&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_control_xx (context, a) {
|
||||
let usr = one_user()
|
||||
console.log("yesy control")
|
||||
console.log(usr)
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&PID='+a+'&username='+usr.M_UserUsername+'&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
async reset (context, prm) {
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.endshowtime(prm)
|
||||
if (resp.data.status != "OK") {
|
||||
|
||||
} else {
|
||||
location.reload()
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
async print_control (context, prm) {
|
||||
let usr = one_user()
|
||||
console.log("yesy control")
|
||||
console.log(usr)
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&PID='+prm.order_id+'&username='+usr.M_UserUsername+'&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
63
test/vuex/cpone-card-reader/modules/photo.js
Normal file
63
test/vuex/cpone-card-reader/modules/photo.js
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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: '/one-ui/undraw_tabs_tlxz.svg',
|
||||
default_photo_url: '/one-ui/undraw_tabs_tlxz.svg',
|
||||
patient_id: 0,
|
||||
resp_data: {},
|
||||
resp_msg: ''
|
||||
},
|
||||
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
|
||||
},
|
||||
|
||||
update_resp_data(state, data) {
|
||||
state.resp_data = data
|
||||
},
|
||||
|
||||
update_resp_msg(state, data) {
|
||||
state.resp_msg = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async upload(context) {
|
||||
try {
|
||||
console.log(context.rootState.patient.selected_patient)
|
||||
let resp = await api.upload(one_token(), context.rootState.patient.selected_patient.M_PatientID, context.state.photo_64)
|
||||
|
||||
if (resp.status != "OK") {
|
||||
context.commit('update_resp_data', resp.data.message)
|
||||
console.log(resp)
|
||||
} else {
|
||||
context.commit('update_photo_url', resp.data.photo_url);
|
||||
context.commit('update_dialog_photo', false)
|
||||
context.commit('update_resp_data', resp.data.data)
|
||||
context.commit('update_resp_msg', resp.data.message)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
709
test/vuex/cpone-card-reader/modules/px.js
Normal file
709
test/vuex/cpone-card-reader/modules/px.js
Normal file
@@ -0,0 +1,709 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/px.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_token: {},
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
tests: [],
|
||||
total_test: 0,
|
||||
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: [],
|
||||
|
||||
citos: [],
|
||||
selected_cito: null,
|
||||
is_cito: "N"
|
||||
},
|
||||
mutations: {
|
||||
update_search_token(state, val) {
|
||||
state.search_token = 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
|
||||
},
|
||||
|
||||
update_citos(state, val) {
|
||||
state.citos = val.records
|
||||
},
|
||||
|
||||
update_selected_cito(state, val) {
|
||||
state.selected_cito = val
|
||||
},
|
||||
|
||||
update_is_cito(state, val) {
|
||||
state.is_cito = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async packet_reqs(context,prm) {
|
||||
console.log(prm)
|
||||
context.commit("update_search_panel_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.packet_reqs(prm)
|
||||
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 req = resp.data
|
||||
console.log(req)
|
||||
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: req[i]['tests'],
|
||||
label: req[i]['req_name'],
|
||||
error_message: 'Hasil harus di isi',
|
||||
is_error: true,
|
||||
checked : false,
|
||||
note: '',
|
||||
req_id: req[i]['req_id']
|
||||
})
|
||||
}
|
||||
else{
|
||||
if(req[i]['tests'].length > 0){
|
||||
req[i]['tests'].forEach(function(xtestid) {
|
||||
if(reqs[found].px_id.indexOf(xtestid) == -1)
|
||||
reqs[found].px_id.push(xtestid)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
context.commit('update_requirement', reqs)
|
||||
console.log('selesai paket req')
|
||||
context.commit('order/update_loading_data_patient', true, { root: true })
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
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 cito = context.state.cito.test
|
||||
if(cito.length > 0){
|
||||
let cito_idx = cito.indexOf(test.T_TestID)
|
||||
if (cito_idx > -1)
|
||||
cito.splice(cito_idx, 1)
|
||||
}
|
||||
|
||||
let tests = context.state.tests
|
||||
if (tests == undefined ) tests = []
|
||||
let idx_exist_test = _.findIndex(tests, function(o) { return o.T_TestID == test.T_TestID })
|
||||
if(idx_exist_test > -1){
|
||||
tests.splice(idx_exist_test, 1)
|
||||
}
|
||||
tests.push(test)
|
||||
|
||||
|
||||
//context.dispatch("search")
|
||||
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
|
||||
if(px.px_type !== 'PN'){
|
||||
for (let i = req.length - 1; i >= 0; i-- ) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
else{
|
||||
px.child_test.forEach(function(entry){
|
||||
for (let i = req.length - 1; i >= 0; i-- ) {
|
||||
let x = _.indexOf(req[i].px_id, entry.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)
|
||||
},
|
||||
|
||||
async search(context) {
|
||||
if (!one_token()) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", 'No TOKEN Found')
|
||||
|
||||
context.commit('update_message_error', 'Maaf, koneksi Anda sempat terputus silahkan Log Out dan Login kembali', {root:true})
|
||||
context.commit('update_dialog_error', true, {root:true})
|
||||
return
|
||||
}
|
||||
|
||||
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 search_token = context.state.search_token
|
||||
if (search_token.hasOwnProperty("token")) {
|
||||
console.log('CancelToken', search_token.token)
|
||||
search_token.cancel()
|
||||
}
|
||||
search_token = axios.CancelToken.source()
|
||||
context.commit("update_search_token",search_token)
|
||||
console.log('CancelToken Start',search_token.token)
|
||||
|
||||
//clear the result 1st
|
||||
let data = {
|
||||
records : [],
|
||||
total: 0
|
||||
}
|
||||
context.commit("update_tests",data)
|
||||
console.log('selesai dari px.js')
|
||||
let resp= await api.search(mouCompanyID, context.state.search, search_token.token )
|
||||
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
|
||||
}
|
||||
/////////////////////////////
|
||||
var dadata = []
|
||||
var xdata = resp.data.records
|
||||
let selected_test = context.state.selected_test
|
||||
xdata.forEach( function(t,idx) {
|
||||
if (t.px_type == "PR" ){
|
||||
var xchk = true
|
||||
t.child_test.forEach( function(natx){
|
||||
var idxx =_.findIndex(selected_test, function(o) { return o.T_TestID == natx.T_TestID })
|
||||
if(idxx !== -1){
|
||||
xchk = false
|
||||
}
|
||||
})
|
||||
if(xchk){
|
||||
dadata.push(t)
|
||||
}
|
||||
}
|
||||
else{
|
||||
var idxx =_.findIndex(selected_test, function(o) { return o.T_TestID == t.T_TestID })
|
||||
if(idxx === -1){
|
||||
dadata.push(t)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
var newdata = {
|
||||
records : dadata,
|
||||
total: dadata.length
|
||||
}
|
||||
context.commit("update_tests",newdata)
|
||||
|
||||
//////////////////////////////////////////////
|
||||
}
|
||||
|
||||
} 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
|
||||
console.log("kentut berot")
|
||||
console.log(prm.cito)
|
||||
for (let i in x) {
|
||||
if (x[i].T_TestID == prm.test_id) {
|
||||
if ((Math.round(resp.data.test_price) == 0 && x[i].T_TestForceSell != "Y") ||
|
||||
Math.round(resp.data.test_price) < 0 ) {
|
||||
alert('Pemeriksaan ini belum ada harga CITO-nya !')
|
||||
console.log(x[i].T_TestName)
|
||||
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)
|
||||
}
|
||||
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_message_error', 'satu...dua...tiga permen manis rasanya, coba cek agreement sepertinya sudah kadaluarsa', {root:true})
|
||||
//context.commit('update_dialog_error', true, {root:true})
|
||||
|
||||
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 )
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_cito(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_cito(one_token())
|
||||
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_citos", data)
|
||||
|
||||
for (let i in data.records)
|
||||
if (data.records[i].Nat_CitoIsDefault == "Y")
|
||||
context.commit('update_selected_cito', data.records[i])
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_pxs(context, id) {
|
||||
context.commit("update_search_status",1)
|
||||
// LOADING
|
||||
context.commit('update_dialog_loading', true, {root:true})
|
||||
|
||||
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_pxs(mouCompanyID, id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
|
||||
// LOADING
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
|
||||
let x = resp.data.records
|
||||
|
||||
for (let k in x) {
|
||||
// SEARCH NAT TEST
|
||||
let px = x[k]
|
||||
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)
|
||||
continue
|
||||
|
||||
let selected_test = context.state.selected_test
|
||||
let flag_found = false
|
||||
selected_test.forEach( function(t, idx) {
|
||||
if (t.T_TestID == px.T_TestID) {
|
||||
selected_test[idx] = px
|
||||
flag_found = true
|
||||
}
|
||||
})
|
||||
|
||||
if (!flag_found) {
|
||||
selected_test.push(px)
|
||||
}
|
||||
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.commit('update_nat_test')
|
||||
// END LOADING
|
||||
|
||||
}
|
||||
|
||||
context.dispatch('appx_schedule')
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
context.commit('history/update_history_dialog', false, {root:true})
|
||||
context.commit('change_tab', '02', {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async search_pxs_clinic(context, id) {
|
||||
context.commit("update_search_status",1)
|
||||
// LOADING
|
||||
context.commit('update_dialog_loading', true, {root:true})
|
||||
|
||||
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_pxs_clinic(mouCompanyID, id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
|
||||
// LOADING
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
|
||||
let x = resp.data.records
|
||||
|
||||
for (let k in x) {
|
||||
// SEARCH NAT TEST
|
||||
let px = x[k]
|
||||
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)
|
||||
continue
|
||||
|
||||
let selected_test = context.state.selected_test
|
||||
let flag_found = false
|
||||
selected_test.forEach( function(t, idx) {
|
||||
if (t.T_TestID == px.T_TestID) {
|
||||
selected_test[idx] = px
|
||||
flag_found = true
|
||||
}
|
||||
})
|
||||
|
||||
if (!flag_found) {
|
||||
selected_test.push(px)
|
||||
}
|
||||
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.commit('update_nat_test')
|
||||
// END LOADING
|
||||
|
||||
}
|
||||
|
||||
context.dispatch('appx_schedule')
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
context.commit('history/update_history_dialog', false, {root:true})
|
||||
context.commit('change_tab', '02', {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user