예제 #1
0
void FileHandler::savePatientList(string fname, PatientList& p_list)
{
	// open file
	ofstream fout;
	fout.open(fname);
	if (!fout) 
	{
		cerr << "\n" << "can't open file!!";
		exit(1);
	}

	// save data into file
	int count = p_list.getCount();
	for (int i = 0; i<count; i++) 
	{
		Patient p = p_list.getPatientList(i);
		fout << p.patient_id << " " << p.name << " " << p.sex << " " << p.birth_date << " " << p.phone_no << " " << p.entering_date << " "
			<< p.disease << " " << p.room_no << " " << p.doctor_assigned << " " << p.nurse_assigned << " " << p.leaving_date << endl;
	}

	// close file
	fout.close();
}
예제 #2
0
void FileHandler::savePatient(string fileName, PatientList& p_list) // 파일 쓰기용
{
	ofstream fout;
	fout.open(fileName, ios_base::out);

	for (int i = 0; i < p_list.getCount(); i++)
	{
		fout << p_list.getPatientList(i).id << "\t";
		fout << p_list.getPatientList(i).name << "\t";
		fout << p_list.getPatientList(i).sex << "\t";
		fout << p_list.getPatientList(i).birth << "\t";
		fout << p_list.getPatientList(i).phone_number << "\t";
		fout << p_list.getPatientList(i).ad_date << "\t";
		fout << p_list.getPatientList(i).disease << "\t";
		fout << p_list.getPatientList(i).room << "\t";
		fout << p_list.getPatientList(i).doctor << "\t";
		fout << p_list.getPatientList(i).nurse << "\t";
		fout << p_list.getPatientList(i).leave_date << "\t";
		fout << endl;
	}

	fout.close();
}