0% found this document useful (0 votes)
9 views

Computer Science SBA

CAPE Compsci SBA Example

Uploaded by

jazz dias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Computer Science SBA

CAPE Compsci SBA Example

Uploaded by

jazz dias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Centre Name: ST Anthony’s Secondary

Centre Number: 010024

Lecturer Name: Mr. Charles Edwards

Candidate Name: Jazz Dias

Candidate Number: 0100240097

Subject: Information Technology

DATE: 11/25/2024
Table of Contents

Problem Definition....................................................................................................................................3

Solution Selection......................................................................................................................................4

Narrative and Pseudocode........................................................................................................................5

Narrative..................................................................................................................................................5

Coding of Program....................................................................................................................................6

Narrative..................................................................................................................................................6

Code Testing and Results........................................................................................................................14

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.

By implementing an information technology solution, the process of exchanging materials and

information between these three parties could be executed seamlessly, and allow the Medical

Benefit scheme to run more efficiently.


Solution Selection

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

both doctors and medical benefit employees.


Narrative and Pseudocode

Narrative

This pseudocode displays the inputs and the outputs of the patient information management system.

GET USER NAME (Doctor, or MB Employee)

IF DOCTOR:

INPUT PATIENT INFORMATION AND PRESCRIPTION

SEND TO MB EMPLOYEE (SAVE INFO TO A .txt file)

IF MB EMPLOYEE:

GET PRESCRIPTION FROM DOCTOR (READ data from .txt file, display data in a structure array

called “prescriptions”, see page 32 of the sample sba)


Coding of Program
Narrative

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

text file and prints it out.

#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);

printf("Enter Patient Name : ");


//allows the user to enter input with spaces
scanf("%[^\n]", name);

//fflush function is used because the buffer needs to be


cleared after an input with spaces is entered.
fflush(stdin);
printf("Enter Patient MBS Number : ");
scanf("%[^\n]", mbs_id);
fflush(stdin);
printf("Enter Age : ");
scanf("%i", &age);
fflush(stdin);
printf("Enter Height (in meters): ");
scanf("%f", &height);
fflush(stdin);
printf("Enter Weight (in kilograms): ");
scanf("%f", &weight);
fflush(stdin);
printf("Enter Medical Condition : ");
scanf("%[^\n]", medical_condition);
fflush(stdin);
printf("Enter Medication : ");
scanf("%[^\n]", prescribed_medication);
fflush(stdin);

//Save the data from the variables to the file, separated by


a comma

fprintf(fh, "%s, ", name);


fprintf(fh, "%s, ", mbs_id);
fprintf(fh, "%i, ", age);
fprintf(fh, "%.2f, ", weight);
fprintf(fh, "%.2f, ", height);
fprintf(fh, "%s, ", medical_condition);
fprintf(fh, "%s\n", prescribed_medication);

// Send patient information and prescription to MB employee


printf("Sending patient information and prescription to MB
Employee...\n");

}
// 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);

// if there was a problem opening the file, output an error message


} else printf("Error opening file.\n");

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");

scanf("%i", &selection); //gets menu selection from the user, and


assigns it to the variable 'selection'

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

into a text file, and sends it to the medical benefit employee.

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

information. Previous patient text file history is also displayed.


Based on the image above, when the user inputs the integer ‘3’, which is not an option, the
program exits.
Test Plan

Type of Input Description Expected Result Actual Result Success Rate

Normal 1 was entered to Program should Program asked for Test was

choose user type register choice as patient information successful

‘Doctor’ and allow input and compiled

for patient information into a

information input text file. This text

and compile file was then sent to

information into a the medical benefit

text file. This text employee.

file is then sent to

the medical benefit

employee

Erroneous 3 was entered to Program should Program exited Test was

choose user type exit successful


Encoded File

Please see attached executable file of the code.

You might also like