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(); }
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(); }