79 lines
2.0 KiB
JavaScript
79 lines
2.0 KiB
JavaScript
const URL = "/one-api/fisik/riwayatformv2/";
|
|
|
|
// Flag object untuk memonitor status request masing-masing fungsi
|
|
let isRequestingFlags = {
|
|
get_patient:false,
|
|
get_riwayat:false,
|
|
save_riwayat:false
|
|
};
|
|
|
|
export async function getPatient(prm) {
|
|
if (isRequestingFlags.get_patient) {
|
|
return { status: "ERR", message: "Request get patient in progress" };
|
|
}
|
|
|
|
isRequestingFlags.get_patient = true;
|
|
|
|
try {
|
|
var url_now = 'get_patient';
|
|
|
|
var resp = await axios.post(URL + url_now, prm);
|
|
if (resp.status != 200) {
|
|
return { status: "ERR", message: resp.statusText };
|
|
}
|
|
let data = resp.data;
|
|
return data;
|
|
} catch (e) {
|
|
return { status: "ERR", message: e.message };
|
|
} finally {
|
|
isRequestingFlags.get_patient = false;
|
|
}
|
|
}
|
|
|
|
export async function getRiwayat(prm) {
|
|
if (isRequestingFlags.get_riwayat) {
|
|
return { status: "ERR", message: "Request get riwayat in progress" };
|
|
}
|
|
|
|
isRequestingFlags.get_patient = true;
|
|
|
|
try {
|
|
var url_now = 'get_riwayat';
|
|
|
|
var resp = await axios.post(URL + url_now, prm);
|
|
if (resp.status != 200) {
|
|
return { status: "ERR", message: resp.statusText };
|
|
}
|
|
let data = resp.data;
|
|
return data;
|
|
} catch (e) {
|
|
return { status: "ERR", message: e.message };
|
|
} finally {
|
|
isRequestingFlags.get_patient = false;
|
|
}
|
|
}
|
|
|
|
|
|
export async function saveRiwayat(prm) {
|
|
if (isRequestingFlags.save_riwayat) {
|
|
return { status: "ERR", message: "Request save riwayat in progress" };
|
|
}
|
|
|
|
isRequestingFlags.get_patient = true;
|
|
|
|
try {
|
|
var url_now = 'save_riwayat';
|
|
|
|
var resp = await axios.post(URL + url_now, prm);
|
|
if (resp.status != 200) {
|
|
return { status: "ERR", message: resp.statusText };
|
|
}
|
|
let data = resp.data;
|
|
return data;
|
|
} catch (e) {
|
|
return { status: "ERR", message: e.message };
|
|
} finally {
|
|
isRequestingFlags.get_patient = false;
|
|
}
|
|
}
|