Computer Science SBA
Computer Science SBA
DATE: 11/25/2024
Table of Contents
Problem Definition....................................................................................................................................3
Solution Selection......................................................................................................................................4
Narrative..................................................................................................................................................5
Coding of Program....................................................................................................................................6
Narrative..................................................................................................................................................6
User Documentation................................................................................................................................15
Problem Definition
The Medical Benefit Organization of Antigua and Barbuda was founded in 1979, in an effort to
provide free healthcare services to Antiguan citizens. They offer financial aid and
pharmaceutical supplies to those in need, as well as provide refunds for various medical tests.
They also donate various medical supplies to the local health clinics and the hospital.
Currently, the relationship between doctors, their patients, and the Medical Benefit Organization
of Antigua and Barbuda is inconvenient. When medication is prescribed to a patient, in order for
them to obtain it, they must first carry their prescription to the Medical Benefit office. In carrying
their prescription, they must endure long wait times, which poses difficult to those with busy
schedules. After the prescription has been collected by the medical benefit employees, it is filled
and then returned to the patient. The return process on the filled prescription may take a week at
most, which is especially inconvenient for those relying on said medication. As, there is no
notification system in place at the headquarters, one must check the status of their medication
every day.
information between these three parties could be executed seamlessly, and allow the Medical
In order to solve the issue between all parties involved, a code-run, patient information
management system was selected as the desired solution. The solution, programmed using C
language, aims to organize and store patient information, and allow for data manipulation from
Narrative
This pseudocode displays the inputs and the outputs of the patient information management system.
IF DOCTOR:
IF MB EMPLOYEE:
GET PRESCRIPTION FROM DOCTOR (READ data from .txt file, display data in a structure array
In this program, users that identify under the two categories provided,( Doctor or MB
Employee), are able to input information about a respective patient into a text file. The “main()”
function allows the user to select their category, and gives them the option of setting or reading
the prescription based on their category choice. The function “get_user_input()” accepts a value
representing the user category. The function “setPrescription” allows the user to enter patient
information, then stores it into a text file. The function then notifies the user that the file has been
sent to a medical benefit employee. The function “readPrescription” extracts the data from the
#include <stdio.h>
#include <string.h>
//FUNCTIONS
void enterPrescription() {
//This function takes the user's input and appends the data to
file.txt
//local variables
FILE *fh;
int age;
float height;
float weight;
char medical_condition[50];
char name[50];
char mbs_id[10];
char prescribed_medication[50];
fh = fopen("file.txt", "a");
if (fh != NULL)
{
fflush(stdin);
}
// if there was a problem opening the file, output an error
message
else printf("Error opening file.\n");
return;
void readPrescription() {
//This function reads file.txt and displays its data
FILE *fh;
fh = fopen("file.txt", "r");
if (fh != NULL)
{
// output each char of the file to the console one at a time
until end of file (EOF)
char c;
while ( (c = fgetc(fh)) != EOF )
putchar(c);
fclose(fh);
return;
}
void menu(void) {
//The program's menu
int selection;
printf("*********************************************************\
n");
printf("* *\
n");
printf("* Welcome to MBS *\
n");
printf("* *\
n");
printf("* Please Select an option *\
n");
printf("* *\
n");
printf("* 1 - Doctor *\
n");
printf("* *\
n");
printf("* 2 - MB Employee *\
n");
printf("* *\
n");
printf("*********************************************************\
n");
switch(selection) {
case 1:
// This case allows the user to enter patient data
enterPrescription();
break;
case 2:
// This case allows the user to retrieve patient data
readPrescription();
break;
default:
printf("Exiting...");
break;
}
}
// Main function
int main() {
menu();
//Calls the menu function;
}
Code Testing and Results
*This code was run using the Microsoft application “Visual Studio Code” *
Based on the image above, when the user inputs the integer ‘1’ , indicating that they are a
doctor, the program then asks the user to input the patient information, compiles the information
Based on the image above, when the user inputs the integer ‘2’ , indicating that they are a
medical benefit employee, the program then opens the text file including all the patient’s
Normal 1 was entered to Program should Program asked for Test was
employee