368 lines
12 KiB
JavaScript
368 lines
12 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/patient.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id: -1,
|
|
last_saved_id: -1,
|
|
x_addr_id: 0,
|
|
act: 'edit',
|
|
act_addr: 'new',
|
|
get_data_status: 0,
|
|
search_patient: 0,
|
|
search_status: 0,
|
|
search_error_message: '',
|
|
norm: '',
|
|
patient_prefix: '',
|
|
patient_name: '',
|
|
patient_suffix: '',
|
|
titles: [],
|
|
selected_title: {},
|
|
dob: '',
|
|
patients: [],
|
|
total_patients: 0,
|
|
patient_address: [],
|
|
sexes: [],
|
|
selected_sex: {},
|
|
religions: [],
|
|
selected_religion: {},
|
|
phone: '',
|
|
hp: '',
|
|
email: '',
|
|
pob: '',
|
|
kartuidentitass: [],
|
|
selected_kartuidentitas: {},
|
|
noidentitas: '',
|
|
note: '',
|
|
nik: '',
|
|
jabatan: '',
|
|
kedudukan: '',
|
|
pj: '',
|
|
location: '',
|
|
job: '',
|
|
total_patient: 0,
|
|
selected_patient: {},
|
|
save_status: 0,
|
|
btn_save_seen: true,
|
|
pgrs_save: false,
|
|
save_error_message: '',
|
|
no_save: 0,
|
|
open_alert_confirmation: false,
|
|
alert_success: false,
|
|
msg_success: "",
|
|
dialog_success: false,
|
|
dialog_confirmation_delete: false,
|
|
msg_confirmation_delete: "",
|
|
dialog_confirmation_delete_addr: false,
|
|
msg_confirmation_delete_addr: "",
|
|
autocomplete_status: 0,
|
|
dialog_form_address: false,
|
|
label_address: '',
|
|
addresses: [],
|
|
cities: [],
|
|
city_address: {},
|
|
districts: [],
|
|
district_address: {},
|
|
kelurahans: [],
|
|
kelurahan_address: {},
|
|
description_address: '',
|
|
errors: [],
|
|
current_page:1,
|
|
onsearch:false,
|
|
details:[],
|
|
name:''
|
|
},
|
|
mutations: {
|
|
update_name(state, val) {
|
|
state.name = val
|
|
},
|
|
update_details(state, val) {
|
|
state.details = val
|
|
},
|
|
update_onsearch(state, val) {
|
|
state.onsearch = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_x_addr_id(state, val) {
|
|
state.x_addr_id = val
|
|
},
|
|
update_last_id(state, val) {
|
|
state.last_id = val
|
|
},
|
|
update_last_saved_id(state, val) {
|
|
state.last_saved_id = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_act_addr(state, val) {
|
|
state.act_addr = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_search_error_message(state, patient) {
|
|
state.search_error_message = patient
|
|
},
|
|
update_search_patient(state, patient) {
|
|
state.search_patient = patient
|
|
},
|
|
update_dob(state, val) {
|
|
state.dob = val
|
|
},
|
|
update_patient_prefix(state, val) {
|
|
state.patient_prefix= val
|
|
},
|
|
update_patient_name(state, val) {
|
|
state.patient_name = val
|
|
},
|
|
update_patient_suffix(state, val) {
|
|
state.patient_suffix = val
|
|
},
|
|
update_norm(state, val) {
|
|
state.norm = val
|
|
},
|
|
update_titles(state, val) {
|
|
state.titles = val
|
|
},
|
|
update_selected_title(state, val) {
|
|
state.selected_title = val
|
|
},
|
|
update_patients(state, data) {
|
|
state.patients = data
|
|
},
|
|
update_selected_patient(state, val) {
|
|
state.selected_patient = val
|
|
},
|
|
update_sexes(state, val) {
|
|
state.sexes = val
|
|
},
|
|
update_selected_sex(state, val) {
|
|
state.selected_sex = val
|
|
},
|
|
update_religions(state, val) {
|
|
state.religions = val
|
|
},
|
|
update_selected_religion(state, val) {
|
|
state.selected_religion = val
|
|
},
|
|
update_phone(state, val) {
|
|
state.phone = val
|
|
},
|
|
update_email(state, val) {
|
|
state.email = val
|
|
},
|
|
update_pob(state, val) {
|
|
state.pob = val
|
|
},
|
|
update_hp(state, val) {
|
|
state.hp = val
|
|
},
|
|
update_kartuidentitass(state, val) {
|
|
state.kartuidentitass = val
|
|
},
|
|
update_selected_kartuidentitas(state, val) {
|
|
state.selected_kartuidentitas = val
|
|
},
|
|
update_noidentitas(state, val) {
|
|
state.noidentitas = val
|
|
},
|
|
update_note(state, val) {
|
|
state.note = val
|
|
},
|
|
update_nik(state, val) {
|
|
state.nik = val
|
|
},
|
|
update_jabatan(state, val) {
|
|
state.jabatan = val
|
|
},
|
|
update_kedudukan(state, val) {
|
|
state.kedudukan = val
|
|
},
|
|
update_pj(state, val) {
|
|
state.pj = val
|
|
},
|
|
update_location(state, val) {
|
|
state.location = val
|
|
},
|
|
update_job(state, val) {
|
|
state.job = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_btn_save_seen(state, val) {
|
|
state.btn_save_seen = val
|
|
},
|
|
update_pgrs_save(state, val) {
|
|
state.pgrs_save = val
|
|
},
|
|
update_save_error_message(state, msg) {
|
|
state.save_error_message = ''
|
|
},
|
|
update_no_save(state, val) {
|
|
state.no_save = val
|
|
},
|
|
update_open_alert_confirmation(state, val) {
|
|
state.open_alert_confirmation = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_dialog_success(state, val) {
|
|
state.dialog_success = val
|
|
},
|
|
update_dialog_confirmation_delete(state, val) {
|
|
state.dialog_confirmation_delete = val
|
|
},
|
|
update_msg_confirmation_delete(state, val) {
|
|
state.msg_confirmation_delete = val
|
|
},
|
|
update_dialog_confirmation_delete_addr(state, val) {
|
|
state.dialog_confirmation_delete_addr = val
|
|
},
|
|
update_msg_confirmation_delete_addr(state, val) {
|
|
state.msg_confirmation_delete_addr = val
|
|
},
|
|
update_addresses(state, val) {
|
|
state.addresses = val
|
|
},
|
|
update_autocomplete_status(state, val) {
|
|
state.autocomplete_status = val
|
|
},
|
|
update_dialog_form_address(state, val) {
|
|
state.dialog_form_address = val
|
|
},
|
|
update_label_address(state, val) {
|
|
state.label_address = val
|
|
},
|
|
update_cities(state, val) {
|
|
state.cities = val
|
|
},
|
|
update_city_address(state, val) {
|
|
state.city_address = val
|
|
},
|
|
update_districts(state, val) {
|
|
state.districts = val
|
|
},
|
|
update_district_address(state, val) {
|
|
state.district_address = val
|
|
},
|
|
update_kelurahans(state, val) {
|
|
state.kelurahans = val
|
|
},
|
|
update_kelurahan_address(state, val) {
|
|
state.kelurahan_address = val
|
|
},
|
|
update_description_address(state, val) {
|
|
state.description_address = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_total_patients(state, val) {
|
|
state.total_patients = val
|
|
},
|
|
update_total_patient(state, val) {
|
|
state.total_patient = val
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_patient", 1)
|
|
try {
|
|
context.commit("update_onsearch", true)
|
|
prm.token = one_token()
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_onsearch", false)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_patient", 2)
|
|
context.commit("update_search_error_message", "")
|
|
context.commit("update_onsearch", false)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_patients", data.records)
|
|
context.commit("update_total_patient", data.total)
|
|
context.commit("update_no_save", 0)
|
|
if (prm.lastid === -1) {
|
|
context.commit("update_selected_patient", data.records[0])
|
|
var pat = data.records[0]
|
|
context.dispatch("gettemplatedetail",pat)
|
|
//console.log(pat.M_PatientNoReg)
|
|
|
|
} else {
|
|
let arrpatient = context.state.patients
|
|
var idx = _.findIndex(arrpatient, item => item.NonlabTemplateMappingID === prm.lastid)
|
|
context.commit("update_selected_patient", data.records[idx])
|
|
var pat = data.records[idx]
|
|
context.dispatch("gettemplatedetail",pat)
|
|
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_onsearch", false)
|
|
context.commit("update_search_patient", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async gettemplatedetail(context,prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.gettemplatedetail(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_details", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async save(context,prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.save(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
} else {
|
|
context.commit("update_pgrs_save", false)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.dispatch("search", {name:context.state.name,lastid:context.state.selected_patient.NonlabTemplateMappingID})
|
|
context.dispatch("update_get_data_status", 2)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
}
|
|
}
|
|
}
|
|
} |