Example #1
0
void FileHandler::loadPatient(string fileName, PatientList& p_list) // 파일 읽기용
{
	IOHandler ioh;
	ifstream fin;
	fin.open(fileName, ios_base::in);

	int id; // 환자번호
	string name; // 성명
	string sex; // 성별
	int birth; // 생일
	string phone_number; // 휴대폰번호
	string ad_date; // 입원일
	string disease; // 병명
	string room; // 병실
	string doctor; // 주치의
	string nurse; // 담당간호사
	string leave_date; // 퇴원일
	
	while (!fin.eof()) // 파일의 끝에 도달하지 않았다면 계속 반복
	{
		fin >> id >> name >> sex >> birth >> phone_number >> ad_date >> disease >> leave_date; // 파일의 값을 읽음
		Patient p(id, name, sex, birth, phone_number, ad_date, disease, room, doctor, nurse, leave_date); // 생성자

		int index = p_list.findLeaveDate(leave_date);
		if (index != NOT_FOUND) // 중복 예외처리
		{
			ioh.putString("Already exists!"); // 이미 존재한다

			return;
		}
		p_list.insertPatient(p);
	}

	fin.close();
}
Example #2
0
// 입원 중이거나 입원한 적이 있는 환자의 환자 번호를 입력 받는다. 
string ioHandler::getPatientId(PatientList& p_list, string msg)
{
	string p_id;

	while (1)
	{
		p_id = getString(msg);
		Patient p = p_list.searchPatient(p_id);
		if (p.patient_id != "")	break;		// if valid patient id
		putString("", "Invalid patient id!!, Retry!!");
	}
	return p_id;
}
Example #3
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();
}
Example #4
0
StaffAssign ioHandler::getNurseAssign(PatientList& p_list, StaffList& s_list)
{
	StaffAssign sa;
	sa.patient_id = getPatientId(p_list, "직원을 변경할 환자의 번호 : ");
	Patient p = p_list.searchPatient(sa.patient_id);

	sa.change_date = getCurrentDate();
	cout << endl << "변경일(yyyymmdd) : " << sa.change_date;

	sa.before_staff = p.nurse_assigned;
	cout << "변경전 담당 간호사 : " << sa.before_staff;
	sa.after_staff = getStaffId(s_list, "");
	return sa;
}
Example #5
0
RoomChange ioHandler::getRoomChange(PatientList& p_list, RoomList& r_list)
{
	RoomChange rc;
	rc.patient_id = getPatientId(p_list, "병실을 변경할 환자의 번호 : ");
	Patient p = p_list.searchPatient(rc.patient_id);

	rc.change_date = getCurrentDate();
	cout << endl << "변경일(yyyymmdd) : " << rc.change_date;
	//cin >> rc.change_date;

	rc.before_room = p.room_no;
	cout << "변경전 병실 번호 : " << rc.before_room;
	rc.after_room = getRoomNo(r_list);
	return rc;
}
Example #6
0
void FileHandler::loadPatientList(string fname, PatientList& p_list)
{	// open file
	ifstream fin;
	fin.open(fname, ios_base::in);
	if (!fin) 
	{
		cerr << "\n" << "can't open file!!";
		return;
	}

	// read data from file
	Patient p;
	while (!fin.eof()) // read data
	{
		fin >> p.patient_id >> p.name >> p.sex >> p.birth_date >> p.phone_no >> p.entering_date >> p.entering_time
			>> p.disease >> p.room_no >> p.doctor_assigned >> p.nurse_assigned >> p.leaving_date >> p.leaving_time;
		p_list.insertPatient(p);
	}

	// close file
	fin.close();
}
Example #7
0
Patient ioHandler::getPatient(PatientList& p_list)
{
	Patient p;
	string today = getCurrentDate();
	cout << "신규 환자에 대한 자료 입력" << endl;
	p.patient_id = p_list.findMaxPatientId(today.substr(0, 4));
	cout << endl << "환자번호: " << p.patient_id;
	putNewLine();
	cout << endl << "성명: ";
	cin >> p.name;
	cout << endl << "성별(M: 남성 / F: 여성) : ";
	cin >> p.sex;
	cout << endl << "생년월일(yyyymmdd) : ";
	cin >> p.birth_date;
	cout << endl << "휴대전화번호: ";
	cin >> p.phone_no;
	p.entering_date = getCurrentDate();
	putNewLine();
	cout << endl << "입원일(yyyymmdd) : " << p.entering_date;
	//cout << endl << "입원일(yyyymmdd) : ";
	//cin >> p.entering_date;
	p.entering_time = getCurrentTime();
	putNewLine();
	cout << endl << "입원시간(hhmm) : " << p.entering_time;
	//cout << endl << "입원시간(hhmm) : ";
	//cin >> p.entering_time;
	putNewLine();
	cout << endl << "병명: ";
	cin >> p.disease;
	cout << endl << "병실: ";
	cin >> p.room_no;
	cout << endl << "주치의: ";
	cin >> p.doctor_assigned;
	cout << endl << "담당 간호사 : ";
	cin >> p.nurse_assigned;
	p.leaving_date = "xxxx0101";
	p.leaving_time = "xxxx";
	return p;
}
Example #8
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();
}