// heydari.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdlib.h"
#include "conio.h"
#include "string.h"
void cmput(long bc,int nd,long cd,int bt,char it[5],long tc,long *ohd,long *psc, long *isc);
int total(int nor,long *totalself,long *totalins,long bimar[][6],char paziresh[][5]);
int readin(long *data,long bimar[][6],char code[][3],char paziresh[][5],char name[][21],char family[][21],int patient[100][3]);
void list1(int patient_no,long *data,long bimar[][6],char code[][3],char paziresh[][5],char name[][21],char family[][21],int patient[100][3],long *ohd,long *psc, long *isc);
void sort(int nor,long bimar[][6],char code[][3],char paziresh[][5],char name[][21],char family[][21]);
int main()
{
long ohd,psc,isc,totalself,totalins,data;
long bimar[100][6];
char code[100][3];
char paziresh[100][5];
int patient[100][3],i,t;
char name[100][21],family[100][21];
int nor,patient_no,numinshure,notinshure;
nor=readin(&data,bimar,code,paziresh,name,family,p atient);
sort(nor,bimar,code,paziresh,name,family);
i=1;
for(patient_no=0;patient_no<nor;patient_no++)
{
printf(" Hospital Cost Report ");
printf("Page:");
printf("%3d",i);
printf("\n");
list1(patient_no,&data,bimar,code,paziresh,name,fa mily,patient,&ohd,&psc,&isc);
t=patient_no+1;
if(t%3==0)
i++;
}
numinshure=total(nor,&totalself,&totalins,bimar,pa ziresh);
printf("number of patient inshusred:");
printf("%d\n",numinshure);
printf("number of patient not inshusred:");
notinshure=nor;
printf("%d\n",notinshure);
printf("total payment patient:");
printf("%ld\n",totalself);
printf("total payment inshure:");
printf("%ld\n",totalins);
return 0;
}
//************************************
int total(int nor,long *totalself,long *totalins,long bimar[][6],char paziresh[][5])
{
int totbime,i;
totalself=0;
totalins=0;
for (i=0;i<nor;i++)
{
totalself+=bimar[i][4];
totalins+=bimar[i][5];
}
for (i=0;i<nor;i++)
{
if (strcmp(paziresh[i],"BIME"))
totbime++;
else
continue;
}
return totbime;
}
//**********************************
int readin(long *data,long bimar[][6],char code[][3],char paziresh[][5],char name[][21],char family[][21],int patient[100][3])
{
int nor,i,numofcost,j;
char cost[100][21];
long cost2[100];
long ohd,psc,isc,sum;
char ch;
sum=0;
scanf("%2d",&nor);
printf("%d",nor);
scanf("%6ld",&data);
printf("%d",nor);
for (i=0;i<nor;i++)
{
scanf("%s",name[i]);
scanf("%s",family[i]);
scanf("%2s",code[i]);
scanf("%6ld",&bimar[i][0]);
scanf("%4s",paziresh[i]);
scanf("%2d",&numofcost);
scanf("%2d",&patient[i][0]);
scanf("%5d",&patient[i][1]);
scanf("%1d",&patient[i][2]);
if (numofcost==0)
goto loop1;
else
{
for (j=0;j<numofcost;j++)
{
scanf("%20s",cost[j]);
scanf("%6ld",&cost2[j]);
sum+=cost2[j];
}
}
loop1:
bimar[i][2]=sum;
cmput(bimar[i][0],patient[i][0],patient[i][1],patient[i][2],paziresh[i],bimar[i][2],&ohd,&psc,&isc);
bimar[i][3]=ohd;
bimar[i][4]=psc;
bimar[i][5]=isc;
bimar[i][1]=patient[i][0]*patient[i][1]*patient[i][2];
}
return nor;
}
//***********************************
void list1(int patient_no,long *data,long bimar[][6],char code[][3],char paziresh[][5],char name [][21],char family[][21],int patient[100][3],long *ohd,long *psc, long *isc)
{
long total;
printf("Date:");
printf("%6ld",data);
printf(" ");
printf("Section:");
if(code[patient_no]=="CD")
printf("cardiology ");
else if(code[patient_no]=="OP")
printf("operation ");
else if(code[patient_no]=="UR")
printf("urology ");
printf("\n");
printf("Patient:");
printf("%s%s",name[patient_no],family[patient_no]);
printf(" ");
printf("Bed Cost:");
printf("%5d",(patient[patient_no][0]*patient[patient_no][1]*patient[patient_no][2]));
printf(" ");
printf("Type:");
if (paziresh[patient_no]=="BIME")
printf("BIME");
else if (paziresh[patient_no]=="AZAD")
printf("AZAD");
printf("\n");
printf("Basic Cost:");
printf("%5ld",bimar[patient_no][0]);
printf(" ");
printf("Over Head:");
printf("%ld",ohd);
printf("\n");
printf("Other Costs:");
printf("%5ld",bimar[patient_no][2]);
printf(" ");
printf("Insurance Payment:");
printf("%ld",isc);
printf("\n");
printf("Total Cost:");
total=(bimar[patient_no][0])+((patient[patient_no][0])*(patient[patient_no][1])*(patient[patient_no][2]))+(bimar[patient_no][2])+(bimar[patient_no][3]);
printf("%7ld",total);
printf(" ");
printf("Patient Payment:");
printf("%ld",psc);
printf("\n");
printf(" **********");
printf("\n");
printf("\n");
}
//***********************************
void sort(int nor,long bimar[][6],char code[][3],char paziresh[][5],char name[][21],char family[][21])
{
char *tempfamily,*tempcode,*temppaziresh,*tempname;
long t0,t1,t2,t3,t4,t5;
int i,j;
for (i=0;i<nor-1;i++)
for (j=0;j<nor;j++)
if(strcmp(family[i],family[j])>0)
{
tempfamily=family[i];
tempcode=code[i];
tempname=name[i];
temppaziresh=paziresh[i];
t0=bimar[i][0];
t1=bimar[i][1];
t2=bimar[i][2];
t3=bimar[i][3];
t4=bimar[i][4];
t5=bimar[i][5];
*family[i]=*family[j];
*code[i]=*code[j];
*name[i]=*name[j];
*paziresh[i]=*paziresh[j];
bimar[i][0]=bimar[j][0];
bimar[i][1]=bimar[j][1];
bimar[i][2]=bimar[j][2];
bimar[i][3]=bimar[j][3];
bimar[i][4]=bimar[j][4];
bimar[i][5]=bimar[j][5];
*family[j]=*tempfamily;
*code[j]=*tempcode;
*name[j]=*tempname;
*paziresh[j]=*temppaziresh;
bimar[j][0]=t0;
bimar[j][1]=t1;
bimar[j][2]=t2;
bimar[j][3]=t3;
bimar[j][4]=t4;
bimar[j][5]=t5;
}
}
//**************************************
void cmput(long bc,int nd,long cd,int bt,char it[5],long tc,long *ohd,long *psc, long *isc)
{
long ht,mmb,t;
ht=nd*cd*bt;
*ohd=10/100*(bc+ht)*20/100*tc;
mmb=bc+nd*cd+tc;
if (mmb<=500000)
*isc=80/100*mmb;
else if (mmb>500000 && mmb<=1000000)
*isc=60/100*(mmb-500000);
else if (mmb>1000000)
*isc=40/100*(mmb-1000000);
t=bc+ht+tc+(*ohd);
(*psc)=t-(*isc);
}
//*********************************
اینم داده های ورودی:
12830303
Ali Mohammadi CD100000AZAD05
10400002
amalejarrahi 250000
azmayeshekhoon 050000
shostoshoo&pansoman 030000
tazrighat 020000
capsouleoxigen 075000
Mohsen Rezaei OP150000BIME06
05800001
amalejarrahi 250000
phisiotorapy 150000
radiology 100000
shostoshoo&pansoman 030000
shecastebandy 080000
tazrighat 020000
HoseinAli Bemanidehnoie UR080000BIME03
08400002
amalejarrahi 250000
shostoshoo&pansoman 030000
tazrighat 020000
Fatemeh HoseiniAsleEsfahani OP180000AZAD07
20400002
amalejarrahi 250000
sonography 200000
radiology 100000
phisiotorapy 150000
tazrighat 020000
shostashoo&pansoman 030000
azmayeshekhoon 050000
Seddigheh Ahmadi CD100000BIME00
06800001
Sadegh Karimi UR080000BIME04
15400002
sonography 200000
tazrighat 020000
shostoshoo&pansoman 030000
azmayeshekhoon 050000
AliReza Yasini CD130000BIME06
30800001
amalejarrahi 250000
shostoshoo&pansoman 030000
azmayeshekhoon 050000
capsouleoxigen 075000
sonography 200000
tazrighat 020000
Hasan Bahadori OP080000BIME03
05400002
radiology 100000
shecastebandy 080000
phisiotorapy 150000
Razieh Hasanzadeh UR140000AZAD05
13400002
amalejarrahi 250000
shostoshoo&pansoman 030000
tazrighat 020000
azmayeshekhoon 050000
sonography 200000
Meisam Zamani CD120000BIME04
13800001
amalejarrahi 250000
capsouleoxigen 075000
shostoshoo&pansoman 030000
azmayeshekhoon 050000
Somaieh Kamali OP800000BIME05
15800001
amalejarrahi 250000
shostoshoo&pansoman 030000
shecastebandy 080000
tazrighat 020000
radiology 100000
Morteza Yosefi OP500000AZAD06
12800001
amalejarrahi 250000
radiology 100000
shostoshoo&pansoman 030000
phisiotorapy 150000
shecastebandy 080000
tazrighat 020000