Simple C++ Functions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

1|Page

Table of Content

2|Page
1.0 Introduction

Due to THE COVID-19 pandemic, people's lifestyles have been affected in many ways. The
increased use of online services and applications are some of them. One of the many groups
affected are the patients that depend on prescribed medication from their local public or
government hospitals. With the rise of the pandemic, many hospitals are trying to handle the
sudden influx in cases, decided to postpone the appointments of their regular patients. As a
result, these patients have trouble acquiring new medication, particularly if the hospital
mentioned was designated to handle Covid cases. Therefore, some patients have resulted to
obtaining their medication from private pharmacies, which cost more. In this assignment, our
group were tasked to create a general text-based C++ program for government hospitals.

2.0 Proposed Solution

There are two users who used the system which are Admin Staff and Pharmacist. Below is
the functionality of the System:
Users Function
Admin Staff 1) Login
2) Modify Patient Credit/ Debit Card Details
3) Modify Patient Address
4) Update Appointment Date & Time
Pharmacist 1) Login
2)

3|Page
3.0 Pseudocode
Begin
Declare user as int

REPEAT
Display "====================================="
Display "Welcome to Hospital Management System!"
Display "====================================="
Display "Press 1 to login as Admin"
Display "Press 2 to login as Pharmacists"
Display "Press 3 to exit application"
Display "====================================="

Read user

IF(user <> 3)THEN


IF (user == 1) THEN
call AdminLogin()
ELSE
IF (user == 2) THEN
call PharmacistLogin()
ELSE
Display "Please only key in 1, 2 or 3"
ENDIF
ENDIF
ENDIF
UNTIL(user == 3)

Display "Application ended!"


Display "====================================="
End

4|Page
Function AdminLogin()

Declare existAdminId, existAdminPw, adminId, adminPW, bankName, typeOfCard, inputCard, address, city, state, inputAddr as string
Declare existPatRegNum, patRegNum, adminFunc, cardNumber, cardCvc, postCode as int
Declare apptDate, cardExp as date
Declare apptTime as time
Declare presList as array

Get existAdminId, existAdminPw from text files


Repeat
Display "Please insert AdminID and Password"
Read adminId, adminPW

Display "=========================================="

IF (existAdminId == adminId AND existAdminPw == adminPW) THEN


Display "Welcome " adminId "!"
ELSE
Display "Invalid AdminID or Password"
ENDIF
UNTIL(existAdminId == adminId AND existAdminPw == adminPW)

Repeat
Display "Enter patient registration number: "
Read patRegNum

IF (patRegNum <> -1) THEN


IF (existPatRegNum <> patRegNum) THEN
Display "Invalid Patient"
Display "=========================================="
ELSE
Display "Patient found!"

5|Page
Display "====================================="
Get apptDate, apptTime from text files

Display patName "’s Next Appointment Date is " apptDate ", " apptTime "."
Get presList from text files

Display "MedicineID Medicine Name Dosage "


Display "-------------- --------------------- -------------------"

DOWHILE(presList not EOF)


Display presList
ENDDO

REPEAT
Display "====================================="
Display "Press 1 to update credit / debit card"
Display "Press 2 to verify address"
Display "Press 3 to update appointment date & time"
Display "Press 4 to exit"
Display "====================================="

Read adminFunc
IF (adminFunc <> 4) THEN
IF (adminFunc == 1) THEN
Get bankName, typeOfCard, cardNumber, cardCvc, cardExp from text files

Display "Existing Card Details "


Display "====================================="
Display "Bank name: " bankName
Display "Type of card: " typeOfCard
Display "Credit card number: " cardNumber
Display "CVC: " cardCvc

6|Page
Display "Expiry Date: " cardExp
Display "====================================="

Display "Do you want to update? (Yes: Y/ No: N)"


Read inputCard
Display "====================================="

IF (inputCard == 'Y' OR inputCard == 'y') THEN


Display "Enter bank name: "
Read bankName
Display "Enter type of card: "
Read typeOfCard
Display "Enter credit card number: "
Read cardNumber
Display "Enter CVC: "
Read cardCvc
Display "Enter expiry Date: "
Read cardExp

Update bankName, typeOfCard, cardNumber, cardCvc, cardExp into text files


Display "Card Details update successfully!"
ENDIF
ELSE
IF (adminFunc == 2) THEN
Get address, city, state, postCode from text files

Display "Existing Address Details "


Display "====================================="
Display "Address : " address
Display "City : " city
Display "State : " state
Display "Postal Code : " postCode

7|Page
Display "====================================="

Display "Do you want to update? (Yes: Y/ No: N)"


Read inputAddr
Display "====================================="

IF (inputAddr == 'Y' OR inputAddr == 'y') THEN


Display "Enter Address: "
Read address
Display: "Enter City:"
Read city
Display "Enter State: "
Read state
Display "Enter Postal Code:"
Read postCode

Update address, city, state, postCode into text files


Display "Address update successfully!"
ENDIF
ELSE
IF (adminFunc == 3) THEN
Get apptDate, apptTime from text files
Display "Appointment Date : " apptDate
Display "Appointment Time : " apptTime

Display "========================================="
Display "Enter next Appointment Date: "
Read apptDate
Display "Enter next Appointment Time: "
Read apptTime

Update apptDate, apptTime into text files

8|Page
Display "Appointment Details update successfully!"
Display "==========================================="
Display "New Appointment Date : " apptDate
Display "New Appointment Time : " apptTime
ELSE
Display "Please only key in only 1,2,3,4!"
ENDIF
ENDIF
ENDIF
ENDIF
UNTIL(adminFunc == 4)
ENDIF
ENDIF
UNTIL(patRegNum == -1)
Return

Function PharmacistLogin()

Declare existPharmacistId, existPharmacistPw, pharmacistId, pharmacistPW, patName, address, city, state, medId, medName as string
Declare existPatRegNum, patRegNum, dosage, supplyDateAmount, quantity = 0, amountDispensed, cardNumber, postCode,
amountBoxes as int

Declare price, medPrice = 0.00, totalPrice = 0.00 as double


Declare apptDate, todayDate as date
Declare apptTime as time
Declare presList, billDetail as array

Get existPharmacistId, existPharmacistPw from text files


Repeat
Display "Please insert PharmacistID and Password"
Read pharmacistId, pharmacistPW

9|Page
Display "====================================="

IF (existPharmacistId == pharmacistId AND existPharmacistPw == pharmacistPW) THEN


Display "Welcome " pharmacistId "!"
ELSE
Display "Invalid PharmacistId or Password!"
ENDIF
UNTIL(existPharmacistId == pharmacistId AND existPharmacistPw == pharmacistPW)

Get existPatRegNum from text files


Repeat
Display "Enter patient registration number: "
Read patRegNum

IF (patRegNum <> -1) THEN

IF (existPatRegNum <> patRegNum) THEN


Display "Invalid Patient"
Display "=========================================="
ELSE
Display "Patient found!"
Display "=========================================="
Get patName, apptDate, apptTime from text files
Display patName "’s Next appointment Date is " apptDate ", " apptTime "."

supplyDateAmount = apptDate – todayDate

Get presList, price from text files


(Note: presList contains medId, medName, dosage)

Display "MedicineID Medicine Name Dosage "


Display "---------------- --------------------- -------------------"

10 | P a g e
DOWHILE(presList not EOF)
Display presList
quantity = dosage * supplyDateAmount

Display "Medicine amount needed is " quantity "."


Display "Enter amount of medicine (boxes)"
Read amountBoxes

medPrice = amountBoxes * price


totalPrice = totalPrice + medPrice

Write medId, medName, quantity, amountBoxes, medPrice, totalPrice into billDetail


ENDDO

Display "=========================================="
Display "Generating Receipt. Please Wait."
Display "=================================="
Display "ABC Pharmacist
Display "1, Jalan Ali 2,"
Display "Taman Abu, 56100 Kuala Lumpur"
Display "=================================="
Display "Name : " patName
Display "Reg. Number : " patRegNum
Display "Next Appt. Date : " apptDate
Display "Next Appt. Time : " apptTime
Display "Supply : " supplyDateAmount " days"
Display "=================================="
Display "MedicineID MedicineName Quantity (calculated) Quantity (dispensed) Price/unit Total Price
Display "======================================================================="
DOWHILE(billDetail not EOF)
Display billDetail
ENDDO

11 | P a g e
Get cardNumber from text file

Display "==============================================="
Display "Payment via Debit Card : " cardNumber
Display "Total Payable Amount : RM" totalPrice
Display "Date: " todayDate : todayDate
Display "==============================================="

Get patName, address, city, postCode, state from text file


Display "Ship From: ABC Pharmacist"
Display "1, Jalan Ali 2, Taman Abu, 56100 Kuala Lumpur."
Display "==============================================="
Display "Ship To: " patName
Display address ", " city ", " postCode state
Display "==============================================="
Display "Receipt & Delivery Label generated successfully!"
Display "Returning to Main Menu"
Display "======================================="
ENDIF
ENDIF
UNTIL(patRegNum == -1)
Return

12 | P a g e
System Output (Sample)
=====================================
Welcome to Hospital Management System!
=====================================
Press 1 to login as Admin
Press 2 to login as Pharmacists
Press 3 to exit application
=====================================
1
Please insert AdminID and Password
34552 wrongPw (Note: This is an example with wrong password)
=====================================
Invalid AdminID or Password
Please insert AdminID and Password
34552 correctPw (Note: This is an example with correct password)
=====================================
Welcome 34552!
Enter patient registration number:
112
Patient found!
=====================================
Abu’s Next Appointment Date is 30 October 2021, 2pm.
MedID MedName Dosage (/day)
======================================
H1002 Amlodipine 3 tablets
H1004 Perindopril 2 tablets
D2929 Insulin 300mg
======================================
Press 1 to update credit / debit card
Press 2 to verify address
Press 3 to update appointment date & time
Press 4 to exit
======================================
1
Existing Card Details
======================================
Bank Name : Maybank
Type of card : Debit Card
Card Number : 451297345612
CVC Number : 186
Expiry Date : 10/26
======================================
Do you want to update? (Yes: Y/ No: N)
Y
=====================================
Enter Bank Name :
Public Bank
Enter Type of card :
Debit Card
Enter Card Number :

13 | P a g e
413215794647
Enter CVC Number :
765
Enter Expiry Date :
08/25
Card Details update successfully!
======================================
Press 1 to update credit / debit card
Press 2 to verify address
Press 3 to update appointment date & time
Press 4 to exit
======================================
2
Existing Address Details
======================================
Address : 1, Jalan Abu 10, Taman Ali
City : Cheras
State : Kuala Lumpur
Postcode : 56000
======================================
Do you want to update? (Yes: Y/ No: N)
Y
=====================================
Enter Address :
3, Jalan Ali 6
Enter City :
Cheras
Enter State :
Kuala Lumpur
Enter Postcode :
56000
Patient Address Details update successfully!
======================================
Press 1 to update credit / debit card
Press 2 to verify address
Press 3 to update appointment date & time
Press 4 to exit
======================================
3
Current Appointment Date : 10 October 2021
Current Appointment Time : 2pm
======================================
Enter Next Appointment Date:
30 October 2021
Enter Next Appointment Time:
2pm
Appointment Details update successfully!
======================================
New Appointment Date is 30 October 2021
New Appointment Time is 2pm

14 | P a g e
======================================
Press 1 to update credit / debit card
Press 2 to verify address
Press 3 to update appointment date & time
Press 4 to exit
======================================
4
Enter patient Registration number:
-1
======================================
Welcome to Hospital Management System!
=====================================
Press 1 to login as Admin
Press 2 to login as Pharmacists
Press 3 to exit application
=====================================
2
Please insert PharmacistID and Password
98723 rightPw
=====================================
Welcome 98723!
Enter patient registration number:
112
Patient found!
=====================================
Abu’s Next Appointment Date is 30 October 2021, 2pm.
MedID MedName Dosage (/day)
======================================
H1002 Amlodipine 3 tablets
Medicine amount needed is 60.
Enter amount of medicine (boxes)
6
======================================
H1004 Perindopril 2 tablets
Medicine amount needed is 40.
Enter amount of medicine (boxes)
10
======================================
D2929 Insulin 30mg
Medicine amount needed is 600mg.
Enter amount of medicine (boxes/ strips)
4
======================================
Generating Receipt. Please Wait.
======================================
ABC Pharmacist
1, Jalan Ali 2,
Taman Abu, 56100 Kuala Lumpur
======================================
Name : Abu

15 | P a g e
Reg. Num : 112
Next Appt. Date : 30 October 2021
Next Appt. Time : 2pm
Supply : 20 days
======================================
MedID MedName Quantity(total) Quantity(dispensed) Price/Unit Total Price(RM)
==================================================================
H1002 Amlodipine 60 tablets 6 strips 10.00 60.00
H1004 Perindopril 40 tablets 10 boxes 20.00 200.00
D2929 Insulin 600 mg 4 bottles 15.00 60.00
==================================================================
Payment via Debit Card : 413215794647
Total Payable Amount : RM320.00
Payment Date : 10 October 2021
======================================
Ship From: ABC Pharmacist
1, Jalan Ali 2, Taman Abu, 56100 Kuala Lumpur.
======================================
Ship To : Abu
3, Jalan Ali 6, Taman Aman, Cheras, 56000 Kuala Lumpur
======================================
Receipt & Delivery Label generated successfully!
Returning to Main Menu
======================================
Enter patient registration number:
-1
======================================
Welcome to Hospital Management System!
=====================================
Press 1 to login as Admin
Press 2 to login as Pharmacists
Press 3 to exit application
=====================================
3
Application ended!
======================================

16 | P a g e

You might also like