
INTRODUCTION :
In my project I have tried to implement basic layout of hospital billing that is as follows
LAYOUT:
BILL CUM RECEIPT FORMAT
HOSPITALIZATION DETAILS
1 Hospital Name Hospital NSP Co
2 Address Hospital PIN Code:
3 Bill no. Bill Date and Time
4 PAN Number Service Tax No
5 IP No Bed Number
6 Date and time:Admission Date and time: Discharge
7 Patient Name Member ID / Card No.
8 Patient's address Patient's Contact No
9 Cashless Issued Amount Name of Insurance Co:
BILL SUMMARY (Detailed Break up to be provided separately as per hospital format)
Particulars Gross Amount Discount Net Amount
1 ROOM RENT SERVICES
2 ICU CHARGES
3 NURSING / RMO SERVICES
4 CONSULTANT VISITS
5 MEDICINE & CONSUMABLES
6 INVESTIGATION CHARGES
7 SURGERY / PROCEDURE CHARGES
8 IMPLANTS AND EQUIPMENTS
9 MISCELLANEOUS CHARGES
10 PACKAGE CHARGES
11 ANY OTHER (SPECIFY)
12 BILLED AMOUNT:
1 Net Bill Amount after discount(A)
2 Cashless Authorized (B)
3 Service Tax ( C ) = (B*10.3%)
4 To be paid by Insurer: B + C
5 To be Paid By Patient (A -B)
I have also provided a module for tests, in case any extra test are to be done for patient.
I have tried to implement all my knowledge in matlab to make this program.
CONTROL FLOW STRUCTURES USED IN MATLAB
IF Control statement
⦁ if structure
This is the simplest form of if structure. It has only one group of statements which is executed if the condition is true, otherwise the program exits the if control structure. The syntax of if structure is given as:
if expression
statements
end
⦁ if-else structure
An IF statement can be used to execute code when the logical test (expression) returns a true value (anything but 0). An "else" statement is executed if the same expression is false (0).
Syntax:
if expression
statements
else
statements
end
⦁ if-elseif-else Structure
This is the most useful form of if control structure. It provides a user the option to check a large number of different conditions. The syntax is given as follows:
if expression1
statements
elseif expression2
statements
else
statements
end
If expression1 is true, then the statement under if block are executed and other statement are skipped and the control shifts to next statement outside if-elseif-else block.
If expression2 is true, then the statement under elseif block are executed and other statement are skipped and the control shifts to next statement outside if-elseif-else block.
If both the expressions are false, then the statement under else block are executed and other statement are skipped and the control shifts to next statement outside if-elseif-else block.
SWITCH statement
Switch statements are used to perform one of several possible sets of operations, depending on the value of a single variable. They are intended to replace nested "if" statements depending on the same variable, which can become very cumbersome. The syntax is as follows:
switch variable
case value1
statements(1)
case value2
statements(2)
...
otherwise
statements
end
The end is only necessary after the entire switch block, not after each case. If you terminate the switch statement and follow it with a "case" statement you will get an error saying the use of the "case" keyword is invalid. If this happens it is probably because you deleted a loop or an "if" statement but forgot to delete the "end" that went with it, thus leaving you with surplus "end"s. Thus MATLAB thinks you ended the switch statement before you intended to.
The otherwise keyword executes a certain block of code (often an error message) for any value of variable other than those specified by the "case" statements.
FOR statement
The FOR statement executes code a specified number of times using an iterator.
Syntax:
for iterator = startvalue:increment:endvalue
statements
end
The iterator variable is initialized to startvalue and is increased by the amount in increment every time it goes through the loop, until it reaches the value endvalue. If increment is omitted, it is assumed to be 1, as in the following code:
for i = 1:3
statements
end
This would execute statements three times.
WHILE statement
The while statement executes code until a certain condition evaluates to false or zero. Example:
while condition
statements
end
Forgetting to change the condition within a while loop is a common cause of infinite loops.
Command Specifically used
⦁ xlswrite(<‘filename.xls’>,<variable name>,<Sheet no.>)
FUNCTION: Used for writing a particular variable to an excel file.
PURPOSE: Used in my program to write particular bill to auto-generated billbook.xls.
⦁ menu(<‘title of menu’>,<’choice 1’>,<’choice 2’>,..)
FUNCTION: To display a menu.
PURPOSE: To user a gui choice menu.
⦁ input(<‘Statement enquiring input’>)
FUNCTION: Used to take input from user.
PURPOSE: For various entry to be made to the file.
⦁ fprintf()
FUNCTION: To print on a file.
PURPOSE: To print on standard output file i.e. the monitor screen.
⦁ mod(x,y)
FUNCTION: To get the remainder when x is divided by y.
PURPOSE: To check for leap year.
PROGRAM CODE
clc
ch=menu('billing type','admit','tests');
j=0;i=0;sl=11;nl=4;
s(1).t=' ';
s(1).p=0;
rt=[0 0 0 0 0 0 0 0];
if(ch == 1)
c=cell(26,5);
c(1,1)={' '};
c(1,2)={' '};
c(1,3)={'BILL'};
c(1,4)={' '};
c(1,5)={' '};
c(2,1)={' '};
c(2,2)={' '};
c(2,3)={' '};
c(2,4)={' '};
c(2,5)={' '};
c(3,1)={' '};
c(3,2)={' '};
c(3,3)={'DETAILS'};
c(3,4)={' '};
c(3,5)={' '};
c(4,1)={'1'};
c(4,2)={'Hospital name:'};
c(4,3)={input('Enter the hospital name:','s')};
c(4,4)={'Hospital nsp code:'};
c(4,5)={input('Enter the hospital nsp code:','s')};
c(5,1)={'2'};
c(5,2)={'Address:'};
c(5,3)={input('Enter the hospital address:','s')};
c(5,4)={'Hospital pin code:'};
c(5,5)={input('Enter the hospital pin code:','s')};
c(6,1)={'3'};
c(6,2)={'Bill no.:'};
o=input('Enter the bill no.:');
c(6,3)={0};
c(6,4)={'Bill date and time:'};
c(6,5)={input('Enter the bill date and time:','s')};
c(7,1)={'4'};
c(7,2)={'PAN no.:'};
c(7,3)={input('Enter payee''s pan no.:','s')};
c(7,4)={'Service tax no.:'};
c(7,5)={input('Enter the payee''s service tax no.:','s')};
c(8,1)={'6'};
c(8,2)={'IP no.:'};
c(8,3)={input('Enter the IP no.:','s')};
c(8,4)={'Bed no.:'};
c(8,5)={input('Enter the bed no.:','s')};
c(9,1)={'6'};
c(9,2)={'Admit Date'};
i=1;d=0;m=0;y=0;
while(i == 1)
fprintf('Enter the details of date of admit\n:');
d=input('enter the date:');
m=input('enter the month:');
y=input('enter the year:');
if mod(y,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
if m <= 12 && d <= dm(m)
i=0;
else
fprintf('Enter a valid date.');
end
end
c(9,3)={[num2str(d),'-',num2str(m),'-',num2str(y)]};
c(9,4)={'Discharge Date:'};
i=1;d1=0;m1=0;y1=0;
while(i == 1)
fprintf('Enter the details of date of discharge:\n');
d1=input('enter the date:');
m1=input('enter the month:');
y1=input('enter the year:');
if mod(y,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
if y1 > y
if m1 <= 12 && d1 <= dm(m1)
i=0;
else
fprintf('Enter a valid date.');
end
elseif y1 == y
if m1 <= 12 && d1 <= dm(m1)
z=1;
else
fprintf('Enter a valid date.');
end
if m1 > m
i=0;
elseif m1==m
if d1 > d
i=0;
else
fprintf('Enter a valid date.')
end
else
fprintf('Enter a valid date.')
end
else
fprintf('Enter a valid date.')
end
end
c(9,5)={[num2str(d1),'-',num2str(m1),'-',num2str(y1)]};
c(10,1)={'7'};
c(10,2)={'Patient name:'};
c(10,3)={input('Enter the Patient name:','s')};
c(10,4)={'Member id:'};
c(10,5)={input('Enter your member id:','s')};
c(11,1)={'8'};
c(11,2)={'Patient''s Address:'};
c(11,3)={input('Enter the Patient''s Address:','s')};
c(11,4)={'Contact no.:'};
c(11,5)={input('Enter the Contact no. for patient:','s')};
c(12,1)={'9'};
c(12,2)={'Cashless issued amount:'};
c(12,3)={input('Enter cahless issued amount:')};
c(12,4)={'Name of insurance company:'};
c(12,5)={input('Enter the name of insurance company:','s')};
c(13,1)={' '};
c(13,2)={' '};
c(13,3)={' '};
c(13,4)={' '};
c(13,5)={' '};
c(14,1)={' '};
c(14,2)={' '};
c(14,3)={'SUMMARY'};
c(14,4)={' '};
c(14,5)={' '};
c(15,1)={'Sl.no.'};
c(15,2)={'PARTICULARS'};
c(15,3)={'GROSS AMOUNT'};
c(15,4)={'DISCOUNT'};
c(15,5)={'NET AMOUNT'};
yd=y1-y;
sd=0;q=0;
if yd == 0
if mod(y1,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
if m == m1
sd=d1-d+1;
else
sd=dm(m)-d+1;
if (m+1) < m1
for i=(m+1):1:m1
sd=sd+dm(i);
end
sd=sd+d1;
else
sd=sd+d1;
end
end
elseif yd == 1
if mod(y,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
sd=dm(m)-d+1;
if m~=12
for i=(m+1):1:12
sd=sd+dm(i);
end
end
if mod(y1,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
for i=1:1:(m1-1)
sd=sd+dm(i);
end
sd=sd+d1;
else
if mod(y,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
sd=dm(m)-d+1;
if m~=12
for i=(m+1):1:12
sd=sd+dm(i);
end
end
for q=(y+1):1:(y1-1)
if mod(q,4)==0
sd=sd+366;
else
sd=sd+365;
end
end
if mod(y1,4)==0
dm=[31 29 31 30 31 30 31 31 30 31 30 31];
else
dm=[31 28 31 30 31 30 31 31 30 31 30 31];
end
for i=1:1:(m1-1)
sd=sd+dm(i);
end
sd=sd+d1;
end
bill=0;
cb=0;
c(16,1)={'1'};
c(16,2)={'Room Rent services'};
chd=input('Enter room rent for a day:');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(16,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(16,4)={hu};
c(16,5)={jy-hu};
c(17,1)={'2'};
c(17,2)={'ICU services'};
chd=input('Enter ICU charges for a day:');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(17,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(17,4)={hu};
c(17,5)={jy-hu};
c(18,1)={'3'};
c(18,2)={'Nursing services'};
chd=input('Enter charge of nursing services for a day:');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(18,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(18,4)={hu};
c(18,5)={jy-hu};
c(19,1)={'4'};
sd=1;
c(19,2)={'Consultant visits'};
chd=input('Enter charge of consultancy services :');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(19,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(19,4)={hu};
c(19,5)={jy-hu};
c(20,1)={'5'};
c(20,2)={'Medicines'};
chd=input('Enter charge of medicine:');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(20,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(20,4)={hu};
c(20,5)={jy-hu};
c(21,1)={'6'};
c(21,2)={'Ivestigation charges'};
chd=input('Enter charge of investigation :');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(21,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(21,4)={hu};
c(21,5)={jy-hu};
c(22,1)={'7'};
c(22,2)={'Surgery/Procedure'};
chd=input('Enter charge of surgeries/procedures:');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(22,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(22,4)={hu};
c(22,5)={jy-hu};
c(23,1)={'8'};
c(23,2)={'Mislleneous Charges'};
chd=input('Enter charge of mislleneous charges:');
jy=sd*chd;
cb=cb+1;
rt(cb)=jy;
c(23,3)={jy};
dis=input('Enter the discount percentage:');
hu=sd*chd*(dis/100);
bill=bill+rt(cb)-hu;
c(23,4)={hu};
c(23,5)={jy-hu};
c(24,1)={' '};
c(24,2)={' '};
c(24,3)={' '};
c(24,4)={' '};
c(24,5)={' '};
c(25,1)={'*'};
c(25,2)={'Net Bill'};
c(25,3)={bill};
cl=input('Enter the cashless authorized:');
st=input('Enter the rate for sevice tax:');
c(25,4)={'Service tax'};
c(25,5)={cl*(st/100)};
c(26,1)={'*'};
c(26,2)={'paid by insurer'};
c(26,3)={cl+((100+st)/100)};
c(26,4)={'paid by patient'};
c(26,5)={bill-cl};
sh=['Sheet',o];
xlswrite('billbook',c,sh);
disp(rt);
fprintf( 'Current Bill is saved to Sheet%d of billbook.xls in Matlab path,format as you wish with excel.' ,o);
ch_gr = menu('view graph','Yes','No')
if ch_gr == 1
fprintf('note:x-co ordinate represent there respective serial no.in bill.');
bar(rt);
xlabel('Charges------->');
ylabel('Rate------->');
title('Bar graph representing rate comparison');
fprintf('press enter to view pie chart:');
pause
sl=[0 1 1 0 1 1 0 1];
label=[c(16,2) c(17,2) c(18,2) c(19,2) c(20,2) c(21,2) c(22,2) c(23,2)];
pie(rt,sl,label);
end
else
pname=input('Enter Paitient Name:','s');
page=input('Enter paitient''s age:');
ta=input('Enter the name of testing agency:','s');
dis=input('Discount% to be provided:');
sum_c=0;
while j==0
i=i+1;
if (i==1)
s(i).t=input('enter the test name: ','s');
if(length(s(i).t)>11)
sl=length(s(i).t);
end
s(i).p=input('enter the cost of test:');
sum_c=sum_c+s(i).p;
if(length(num2str(s(i).p))>4)
nl=length(num2str(s(i).p));
end
j=input('if more test are to be done press 0 else some other number :');
end
if(i~=1)
s(i).t=input ('enter the test name: ','s');
if(length(s(i).t)>sl)
sl=length(s(i).t);
end
s(i).p=input('enter the cost of test:');
sum_c=sum_c+s(i).p;
if(length(num2str(s(i).p))>nl)
nl=length(num2str(s(i).p));
end
j=input('if more test are to be done press 0 else some other number :');
end
end
clc
l=5+2+sl+2+nl;
for k=1:1:(7+sl/4)
fprintf(' ');
end
fprintf('%s\n',ta);
for k=1:1:l
fprintf('-');
end
fprintf('\nName:%s\n',pname);
fprintf('Age of patient:%d\n',page);
for k=1:1:l
fprintf('-');
end
fprintf('\nS.no. DESCRIPTION');
for k=1:1:(sl-11+2)
fprintf(' ');
end
fprintf('RATE\n');
for k=1:1:l
fprintf('-');
end
for k=1:i
fprintf('\n');
fprintf('%d',k);
for j=1:1:(7-(length(num2str(k))))
fprintf(' ');
end
fprintf(s(k).t);
for j=1:1:(sl-(length(s(k).t))+2)
fprintf(' ');
end
fprintf('%d',s(k).p);
end
fprintf('\n');
for k=1:1:l
fprintf('-');
end
fprintf('\nTotal bill:%d',sum_c);
x=sum_c*((100-dis)/100);
fprintf('\nBill after discount:%d\n',x);
for k=1:1:l
fprintf('-');
end
end
INPUT AND OUTPUT
⦁ First of all when you would executed my program on command window. It would ask for your choice by means of a menu as follows:
⦁ You make your choice, say as ‘admit’.then it would ask you for some details.
⦁ After entering all your details. Your bill will be generated and saved in sheet no. As your entered bill no. In an excel file named ‘billbook.xls’ auto-generated by my program in Matlab path as follows:
⦁ Further if you wish to see the graph of comparison of various charges ,a menu will be displayed asking your choice:
⦁ On selecting ‘Yes’ from menu the bar graph will be generated as follows:
⦁ On pressing any key , you can view the pie chart as follows:
⦁ Suppose you would had made choice for test, you would again be asked for input as follows:
⦁ Then the bill will be generated on command window, as follows:
RESULT
A module for hospital billing is made, which implements basically a bill-cum receipt using MATLAB
0 comments:
Post a Comment