From 3c4cc9616b37139a17f307884ae16934b02bee1a Mon Sep 17 00:00:00 2001 From: Poh Anson <50758680+PohAnson@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:38:02 +0800 Subject: [PATCH 1/5] Fixing Pagination Bugs --- pages/records/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/pages/records/index.js b/pages/records/index.js index 9571fee9..d32a0a32 100644 --- a/pages/records/index.js +++ b/pages/records/index.js @@ -75,6 +75,7 @@ function PatientList() { useEffect(() => { filterPatients(); + setCurrentPage(1); }, [patientSearch, villageCode, patients]); function handleSearchChange(e) { From 11147c46ff7444f54054c74c0bf89e3f8d354806 Mon Sep 17 00:00:00 2001 From: Poh Anson <50758680+PohAnson@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:06:23 +0800 Subject: [PATCH 2/5] Implement negative medication alert MUST be merged with the backend `negative-medication-alert` --- pages/records/patient-consultation/index.js | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pages/records/patient-consultation/index.js b/pages/records/patient-consultation/index.js index 9a73ba2a..4ddd10d0 100644 --- a/pages/records/patient-consultation/index.js +++ b/pages/records/patient-consultation/index.js @@ -221,7 +221,7 @@ const PatientConsultation = () => { } } - function submitNewOrder() { + async function submitNewOrder() { // Non-existent medication check: check if orderFormDetails.medicine (which is the id) is === 0 (which is the default value in the state obj) if (orderFormDetails.medicine === 0) { toast.error( @@ -249,6 +249,26 @@ const PatientConsultation = () => { return; } + // get pending quantity of medicine requested + const pendingQuantity = await axiosInstance + .get(`/medications/${orderFormDetails.medicine}?order_status=PENDING`) + .then(res => res.data.pending_quantity); + + // Alert when (pending order + current_order) > stock + if ( + -pendingQuantity + Number(orderFormDetails.quantity) > + quantityStockMedication + ) { + let alertResult = confirm(`Insufficient Stock! + Pending: ${-pendingQuantity} + Requesting: ${orderFormDetails.quantity} + Current Stock: ${quantityStockMedication} - ${-pendingQuantity} = ${quantityStockMedication + pendingQuantity} + `); + if (!alertResult) { + return; + } + } + const index = orders.findIndex( order => order.medicine === orderFormDetails.medicine ); From 39500cb0d3eb61449d41eda31e15cb98255b68cd Mon Sep 17 00:00:00 2001 From: Ang Peng Xuan Date: Wed, 4 Dec 2024 11:41:29 +0800 Subject: [PATCH 3/5] Update readme with offline --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 631e387a..c62c5f0a 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,22 @@ Log into localhost with the credentials in the "Key Credentials" document. +5. Offline Setup + Change .env.local for the following variables (note that IP Address should be your static IP): + + ``` + NEXT_PUBLIC_OFFLINE='OFFLINE' + NEXT_PUBLIC_API_URL='https://192.168.1.100:3000/api/v1' + ``` + + Run the following command to start offline + + ``` + pnpm offline + ``` + + Refer to BackEnd offline Setup + ## Technology used 1. Node Version Manager [https://github.com/nvm-sh/nvm] From c986c4da2094d5b608cbb19287f9a496627f24f0 Mon Sep 17 00:00:00 2001 From: nathantew14 Date: Wed, 4 Dec 2024 11:47:31 +0800 Subject: [PATCH 4/5] fix undefined village code in side menu when loading for the first time; default to ALL --- context/VillageContext.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/context/VillageContext.js b/context/VillageContext.js index a29d5e22..aaf229b0 100644 --- a/context/VillageContext.js +++ b/context/VillageContext.js @@ -6,10 +6,11 @@ export const VillageContext = createContext(); export const useLoading = () => useContext(LoadingContext); export const VillageProvider = ({ children }) => { - const [village, setVillageState] = useState(undefined); + const [village, setVillageState] = useState('ALL'); useEffect(() => { - setVillageState(localStorage.getItem('village')); + const cachedVillage = localStorage.getItem('village'); + cachedVillage && setVillageState(cachedVillage); }, []); function setVillage(village) { From 690d54a16ea369cbb6cfc65e7952abe42b5e5c29 Mon Sep 17 00:00:00 2001 From: davidgohzk Date: Wed, 4 Dec 2024 12:07:09 +0800 Subject: [PATCH 5/5] add more description --- pages/records/patient-consultation/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pages/records/patient-consultation/index.js b/pages/records/patient-consultation/index.js index 4ddd10d0..c4eacc07 100644 --- a/pages/records/patient-consultation/index.js +++ b/pages/records/patient-consultation/index.js @@ -254,15 +254,18 @@ const PatientConsultation = () => { .get(`/medications/${orderFormDetails.medicine}?order_status=PENDING`) .then(res => res.data.pending_quantity); + console.log(pendingQuantity, quantityStockMedication); // Alert when (pending order + current_order) > stock if ( -pendingQuantity + Number(orderFormDetails.quantity) > quantityStockMedication ) { - let alertResult = confirm(`Insufficient Stock! - Pending: ${-pendingQuantity} - Requesting: ${orderFormDetails.quantity} - Current Stock: ${quantityStockMedication} - ${-pendingQuantity} = ${quantityStockMedication + pendingQuantity} + const alertResult = confirm(` + Warning (can ignore if ok) + Potentially Insufficient Stock! + Currently Requesting: ${orderFormDetails.quantity} + Total Potential Pending: ${-pendingQuantity} + Potentially Remaining: ${quantityStockMedication} - ${-pendingQuantity} = ${quantityStockMedication + pendingQuantity} `); if (!alertResult) { return;