In: Computer Science
I need pesodocode of this code.
void claimProcess()
{
int id;
bool found = false;
system("cls");
printf("Enter patient ID for which you want to claim insurrence:
");
scanf("%d", & id);
int i;
for (i = 0; i < patientCount; i++)
{
if (patients[i].id == id)
{
found = true;
break;
}
}
if (found == false)
{
printf("subscriber not found\n");
return;
}
int numOfDaysHospitalized, suppliesCost, surgicalFee,
otherCharges;
bool ICU;
printf("How many days were you haspitalized: ");
scanf("%d", & numOfDaysHospitalized);
int ICUFlag;
do {
printf("Select A Ward Type\n1-Normal Ward 2-ICU: ");
scanf("%d", & ICUFlag);
} while (ICUFlag < 1 || ICUFlag > 2);
if (ICUFlag == 2)
ICU = true;
else
ICU = false;
printf("Enter Cost of Supplies and Services: ");
scanf("%d", & suppliesCost);
printf("Enter Surgical Fees: ");
scanf("%d", & surgicalFee);
printf("Enter Other Charges: ");
scanf("%d", & otherCharges);
int ICUCharges = 0;
if (ICU == true)
{
if (patients[i].plan == 1)
ICUCharges = numOfDaysHospitalized * 120;
else if (patients[i].plan == 2)
ICUCharges = numOfDaysHospitalized * 150;
else
ICUCharges = numOfDaysHospitalized * 200;
} else
{
if (patients[i].plan == 1)
ICUCharges = numOfDaysHospitalized * 250;
else if (patients[i].plan == 2)
ICUCharges = numOfDaysHospitalized * 400;
else
ICUCharges = numOfDaysHospitalized * 700;
}
int totalClaimAmount = numOfDaysHospitalized + suppliesCost +
surgicalFee + otherCharges + ICUCharges;
if (patients[i].annualClaim == true)
{
if (patients[i].age > 60)
{
printf("The subscriber age has exceeded the limit(60 Year), Not
Eligible");
return;
}
}
int j;
for (j = 0; j < patientCount; j++)
{
if (claims[j].id == patients[i].id)
break;
}
int amountToBeBorne = 0;
if (totalClaimAmount <= claims[j].remaininigAmount)
{
claims[j].amountClaimed += totalClaimAmount;
claims[j].remaininigAmount -= totalClaimAmount;
} else
{
amountToBeBorne = totalClaimAmount -
claims[j].remaininigAmount;
claims[j].amountClaimed += (totalClaimAmount -
amountToBeBorne);
claims[j].remaininigAmount = 0;
printf("\n\nThe amount that can be claimed is less then the claim
by subscriber. %d RM should be given by subscriber themselves\n",
amountToBeBorne);
}
FILE * fp;
fp = fopen("claims.txt", "w");
for (int i = 0; i < patientCount; i++)
fprintf(fp, "%d,%d,%d,%d\n", claims[i].id, claims[i].claimedYear,
claims[i].amountClaimed, claims[i].remaininigAmount);
fclose(fp);
printf("Subscriber ID: %d\nSubscriber Name: %s\nSubscriber Claimed
Year: %d\nSubscriber amount Claimed: %d\nSubscriber Remaining
Claimed: %d\n", claims[j].id, patients[i].name,
claims[j].claimedYear, claims[j].amountClaimed,
claims[j].remaininigAmount);
system("pause");
}
Here is the pseudocode for the above code:
Ask for patient ID
If id does not exist then show message and exit
Ask for number of days hospitalised
Ask if it is a ICU case or not
Ask for suppliesCost
Ask for Surgical fees
Ask for other charges
If it is ICU case:
if patient has plan 1:
make ICUCharges = numOfDaysHospitalized * 120
else if patient has plan 2:
make ICUCharges = numOfDaysHospitalized * 150
else
make ICUCharges = numOfDaysHospitalized * 200
else:
if patient has plan 1:
make ICUCharges = numOfDaysHospitalized * 250
else if patient has plan 2:
make ICUCharges = numOfDaysHospitalized * 400
else
make ICUCharges = numOfDaysHospitalized * 700
calculate total claim amount as totalClaimAmount = numOfDaysHospitalized + suppliesCost + surgicalFee + otherCharges + ICUCharges
if patient has annual claim:
if age > 60:
show message: The subscriber age has exceeded the limit(60 Year), Not Eligible
loop through the patients:
if claim id == patient id:
break out of loop
if totalClaimAmount is less than equal to claims remaininigAmount:
make claims amountClaimed = claims amountClaimed+totalClaimAmount
make claims remaininigAmount = claims remaininigAmount-totalClaimAmount;
else:
make amountToBeBorne = totalClaimAmount - claims remaininigAmount
make claims amountClaimed = claims amountClaimed + totalClaimAmount - amountToBeBorne;
make claims remaininigAmount = 0;
show message: The amount that can be claimed is less then the claim by subscriber (amountToBeBorne) RM should be given by subscriber themselves
write all the information to a file named claims.txt
show all the information