// 1 => LOADING // 2 => DONE // 3 => ERROR import * as api from "../api/patient.js" export default { namespaced: true, state: { lastidx: 0, lookup_status: 0, lookup_error_message: '', search_patient: 0, search_error_message: '', start_date: moment(new Date()).format('YYYY-MM-DD'), end_date: moment(new Date()).format('YYYY-MM-DD'), search: '', total_patiens: 0, total_filter_patiens: 0, total_patients_all: 0, patients: [], total_patient: 0, selected_patient: { totalbill: 0 }, save_error_message: '', statuses: [], selected_status: {}, open_alert_no_pay: false, msg_alert_no_pay: "Loh ... Gak jadi bayar dong ?", current_page: 1, total_page: 0, filters: [{ id: 'day', name: 'Hari ini' }, { id: 'notsampled', name: 'Belum sampling' }, { id: 'all', name: 'Tampilkan semua' }], selected_filter: { id: 'day', name: 'Hari ini' }, promise_dialog: false, promises: [], errors: [], save_status: 0, save_error_message: '', barcodes: [], dialog_barcode: false, autocomplete_status: 0, companies: [], selected_company: { id: 0, name: 'Semua' }, dialog_details: false, order_id: 0, noreg: '', data_patient: {}, data_riwayat: [], data_packet: [], data_tests: [], data_sample_lab: [], data_sample_lab_undone: [], data_sample_lab_done: [], data_sample_radiodiagnostic: [], data_sample_electromedic: [], data_sample_other: [], data_requirement: [], dialog_scanner: false, selected_patient: {}, sampletypes: [], act_scan: '', alert_msg: "", alert_status: false, isScanning: false, html5QrCode: null, stations: [], selected_station: {}, locations: [], selected_location: {}, get_data_status: 0, isdone: "X", url_labnumber: "", dialog_done: false, status_done: false, station_id: -1, location_id: -1, value_tb: '', value_bb: '', value_bf: '', tkod: '', tkos: '', dkod: '', dkos: '', btwrn: 'N', withCorection: false, visusAdd: '', odSph: '', odCyl: '', odX: '', osSph: '', osCyl: '', osX: '', colorBlindNumber: '', dialogError: false, errorMsg: 'Kode form harus diisi', urls: {}, glucoses:[], uuid_form:'', form_code:'', open_form_code:true, loading_form_code:false, dialog_riwayat_exist:false, dialog_success:false, dialog_error:false, error_msg:'' }, mutations: { update_error_msg(state,val){ state.error_msg = val }, update_dialog_error(state,val){ state.dialog_error = val }, update_dialog_success(state,val){ state.dialog_success = val }, update_dialog_riwayat_exist(state,val){ state.dialog_riwayat_exist = val }, update_data_riwayat(state,val){ state.data_riwayat = val }, update_loading_form_code(state,val){ state.loading_form_code = val }, update_open_form_code(state,val){ state.open_form_code = val }, update_form_code(state,val){ state.form_code = val }, update_uuid_form(state, val) { state.uuid_form = val }, update_glucoses(state, val) { state.glucoses = val }, update_urls(state, val) { state.urls = val }, update_btwrn(state, val) { state.btwrn = val }, update_dkod(state, val) { state.dkod = val }, update_dkos(state, val) { state.dkos = val }, update_tkod(state, val) { state.tkod = val }, update_tkos(state, val) { state.tkos = val }, update_value_bb(state, val) { state.value_bb = val }, update_value_bf(state, val) { state.value_bf = val }, update_value_tb(state, val) { state.value_tb = val }, update_location_id(state, val) { state.location_id = val }, update_station_id(state, val) { state.station_id = val }, update_status_done(state, val) { state.status_done = val }, update_dialog_done(state, val) { state.dialog_done = val }, update_url_labnumber(state, val) { state.url_labnumber = val }, update_isdone(state, val) { state.isdone = val }, update_get_data_status(state, val) { state.get_data_status = val }, update_locations(state, val) { state.locations = val }, update_selected_location(state, val) { state.selected_location = val }, update_stations(state, val) { state.stations = val }, update_selected_station(state, val) { state.selected_station = val }, update_html5QrCode(state, val) { state.html5QrCode = val }, update_isScanning(state, val) { state.isScanning = val }, update_alert_msg(state, val) { state.alert_msg = val }, update_alert_status(state, val) { state.alert_status = val }, update_act_scan(state, val) { state.act_scan = val }, update_sampletypes(state, val) { state.sampletypes = val }, update_selected_patient(state, val) { state.selected_patient = val }, update_dialog_scanner(state, val) { state.dialog_scanner = val }, update_data_sample_other(state, val) { state.data_sample_other = val }, update_data_sample_electromedic(state, val) { state.data_sample_electromedic = val }, update_data_sample_radiodiagnostic(state, val) { state.data_sample_radiodiagnostic = val }, update_data_sample_lab_undone(state, val) { state.data_sample_lab_undone = val }, update_data_sample_lab_done(state, val) { state.data_sample_lab_done = val }, update_data_sample_lab(state, val) { state.data_sample_lab = val }, update_data_tests(state, val) { state.data_tests = val }, update_data_packet(state, val) { state.data_packet = val }, update_data_patient(state, val) { state.data_patient = val }, update_order_id(state, val) { state.order_id = val }, update_noreg(state, val) { state.noreg = val }, update_dialog_details(state, val) { state.dialog_details = val }, update_companies(state, val) { state.companies = val }, update_selected_company(state, val) { state.selected_company = val }, update_dialog_barcode(state, val) { state.dialog_barcode = val }, update_statuses(state, val) { state.statuses = val }, update_total_patients_all(state, val) { state.total_patients_all = val }, update_save_status(state, val) { state.save_status = val }, update_save_error_message(state, val) { state.save_error_message = val }, update_lookup_error_message(state, val) { state.lookup_error_message = val }, update_lookup_status(state, status) { state.lookup_status = status }, update_promise_dialog(state, val) { state.promise_dialog = val }, update_promises(state, val) { state.promises = val }, update_errors(state, val) { state.errors = val }, update_lastidx(state, val) { state.lastidx = val }, update_selected_filter(state, val) { state.selected_filter = val }, update_filters(state, val) { state.filters = val }, update_total_page(state, val) { state.total_page = val }, update_total_patient(state, val) { state.total_patient = val }, update_current_page(state, val) { state.current_page = val }, update_search_error_message(state, patient) { state.search_error_message = patient }, update_search_patient(state, patient) { state.search_patient = patient }, update_patients(state, data) { state.patients = data }, update_selected_patient(state, val) { state.selected_patient = val }, update_start_date(state, val) { state.start_date = val }, update_autocomplete_status(state, val) { state.autocomplete_status = val }, update_end_date(state, val) { state.end_date = val }, update_search(state, val) { state.search = val }, update_selected_status(state, val) { state.selected_status = val }, update_open_alert_no_pay(state, val) { state.open_alert_no_pay = val }, update_msg_alert_no_pay(state, val) { state.msg_alert_no_pay = val }, update_data_requirement(state, val) { state.data_requirement = val }, update_withCorection(state, val) { state.withCorection = val }, update_odSph(state, val) { state.odSph = val }, update_odCyl(state, val) { state.odCyl = val }, update_odX(state, val) { state.odX = val }, update_osSph(state, val) { state.osSph = val }, update_osCyl(state, val) { state.osCyl = val }, update_osX(state, val) { state.osX = val }, update_colorBlindNumber(state, val) { state.colorBlindNumber = val }, update_visusAdd(state, val) { state.visusAdd = val }, update_dialogError(state, val) { state.dialogError = val }, update_errorMsg(state, val) { state.errorMsg = val }, }, actions: { async get_patient(context, prm) { context.commit("update_loading_form_code", true) try { let resp = await api.getPatient(prm) if (resp.status != "OK") { context.commit("update_loading_form_code", false) context.commit("update_open_form_code", true) context.commit("update_errorMsg", resp.message) console.log(context.state.errorMsg) context.commit("update_dialogError", true) } else { context.commit("update_loading_form_code", false) context.commit("update_open_form_code", false) context.commit("update_data_patient", resp.data.records) let check_local = localStorage.getItem("form_"+context.state.uuid_form) let dt_riwayat = JSON.parse(check_local) if(!check_local || dt_riwayat.length == 0 || resp.data.records.is_sampling === 'D'){ context.dispatch("get_riwayat") }else{ context.commit("update_data_riwayat", dt_riwayat) } } } catch (e) { context.commit("update_loading_form_code", false) } }, async get_riwayat(context){ context.commit("update_loading_form_code", true) let prm = {id:context.state.data_patient.xid} let resp = await api.getRiwayat(prm) if (resp.status != "OK") { context.commit("update_loading_form_code", false) context.commit("update_errorMsg", resp.message) context.commit("update_dialogError", true) } else { context.commit("update_loading_form_code", false) context.commit("update_data_riwayat", resp.data.records) localStorage.setItem("form_"+context.state.uuid_form, JSON.stringify(resp.data.records)) } }, async save_riwayat(context, prm){ let resp = await api.saveRiwayat(prm) if (resp.status != "OK") { context.commit("update_errorMsg", resp.message) context.commit("update_loading_form_code", false) context.commit("update_dialogError", true) }else{ context.commit("update_loading_form_code", false) let form_name = "form_"+context.state.uuid_form console.log(form_name) console.log(localStorage.getItem(form_name)) localStorage.removeItem(form_name) context.commit("update_dialog_success", true) context.commit("update_open_form_code", true) context.commit("update_data_riwayat", []) context.commit("update_data_patient", {}) context.commit("update_form_code", '') } } } }