481 lines
14 KiB
JavaScript
481 lines
14 KiB
JavaScript
const URL = "/one-api/mockup/sampling-lab-mobile-cpone-v12/";
|
|
|
|
// Flag object untuk memonitor status request masing-masing fungsi
|
|
let isRequestingFlags = {
|
|
searchPatient: false,
|
|
scanPatient: false,
|
|
search: false,
|
|
searchCompany: false,
|
|
lookupStatuses: false,
|
|
getDataBarcodes: false,
|
|
serahkan: false,
|
|
getStations: false,
|
|
getLocation: false,
|
|
skipAction: false,
|
|
scanBarcode: false,
|
|
saveBBTB: false,
|
|
saveVisusBW: false,
|
|
saveGlucoses: false,
|
|
savePhlebotomy: false,
|
|
saveAudiometri: false,
|
|
saveSpirometri: false,
|
|
getSpirometriTemplate: false,
|
|
saveQuestionerSpirometri: false,
|
|
getAudiometriTemplate: false,
|
|
saveQuestionerAudiometri: false
|
|
};
|
|
|
|
export async function saveQuestionerSpirometri(prm) {
|
|
if (isRequestingFlags.saveQuestionerSpirometri) {
|
|
return { status: "ERR", message: "Request saveQuestionerSpirometri in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveQuestionerSpirometri = true;
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/saveQuestionerSpirometri', 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.saveQuestionerSpirometri = false;
|
|
}
|
|
}
|
|
|
|
export async function search_patient(prm) {
|
|
if (isRequestingFlags.searchPatient) {
|
|
return { status: "ERR", message: "Request search patient in progress" };
|
|
}
|
|
|
|
isRequestingFlags.searchPatient = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/search_patient', 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.searchPatient = false;
|
|
}
|
|
}
|
|
|
|
export async function scan_patient(prm) {
|
|
if (isRequestingFlags.scanPatient) {
|
|
return { status: "ERR", message: "Request scan in progress" };
|
|
}
|
|
|
|
isRequestingFlags.scanPatient = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/scan_patient', 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.scanPatient = false;
|
|
}
|
|
}
|
|
|
|
export async function search(prm) {
|
|
if (isRequestingFlags.search) {
|
|
return { status: "ERR", message: "Request search in progress" };
|
|
}
|
|
|
|
isRequestingFlags.search = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/search', 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.search = false;
|
|
}
|
|
}
|
|
|
|
export async function searchcompany(token, prm) {
|
|
if (isRequestingFlags.searchCompany) {
|
|
return { status: "ERR", message: "Request search company in progress" };
|
|
}
|
|
|
|
isRequestingFlags.searchCompany = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/searchcompany', { token: token, search: 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.searchCompany = false;
|
|
}
|
|
}
|
|
|
|
export async function lookup_statuses(prm) {
|
|
if (isRequestingFlags.lookupStatuses) {
|
|
return { status: "ERR", message: "Request lookup_statuses in progress" };
|
|
}
|
|
|
|
isRequestingFlags.lookupStatuses = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/lookup_statuses', 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.lookupStatuses = false;
|
|
}
|
|
}
|
|
|
|
export async function getdatabarcodes(prm) {
|
|
if (isRequestingFlags.getDataBarcodes) {
|
|
return { status: "ERR", message: "Request getdatabarcodes in progress" };
|
|
}
|
|
|
|
isRequestingFlags.getDataBarcodes = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/lookup_barcodes', 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.getDataBarcodes = false;
|
|
}
|
|
}
|
|
|
|
export async function serahkan(prm) {
|
|
if (isRequestingFlags.serahkan) {
|
|
return { status: "ERR", message: "Request serahkan in progress" };
|
|
}
|
|
|
|
isRequestingFlags.serahkan = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/serahkan', 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.serahkan = false;
|
|
}
|
|
}
|
|
|
|
export async function getstations(token) {
|
|
if (isRequestingFlags.getStations) {
|
|
return { status: "ERR", message: "Request getstations in progress" };
|
|
}
|
|
|
|
isRequestingFlags.getStations = true;
|
|
|
|
try {
|
|
let prm = { token: token };
|
|
var resp = await axios.post(URL + 'patient/getstations', 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.getStations = false;
|
|
}
|
|
}
|
|
|
|
export async function getLocation(prm) {
|
|
if (isRequestingFlags.getLocation) {
|
|
return { status: "ERR", message: "Request getLocation in progress" };
|
|
}
|
|
|
|
isRequestingFlags.getLocation = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/getlocation', 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.getLocation = false;
|
|
}
|
|
}
|
|
|
|
export async function skipaction(prm) {
|
|
if (isRequestingFlags.skipAction) {
|
|
return { status: "ERR", message: "Request skipaction in progress" };
|
|
}
|
|
|
|
isRequestingFlags.skipAction = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/skipaction', 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.skipAction = false;
|
|
}
|
|
}
|
|
|
|
export async function scanbarcode(prm) {
|
|
if (isRequestingFlags.scanBarcode) {
|
|
return { status: "ERR", message: "Request scanbarcode in progress" };
|
|
}
|
|
|
|
isRequestingFlags.scanBarcode = true;
|
|
|
|
try {
|
|
var url_now = 'patient/scanbarcode';
|
|
if (prm.station.isnonlab !== "") {
|
|
url_now = 'patient/scanbarcode_nonlab';
|
|
}
|
|
|
|
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.scanBarcode = false;
|
|
}
|
|
}
|
|
|
|
|
|
export async function saveBBTB(prm) {
|
|
if (isRequestingFlags.saveBBTB) {
|
|
return { status: "ERR", message: "Request saveBBTB in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveBBTB = true;
|
|
|
|
try {
|
|
var url_now = 'patient/saveBBTB';
|
|
|
|
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.saveBBTB = false;
|
|
}
|
|
}
|
|
|
|
export async function savePhlebotomy(prm) {
|
|
if (isRequestingFlags.savePhlebotomy) {
|
|
return { status: "ERR", message: "Request savePhlebotomy in progress" };
|
|
}
|
|
|
|
isRequestingFlags.savePhlebotomy = true;
|
|
|
|
try {
|
|
var url_now = 'patient/savePhlebotomy';
|
|
|
|
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.savePhlebotomy = false;
|
|
}
|
|
}
|
|
|
|
|
|
export async function saveVisusBW(prm) {
|
|
if (isRequestingFlags.saveVisusBW) {
|
|
return { status: "ERR", message: "Request saveVisusBW in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveVisusBW = true;
|
|
|
|
try {
|
|
var url_now = 'patient/saveVisusBW';
|
|
|
|
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.saveVisusBW = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export async function saveGlucoses(prm) {
|
|
if (isRequestingFlags.saveGlucoses) {
|
|
return { status: "ERR", message: "Request saveGlucoses in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveGlucoses = true;
|
|
|
|
try {
|
|
var url_now = 'patient/saveGlucoses';
|
|
|
|
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.saveGlucoses = false;
|
|
}
|
|
}
|
|
|
|
export async function saveAudiometri(prm) {
|
|
if (isRequestingFlags.saveAudiometri) {
|
|
return { status: "ERR", message: "Request saveAudiometri in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveAudiometri = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/saveAudiometri', prm);
|
|
if (resp.status != 200) {
|
|
return { status: "ERR", message: resp.statusText };
|
|
}
|
|
return resp.data;
|
|
} catch (e) {
|
|
return { status: "ERR", message: e.message };
|
|
} finally {
|
|
isRequestingFlags.saveAudiometri = false;
|
|
}
|
|
}
|
|
|
|
export async function saveSpirometri(prm) {
|
|
if (isRequestingFlags.saveSpirometri) {
|
|
return { status: "ERR", message: "Request saveSpirometri in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveSpirometri = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/saveSpirometri', prm);
|
|
if (resp.status != 200) {
|
|
return { status: "ERR", message: resp.statusText };
|
|
}
|
|
return resp.data;
|
|
} catch (e) {
|
|
return { status: "ERR", message: e.message };
|
|
} finally {
|
|
isRequestingFlags.saveSpirometri = false;
|
|
}
|
|
}
|
|
|
|
export async function getSpirometriTemplate(prm) {
|
|
if (isRequestingFlags.getSpirometriTemplate) {
|
|
return { status: "ERR", message: "Request getSpirometriTemplate in progress" };
|
|
}
|
|
|
|
isRequestingFlags.getSpirometriTemplate = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/getSpirometriTemplate', 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.getSpirometriTemplate = false;
|
|
}
|
|
}
|
|
|
|
export async function getAudiometriTemplate(prm) {
|
|
if (isRequestingFlags.getAudiometriTemplate) {
|
|
return { status: "ERR", message: "Request getAudiometriTemplate in progress" };
|
|
}
|
|
|
|
isRequestingFlags.getAudiometriTemplate = true;
|
|
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/getAudiometriTemplate', 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.getAudiometriTemplate = false;
|
|
}
|
|
}
|
|
|
|
export async function saveQuestionerAudiometri(prm) {
|
|
if (isRequestingFlags.saveQuestionerAudiometri) {
|
|
return { status: "ERR", message: "Request saveQuestionerAudiometri in progress" };
|
|
}
|
|
|
|
isRequestingFlags.saveQuestionerAudiometri = true;
|
|
try {
|
|
var resp = await axios.post(URL + 'patient/saveQuestionerAudiometri', 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.saveQuestionerAudiometri = false;
|
|
}
|
|
} |