694 lines
26 KiB
JavaScript
694 lines
26 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,
|
|
patien_note:'',
|
|
provinces:[],
|
|
province_address:{},
|
|
address:'',
|
|
show_more:true,
|
|
keluhan:'',
|
|
dialogsuccessorder:false,
|
|
nomor_order:'',
|
|
titles_origin:[]
|
|
},
|
|
mutations: {
|
|
update_titles_origin(state, val) {
|
|
state.titles_origin = val
|
|
},
|
|
update_dialogsuccessorder(state, val) {
|
|
state.dialogsuccessorder = val
|
|
},
|
|
update_nomor_order(state, val) {
|
|
state.nomor_order = val
|
|
},
|
|
update_keluhan(state, val) {
|
|
state.keluhan = val
|
|
},
|
|
update_show_more(state, val) {
|
|
state.show_more = val
|
|
},
|
|
update_address(state, val) {
|
|
state.address = val
|
|
},
|
|
update_provinces(state, val) {
|
|
state.provinces = val
|
|
},
|
|
update_province_address(state, val) {
|
|
state. province_address = val
|
|
},
|
|
update_patien_note(state, val) {
|
|
state.patien_note = 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_status",false)
|
|
context.commit("update_search_error_message", "")
|
|
context.commit("update_onsearch", false)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
if(context.state.current_page === 1)
|
|
context.commit("update_patients",[])
|
|
|
|
//context.commit("update_patients", data.records)
|
|
context.commit("update_total_patient", data.total)
|
|
context.commit("update_no_save", 0)
|
|
//console.log(data.records)
|
|
if(data.records.length > 0){
|
|
if(context.state.patients && context.state.patients.length > 0){
|
|
var data_before = context.state.patients
|
|
//console.log(data_before)
|
|
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",data_before)
|
|
}
|
|
else{
|
|
context.commit("update_patients",data.records)
|
|
}
|
|
|
|
context.commit("update_show_more",true)
|
|
}
|
|
else{
|
|
context.commit("update_show_more",false)
|
|
context.commit("update_current_page",1)
|
|
}
|
|
|
|
|
|
}
|
|
} 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 getsexreg(context) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getsexreg(one_token())
|
|
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_sexes", data.records.sexes)
|
|
context.commit("update_religions", data.records.religions)
|
|
context.commit("update_titles", data.records.titles)
|
|
context.commit("update_titles_origin", data.records.titles)
|
|
context.commit("update_kartuidentitass", data.records.kartuidentitass)
|
|
|
|
|
|
if(!_.isEmpty(data.records.default_location)){
|
|
let location = data.records.default_location
|
|
context.commit("update_provinces", location.provinces)
|
|
context.commit("update_province_address", location.province_address)
|
|
context.commit("update_cities", location.cities)
|
|
context.commit("update_city_address", location.city_address)
|
|
context.commit("update_districts", location.districts)
|
|
context.commit("update_district_address", location.district_address)
|
|
context.commit("update_kelurahans", location.kelurahans)
|
|
context.commit("update_kelurahan_address", location.kelurahan_address)
|
|
}else{
|
|
context.dispatch("getprovinces")
|
|
}
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async save(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.save(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
} else {
|
|
context.commit("update_pgrs_save", false)
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_last_id", prm.M_PatientID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data pasien " + prm.M_PatientName + " sudah terupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
}
|
|
},
|
|
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)
|
|
context.commit("update_pgrs_save", false)
|
|
} else {
|
|
context.commit("update_pgrs_save", false)
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_selected_patient", {})
|
|
context.commit("update_keluhan", "")
|
|
context.commit("update_dialogsuccessorder", true)
|
|
let data = resp.data
|
|
context.commit("update_nomor_order", data.orderNumber)
|
|
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
}
|
|
},
|
|
async newpatient(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.newpatient(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_pgrs_save", false)
|
|
console.log(resp.data.id)
|
|
context.commit("update_last_id", resp.data.id)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data pasien " + prm.M_PatientName + " sudah tersimpan dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
}
|
|
},
|
|
async delete(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.xdelete(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_pgrs_save", false)
|
|
context.commit("update_last_id", 0)
|
|
context.commit("update_dialog_confirmation_delete", false)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data pasien " + prm.M_PatientName + " sudah dihapus dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_normupdate_norm", '')
|
|
context.commit("update_patient_prefix", '')
|
|
context.commit("update_patient_name", '')
|
|
context.commit("update_patient_suffix", '')
|
|
context.commit("update_selected_title", {})
|
|
context.commit("update_selected_sex", {})
|
|
context.commit("update_selected_religion", {})
|
|
context.commit("update_dob", '')
|
|
context.commit("update_hp", '')
|
|
context.commit("update_phone", '')
|
|
context.commit("update_email", '')
|
|
context.commit("update_pob", '')
|
|
context.commit("update_selected_kartuidentitas", {})
|
|
context.commit("update_noidentitas", '')
|
|
context.commit("update_note", '')
|
|
context.commit("update_nik", '')
|
|
context.commit("update_jabatan", '')
|
|
context.commit("update_kedudukan", '')
|
|
context.commit("update_pj", '')
|
|
context.commit("update_location", '')
|
|
context.commit("update_job", '')
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_pgrs_save", false)
|
|
}
|
|
},
|
|
async getaddress(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getaddress(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_addresses", data.records)
|
|
let location = data.records
|
|
context.commit("update_provinces", location.provinces)
|
|
context.commit("update_province_address", location.province_address)
|
|
context.commit("update_cities", location.cities)
|
|
context.commit("update_city_address", location.city_address)
|
|
context.commit("update_districts", location.districts)
|
|
context.commit("update_district_address", location.district_address)
|
|
context.commit("update_kelurahans", location.kelurahans)
|
|
context.commit("update_kelurahan_address", location.kelurahan_address)
|
|
context.commit("update_address",location.address.M_PatientAddressDescription)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async getprovinces(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.getprovinces(one_token())
|
|
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_provinces", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async getcities(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getcities(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_cities", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async getdistricts(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getdistricts(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 getkelurahans(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getkelurahans(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 savenewaddress(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.savenewaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_form_address", false)
|
|
context.commit("update_last_id", prm.M_PatientAddressM_PatientID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Penambahan data alamat pasien " + prm.M_PatientName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async saveeditaddress(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.saveeditaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_form_address", false)
|
|
context.commit("update_last_id", prm.M_PatientAddressM_PatientID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Perubahan data alamat pasien " + prm.M_PatientName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async deleteaddress(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.deleteaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_confirmation_delete_addr", false)
|
|
context.commit("update_last_id", prm.M_PatientAddressM_PatientID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Penghapusan data alamat " + prm.M_PatientAddressNote + " dari pasien " + prm.M_PatientName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async listpatient(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.listpatient(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_patients", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
}
|
|
}
|
|
} |