Pada program rawat jalan rumah sakit ini saya menerapkan konsep struktur data : Array Record/Struct, Shorting, dan Searching.
Listing Program
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<conio.h>
#include<string>
struct{
int id,umur,antri;
string NamaDr, bayar;
float JasaDr;
char nik[20],nm[50],alamat[50],jk[10],telp[20],ttl[20],diagnosa[100],tglk[20],nw[50],bpjs[50],rujukan[50];
}
data[100], temp;
char ulang1,ulang2,ulang3,atasnama[50];
int cari,jml,masuk,closemu,PilihDr,pmenu,pbayar;
float TotalObat,tindakan,TotalBiaya,bayar,kembalian;
int main(){
tambah:
system("cls");
cout<<"=========================================="<<endl;
cout<<" RAWAT JALAN RUMAH SAKIT GRAND FAMILY "<<endl;
cout<<" Jln. Nasional No. 06 Karanganyar "<<endl;
cout<<"=========================================="<<endl;
cout<<endl;
cout<<"Masukkan Banyak Data Pasien = ";
cin>>jml;
for(masuk=1; masuk<=jml; masuk++){
inputdata:
cout<<"\nMasukkan Data Pasien Ke - "<<masuk<<" : ";
cout<<endl;
cout<<"\tMasukkan No.Rekam Medis = ";
cin>>data[masuk].id;
cout<<"\tMasukkan Nama Pasien = ";
gets(data[masuk].nm);
cout<<"\tMasukkan NIK [angka] = ";
cin>>data[masuk].nik;
cout<<"\tTanggal Kunjungan = ";
cin>>data[masuk].tglk;
cout<<"\tMasukkan Jenis.Kel[L/P] = ";
cin>>data[masuk].jk;
cout<<"\tMasukkan Tgl Lahir = ";
cin>>data[masuk].ttl;
cout<<"\tMasukan Umur[angka] = ";
cin>>data[masuk].umur;
cout<<"\tMasukkan Nama Ortu/wali = ";
gets(data[masuk].nw);
cout<<"\tMasukkan Alamat = ";
gets(data[masuk].alamat);
bayar:
cout<<"\n\tPilih Pembayaran : "<<endl;
cout<<"\t1.BPJS "<<endl;
cout<<"\t2.UMUM "<<endl;
cout<<"\tPilih [ 1-2 ] = ";
cin>>pbayar;
switch (pbayar){
case 1:
cout<<"\tAnda memilih BPJS "<<endl;
cout<<"\tMasukkan No. BPJS = ";
cin>>data[masuk].bpjs;
cout<<"\tMasukkan No. Rujukan = ";
cin>>data[masuk].rujukan;
data[masuk].bayar="BPJS";
break;
case 2:
cout<<"\tAnda memilih UMUM "<<endl;
data[masuk].bayar="UMUM";
data[masuk].bpjs[masuk]='-';
data[masuk].rujukan[masuk] = '-';
break;
default:
cout<<"\tPilihan Anda Tidak Tersedia";
getch();
goto bayar;
break;
}
cout<<"\tMasukkan No.Telp [angka]= ";
gets(data[masuk].telp);
cout<<"\tMasukkan Diagnosa = ";
gets(data[masuk].diagnosa);
pilihdr:
cout<<"\n\tPilih Poli : "<<endl;
cout<<"\t1.Poli Bedah Umum : Dr. Jamie Robert, Jam Kerja 09.00-17.00 "<<endl;
cout<<"\t2.Poli Anak : Dr. Anggi Venusia, Jam Kerja 08.00-15.00 "<<endl;
cout<<"\t3.Poli Mata : Dr. Reyna A Lily, Jam Kerja 11.00-20.00"<<endl;
cout<<"\t4.Poli Gigi : Dr. Ravi, Jam Kerja 10.00-16.00 "<<endl;
cout<<"\t5.Poli Penyakit Dalam : Dr. Ibnu Sina, Jam Kerja 12.00-20.00"<<endl;
cout<<"\t6.Poli Umum : Dr. Harvey R Horan, Jam Kerja 17.00-23.00 "<<endl;
cout<<"\tPilih [ 1-6 ]= ";
cin>>PilihDr;
switch (PilihDr){
case 1:
cout<<"\tPoli Bedah Umum : Dr. Jamie Robert, Jam Kerja 09.00-17.00\n";
data[masuk].NamaDr="Dr. Jamie Robert";
data[masuk].JasaDr=150000;
break;
case 2:
cout<<"\tPoli Anak : Dr. Anggi Venusia, Jam Kerja 08.00-15.00\n";
data[masuk].NamaDr="Dr. Anggi Venusia";
data[masuk].JasaDr=200000;
break;
case 3:
cout<<"\tPoli Mata : Dr. Reyna A Lily, Jam Kerja 11.00-20.00\n";
data[masuk].NamaDr="Dr. Reyna A Lily";
data[masuk].JasaDr=150000;
break;
case 4:
cout<<"\tPoli Gigi : Dr. Ravi, Jam Kerja 10.00-16.00\n";
data[masuk].NamaDr="Dr. Ravi";
data[masuk].JasaDr=150000;
break;
case 5:
cout<<"\tPoli Penyakit Dalam : Dr. Ibnu Sina, Jam Kerja 12.00-20.00\n";
data[masuk].NamaDr="Dr. Ibnu Sina";
data[masuk].JasaDr=175000;
break;
case 6:
cout<<"\tPoli Umum : Dr. Harvey R Horan, Jam Kerja 17.00-23.00\n";
data[masuk].NamaDr="Dr. Harvey R Horan";
data[masuk].JasaDr=150000;
break;
default:
cout<<"\tPilihan Anda Tidak Tersedia!";
getch();
goto pilihdr;
break;
}
yes:
cout<<"\n\tApakah data sudah benar ? [Y/N]";
cin>>ulang3;
if(ulang3=='N'||ulang3=='n'){
system("cls");
cout<<"=========================================="<<endl;
cout<<" RAWAT JALAN RUMAH SAKIT GRAND FAMILY "<<endl;
cout<<" Jln. Nasional No. 06 Karanganyar "<<endl;
cout<<"=========================================="<<endl;
goto inputdata;
}else if(ulang3=='Y'||ulang3=='y'){
goto lanjut;
}else{
cout<<"\tPilihan Anda tidak tersedia!"<<endl;
getch();
goto yes;
}
lanjut:
data[masuk].antri = masuk;
cout<<"\n\tNo Antrian = "<<data[masuk].antri;
getch();
cout<<endl;
}
// metode shorting, bubble short
for(int i=0;i<jml;i++){
for(int b=0;b<jml;b++){
int k;
if(data[b].id > data[b+1].id){
temp.id=data[b].id;
data[b].id=data[b+1].id;
data[b+1].id=temp.id;
strcpy(temp.nm,data[b].nm);
strcpy(data[b].nm,data[b+1].nm);
strcpy(data[b+1].nm,temp.nm);
strcpy(temp.nik,data[b].nik);
strcpy(data[b].nik,data[b+1].nik);
strcpy(data[b+1].nik,temp.nik);
strcpy(temp.jk,data[b].jk);
strcpy(data[b].jk,data[b+1].jk);
strcpy(data[b+1].jk,temp.jk);
strcpy(temp.ttl,data[b].ttl);
strcpy(data[b].ttl,data[b+1].ttl);
strcpy(data[b+1].ttl,temp.ttl);
temp.umur=data[b].umur;
data[b].umur=data[b+1].umur;
data[b+1].umur=temp.umur;
strcpy(temp.bpjs,data[b].bpjs);
strcpy(data[b].bpjs,data[b+1].bpjs);
strcpy(data[b+1].bpjs,temp.bpjs);
strcpy(temp.rujukan,data[b].rujukan);
strcpy(data[b].rujukan,data[b+1].rujukan);
strcpy(data[b+1].rujukan,temp.rujukan);
strcpy(temp.alamat,data[b].alamat);
strcpy(data[b].alamat,data[b+1].alamat);
strcpy(data[b+1].alamat,temp.alamat);
strcpy(temp.nw,data[b].nw);
strcpy(data[b].nw,data[b+1].nw);
strcpy(data[b+1].nw,temp.nw);
strcpy(temp.telp,data[b].telp);
strcpy(data[b].telp,data[b+1].telp);
strcpy(data[b+1].telp,temp.telp);
temp.antri=data[b].antri;
data[b].antri=data[b+1].antri;
data[b+1].antri=temp.antri;
temp.bayar=data[b].bayar;
data[b].bayar=data[b+1].bayar;
data[b+1].bayar=temp.bayar;
temp.NamaDr=data[b].NamaDr;
data[b].NamaDr=data[b+1].NamaDr;
data[b+1].NamaDr=temp.NamaDr;
strcpy(temp.diagnosa,data[b].diagnosa);
strcpy(data[b].diagnosa,data[b+1].diagnosa);
strcpy(data[b+1].diagnosa,temp.diagnosa);
strcpy(temp.tglk,data[b].tglk);
strcpy(data[b].tglk,data[b+1].tglk);
strcpy(data[b+1].tglk,temp.tglk);
}
}
}
// data pasien
system("cls");
cout<<endl;
cout<<"DATA PASIEN : "<<endl;
cout<<"================================================================================================================================================================"<<endl;
cout<<"| No.Rekam Medis | Nama Pasien | NIK | J.kel | Tgl Lahir | Umur | Alamat | Ortu/Wali | No Telp |"<<endl;
cout<<"================================================================================================================================================================"<<endl;
for(masuk=1; masuk<=jml; masuk++){
cout<<"|"<<setw(8)<<data[masuk].id<<setw(9)<<"|"<<setw(25)<<data[masuk].nm<<"|"<<setw(19)<<data[masuk].nik<<"|"<<setw(7)<<data[masuk].jk<<"|"<<setw(15)<<data[masuk].ttl<<"|"<<setw(6)<<data[masuk].umur<<"|"<<setw(26)<<data[masuk].alamat<<"|"<<setw(18)<<data[masuk].nw<<"|"<<setw(18)<<data[masuk].telp<<"|"<<endl;
}
cout<<"----------------------------------------------------------------------------------------------------------------------------------------------------------------"<<endl<<endl;
// poli
cout<<"=============================================================================================================================================================="<<endl;
cout<<"| No.Antrian | Nama Pasien | Pembayaran | No. BPJS | No. Rujukan | Tgl Kunjungan | Diagnosa | Dokter |"<<endl;
cout<<"=============================================================================================================================================================="<<endl;
for(masuk=1; masuk<=jml; masuk++){
cout<<"|"<<setw(6)<<data[masuk].antri<<setw(7)<<"|"<<setw(19)<<data[masuk].nm<<"|"<<setw(9)<<data[masuk].bayar<<"|"<<setw(16)<<data[masuk].bpjs<<"|"<<setw(22)<<data[masuk].rujukan<<"|"<<setw(15)<<data[masuk].tglk<<"|"<<setw(28)<<data[masuk].diagnosa<<"|"<<setw(10)<<data[masuk].NamaDr<<"|"<<endl;
}
cout<<"--------------------------------------------------------------------------------------------------------------------------------------------------------------"<<endl;
cout<<"Terdapat "<<jml<<" Data Pasien"<<endl;
pilihmenu:
cout<<"\n======================"<<endl;
cout<<" Pilih Menu : "<<endl;
cout<<"======================"<<endl;
cout<<"1. Tambah Data Pasien"<<endl;
cout<<"2. Cari Pasien"<<endl;
cout<<"3. Keluar"<<endl;
cout<<"Masukkan pilihan[1-3] = ";
cin>>pmenu;
switch (pmenu)
{
case 1:
system("cls");
goto tambah;
break;
case 2:
system("cls");
goto cari;
break;
case 3:
goto end;
break;
default:
cout<<"\tPilihan Anda Tidak Tersedia"<<endl;
getch();
goto pilihmenu;
break;
}
cari:
cout<<"Cari berdasar No.Rekam Medis = ";
cin>>cari;
for(masuk=0;masuk<=jml;masuk++){
if(data[masuk].id == cari){
closemu=1;
cout<<endl;
system("cls");
cout<<"==================================\n";
cout<<" TOTAL YANG HARUS DIBAYAR \n";
cout<<"==================================\n";
cout<<"No. Rekam Medis = "<<data[masuk].id<<endl;
cout<<"Nama Pasien = "<<data[masuk].nm<<endl;
cout<<"Tgl. Kunjungan = "<<data[masuk].tglk<<endl;
cout<<"Jenis Kelamin = "<<data[masuk].jk<<endl;
cout<<"Diagnosa = "<<data[masuk].diagnosa<<endl;
cout<<"Atas Nama = ";
gets(atasnama);
cout<<"Dokter = "<<data[masuk].NamaDr<<endl;
cout<<"Jasa Dokter = Rp. "<<data[masuk].JasaDr<<endl;
cout<<"Total Obat = Rp. ";
cin>>TotalObat;
cout<<"Tindakan = Rp. ";
cin>>tindakan;
TotalBiaya = data[masuk].JasaDr + TotalObat + tindakan;
cout<<"Total Biaya = Rp. "<<TotalBiaya;
cout<<endl;
cout<<"Bayar = Rp. ";
cin>>bayar;
kembalian=bayar-TotalBiaya;
cout<<"Kembalian = Rp. "<<kembalian;
cout<<endl;
getch();
cout<<endl<<endl;
cout<<"*******Semoga Lekas Sembuh********\n";
mengulang:
cout<<endl;
cout<<"Ingin Ulagi Lagi? [Y/N]";
cin>>ulang2;
if(ulang2=='y'||ulang2=='Y'){
goto tambah;
}else if(ulang2=='n'||ulang2=='N'){
goto end;
}else{
cout<<"\tPilihan Anda Tidak Tersedia!";
getch();
goto mengulang;
}
}
}
if (closemu==0){
salah:
cout<<"Maaf, No. Rekam Medis "<<cari<<" Tidak ditemukan, Ulangi Lagi? [Y/N]";
cin>>ulang1;
if(ulang1=='y'||ulang1=='Y'){
goto cari;
}else if(ulang1=='n'||ulang1=='N'){
system("cls");
goto pilihmenu;
}else{
cout<<"Pilihan Anda Tidak Tersedia!";
cout<<endl;
getch();
goto salah;
}
}
end:
clrscr();
cout<<""<<endl<<endl<<endl;
cout<<"*******Terima Kasih********\n";
getch();
}
Hasil Program
Posting Komentar