Skip to content

Commit

Permalink
Merge branch 'summer24-dev' into orders/add-diagnoses-col
Browse files Browse the repository at this point in the history
  • Loading branch information
nathantew14 committed Dec 4, 2024
2 parents 1915428 + 2251bbf commit cdd1345
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions context/VillageContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions pages/records/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function PatientList() {

useEffect(() => {
filterPatients();
setCurrentPage(1);
}, [patientSearch, villageCode, patients]);

function handleSearchChange(e) {
Expand Down
25 changes: 24 additions & 1 deletion pages/records/patient-consultation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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(
Expand Down Expand Up @@ -301,6 +301,29 @@ 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);

console.log(pendingQuantity, quantityStockMedication);
// Alert when (pending order + current_order) > stock
if (
-pendingQuantity + Number(orderFormDetails.quantity) >
quantityStockMedication
) {
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;
}
}

const index = orders.findIndex(
order => order.medicine === orderFormDetails.medicine
);
Expand Down

0 comments on commit cdd1345

Please sign in to comment.