621 lines
22 KiB
JavaScript
621 lines
22 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/form.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
form_act:'new',
|
|
step:'order',
|
|
btn_confirm:'hide',
|
|
btn_order:'hide',
|
|
do_btn_order:'hide',
|
|
disabled_register:false,
|
|
status_now:{id:1,code:'NEW'},
|
|
get_data_status:0,
|
|
get_data_error_message:'',
|
|
save_status:0,
|
|
save_error_message:'',
|
|
autocomplete_status:0,
|
|
dialog_form:false,
|
|
dialog_ordernumber:false,
|
|
msg_ordernumber:'',
|
|
title_ordernumber:'',
|
|
titles:[],
|
|
title:{},
|
|
patientname:'',
|
|
dob:'',
|
|
hp:'',
|
|
email:'',
|
|
phone:'',
|
|
sexs:[],
|
|
sex:{},
|
|
religions:[],
|
|
religion:{},
|
|
cities:[],
|
|
new_cities:[],
|
|
city:{},
|
|
new_city:{},
|
|
districts:[],
|
|
new_districts:[],
|
|
new_district:[],
|
|
district:{},
|
|
kelurahans:[],
|
|
new_kelurahans:[],
|
|
kelurahan:{},
|
|
new_kelurahan:{},
|
|
address:'',
|
|
new_address:'',
|
|
orderid:0,
|
|
orderpatients:[],
|
|
orderpatient:{},
|
|
orderadresss:[],
|
|
orderadress:{},
|
|
doctoradresss:[],
|
|
doctoradress:{},
|
|
ordertypes:[],
|
|
ordertype:{},
|
|
orderdate:moment(new Date()).format('YYYY-MM-DD'),
|
|
mindate:moment().subtract(1, 'days').toISOString(),
|
|
ordertimes:[],
|
|
ordertime:{},
|
|
orderphone:'',
|
|
orderautotests:[],
|
|
orderautotest:{},
|
|
ordertests:[],
|
|
deleted_ordertests:[],
|
|
staffs:[],
|
|
orderstaff:{},
|
|
orderdeliverytipes:[],
|
|
orderdeliverytype:{},
|
|
orderdeliveryaddress:'',
|
|
orderpatientdeliveryaddress:{},
|
|
orderdoctors:[],
|
|
orderdoctor:{},
|
|
patient_dob:'',
|
|
ordernote:'',
|
|
supplies_trx_id:0
|
|
},
|
|
mutations: {
|
|
update_step(state,val){
|
|
state.step = val
|
|
},
|
|
update_status_now(state,val){
|
|
state.status_now = val
|
|
},
|
|
update_disabled_register(state,val){
|
|
state.disabled_register = val
|
|
},
|
|
update_btn_confirm(state,val){
|
|
state.btn_confirm = val
|
|
},
|
|
update_do_btn_order(state,val){
|
|
state.do_btn_order = val
|
|
},
|
|
update_btn_order(state,val){
|
|
state.btn_order = val
|
|
},
|
|
update_form_act(state,val){
|
|
state.form_act = val
|
|
},
|
|
update_autocomplete_status(state,val){
|
|
state.autocomplete_status = val
|
|
},
|
|
update_search_city(state,val){
|
|
state.search_city = val
|
|
},
|
|
update_get_data_status(state,val){
|
|
state.get_data_status = val
|
|
},
|
|
update_save_status(state,val){
|
|
state.save_status = val
|
|
},
|
|
update_get_data_error_message(state,val){
|
|
state.get_data_error_message = val
|
|
},
|
|
update_save_error_message(state,val){
|
|
state.save_error_message = val
|
|
},
|
|
update_dialog_form(state,val) {
|
|
state.dialog_form = val
|
|
},
|
|
update_dialog_ordernumber(state,val) {
|
|
state.dialog_ordernumber = val
|
|
},
|
|
update_msg_ordernumber(state,val) {
|
|
state.msg_ordernumber = val
|
|
},
|
|
update_title_ordernumber(state,val) {
|
|
state.title_ordernumber = val
|
|
},
|
|
update_titles(state,data){
|
|
state.titles = data
|
|
},
|
|
update_title(state,val){
|
|
state.title = val
|
|
},
|
|
update_patientname(state,val){
|
|
state.patientname = val
|
|
},
|
|
update_dob(state,val){
|
|
state.dob = val
|
|
},
|
|
update_hp(state,val){
|
|
state.hp = val
|
|
},
|
|
update_phone(state,val){
|
|
state.phone = val
|
|
},
|
|
update_email(state,val){
|
|
state.email = val
|
|
},
|
|
update_sexs(state,data){
|
|
state.sexs = data
|
|
},
|
|
update_sex(state,val){
|
|
state.sex = val
|
|
},
|
|
update_religions(state,data){
|
|
state.religions = data
|
|
},
|
|
update_religion(state,val){
|
|
state.religion = val
|
|
},
|
|
update_cities(state,data){
|
|
state.cities = data
|
|
},
|
|
update_new_cities(state,data){
|
|
state.new_cities = data
|
|
},
|
|
update_city(state,val){
|
|
state.city = val
|
|
},
|
|
update_new_city(state,val){
|
|
state.new_city = val
|
|
},
|
|
update_districts(state,data){
|
|
state.districts = data
|
|
},
|
|
update_new_districts(state,data){
|
|
state.new_districts = data
|
|
},
|
|
update_district(state,val){
|
|
state.district = val
|
|
},
|
|
update_new_district(state,val){
|
|
state.new_district = val
|
|
},
|
|
update_kelurahans(state,data){
|
|
state.kelurahans = data
|
|
},
|
|
update_new_kelurahans(state,data){
|
|
state.new_kelurahans = data
|
|
},
|
|
update_kelurahan(state,val){
|
|
state.kelurahan = val
|
|
},
|
|
update_new_kelurahan(state,val){
|
|
state.new_kelurahan = val
|
|
},
|
|
update_address(state,val){
|
|
state.address = val
|
|
},
|
|
update_new_address(state,val){
|
|
state.new_address = val
|
|
},
|
|
update_orderid(state,val){
|
|
state.orderid = val
|
|
},
|
|
update_ordernote(state,val){
|
|
state.ordernote = val
|
|
},
|
|
update_orderpatients(state,data){
|
|
state.orderpatients = data
|
|
},
|
|
update_orderpatient(state,val){
|
|
state.orderpatient = val
|
|
},
|
|
update_orderadresss(state,data){
|
|
state.orderadresss = data
|
|
},
|
|
update_orderadress(state,data){
|
|
state.orderadress = data
|
|
},
|
|
update_doctoradresss(state,data){
|
|
state.doctoradresss = data
|
|
},
|
|
update_doctoradress(state,data){
|
|
state.doctoradress = data
|
|
},
|
|
update_ordertypes(state,data){
|
|
state.ordertypes = data
|
|
},
|
|
update_ordertype(state,val){
|
|
state.ordertype = val
|
|
},
|
|
update_orderdate(state,val){
|
|
state.orderdate = val
|
|
},
|
|
update_ordertimes(state,data){
|
|
state.ordertimes = data
|
|
},
|
|
update_ordertime(state,val){
|
|
state.ordertime = val
|
|
//console.log(state.ordertime)
|
|
},
|
|
update_orderphone(state,val){
|
|
state.orderphone = val
|
|
},
|
|
update_orderautotests(state,data){
|
|
state.orderautotests = data
|
|
},
|
|
update_orderautotest(state,val){
|
|
state.orderautotest = val
|
|
},
|
|
update_ordertests(state,data){
|
|
state.ordertests = data
|
|
},
|
|
update_deleted_ordertests(state,data){
|
|
state.deleted_ordertests = data
|
|
},
|
|
update_staffs(state,data){
|
|
state.staffs = data
|
|
},
|
|
update_orderstaff(state,val){
|
|
state.orderstaff = val
|
|
},
|
|
update_orderdeliverytipes(state,data){
|
|
state.orderdeliverytipes = data
|
|
},
|
|
update_orderdeliverytype(state,val){
|
|
state.orderdeliverytype = val
|
|
},
|
|
update_orderdeliveryaddress(state,val){
|
|
state.orderdeliveryaddress = val
|
|
},
|
|
update_orderpatientdeliveryaddress(state,val){
|
|
state.orderpatientdeliveryaddress = val
|
|
},
|
|
update_orderdoctors(state,data){
|
|
state.orderdoctors = data
|
|
},
|
|
update_orderdoctor(state,val){
|
|
state.orderdoctor = val
|
|
},
|
|
update_patient_dob(state,val){
|
|
state.patient_dob = val
|
|
},
|
|
update_supplies_trx_id(state,val){
|
|
state.supplies_trx_id = val
|
|
},
|
|
},
|
|
actions: {
|
|
async titsexreg(context) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.titsexreg(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
context.commit("update_get_data_error_message", "")
|
|
context.commit("update_titles", resp.data.records.titles)
|
|
context.commit("update_sexs", resp.data.records.sexs)
|
|
context.commit("update_religions", resp.data.records.religions)
|
|
context.commit("update_ordertypes", resp.data.records.ordertypes)
|
|
context.commit("update_staffs", resp.data.records.staffs)
|
|
context.commit("update_orderdeliverytipes", resp.data.records.deliverytipes)
|
|
context.commit("update_ordertimes", resp.data.records.times)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchcity(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchcity(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status",3)
|
|
} else {
|
|
context.commit("update_autocomplete_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_cities",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async searchnewcity(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchcity(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status",3)
|
|
} else {
|
|
context.commit("update_autocomplete_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_new_cities",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async getdistrict(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getdistrict(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async getnewdistrict(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getdistrict(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_new_districts",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async getkelurahan(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getkelurahan(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_kelurahans",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async getnewkelurahan(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getkelurahan(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_new_kelurahans",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async savenewpatient(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.savenewpatient(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
console.log(data.records[0])
|
|
context.commit("update_title",{})
|
|
context.commit("update_sex",{})
|
|
context.commit("update_religion",{})
|
|
context.commit("update_cities",[])
|
|
context.commit("update_city",{})
|
|
context.commit("update_districts",[])
|
|
context.commit("update_district",{})
|
|
context.commit("update_kelurahans",[])
|
|
context.commit("update_kelurahan",{})
|
|
context.commit("update_patientname","")
|
|
context.commit("update_dob","")
|
|
context.commit("update_hp","")
|
|
context.commit("update_phone","")
|
|
context.commit("update_email","")
|
|
context.commit("update_address","")
|
|
|
|
context.commit("update_orderpatients",data.records)
|
|
context.commit("update_orderpatient",data.records[0])
|
|
context.dispatch("getaddress",data.records[0])
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async getaddress(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
let resp= await api.getaddress(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_orderadresss",resp.data.records)
|
|
context.commit("update_orderadress",resp.data.records[0])
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async getdoctoraddress(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
let resp= await api.getdoctoraddress(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_doctoradresss",resp.data.records)
|
|
context.commit("update_doctoradress",resp.data.records[0])
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async searchpatient(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchpatient(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status",3)
|
|
} else {
|
|
context.commit("update_autocomplete_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_orderpatients",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async searchtest(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchtest(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status",3)
|
|
} else {
|
|
context.commit("update_autocomplete_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_orderautotests",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async searchdoctor(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchdoctor(one_token(),prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status",3)
|
|
} else {
|
|
context.commit("update_autocomplete_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_orderdoctors",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async saveorder(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.saveorder(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
let msg = "Order dengan nomor "+data.records[0].numberx+" berhasil dibuat"
|
|
|
|
context.commit("update_dialog_form",false)
|
|
context.commit("update_msg_ordernumber",msg)
|
|
context.commit("update_title_ordernumber",'Berhasil !')
|
|
context.commit("update_dialog_ordernumber",true)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async updateorder(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.updateorder(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
if(prm.act === 'update'){
|
|
|
|
let msg = 'Perubahan order '+data.records[0].numberx+' telah tersimpan'
|
|
|
|
context.commit("update_dialog_form",false)
|
|
context.commit("update_title_ordernumber",'Berhasil !')
|
|
context.commit("update_msg_ordernumber",msg)
|
|
context.commit("update_dialog_ordernumber",true)
|
|
|
|
//var prm = {fdate:prm.fdate,fstatus:prm.fstatus,ftype:prm.ftype}
|
|
}else{
|
|
let msg = "Order dengan nomor "+data.records.numberx+" berhasil dibuat"
|
|
context.commit("update_title_ordernumber",'Berhasil !')
|
|
context.commit("update_msg_ordernumber",msg)
|
|
context.commit("update_dialog_ordernumber",true)
|
|
}
|
|
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|