}//providerReport // Scenario: Request Member Report private void memberReport() { try { //Get the member number long number = ui.promptForLong("Member Number: "); //Search for the member in the collection Members members = new Members(); members.open(); Member theMember = members.find(number); members.close(); if (theMember == null) { ui.errorMessage("Invalid Member Number"); return; } //Get the end date DateTime endDate = ui.promptForDate("End date of week (" + UserInterface.DATE_FORMAT + "): "); //Generate report for specified week MemberReportGenerator generator = new MemberReportGenerator(theMember, endDate); MemberReport report = generator.getReport(); //Display the report report.display(ui); //"Print" (save the report to a file) if the user wishes String answer = ui.promptForString ("Save the report? (Y)es or (N)o: "); if (answer != null && answer.Length >= 1 && Char.ToUpper(answer[0]) == 'Y') { report.print(theMember.getName()); ui.message("The report has been saved as " + report.getFileName() + "\n"); }//if else { ui.message("Report not saved"); } } catch (FileNotFoundException ex) { //occurs if the file cannot be created ui.errorMessage(ex.Message); } }//memberReport
/** * Creates a new MemberReport. * @param aMember the member whose details and services received * are to be included * @param anEndDate the date to be included in the date range */ public MemberReport(Member aMember, DateTime anEndDate) : base(anEndDate) { //Add a title addHeading("Services Received"); //Add date and member details String dateString = getEndDate().ToString(DATE_FORMAT); sb.AppendLine(String.Format("Week Ending: {0} {1,20} Member Number: {2}", dateString, "", aMember.getNumber())); sb.AppendLine(String.Format("Member Name: {0,-32} Address: {1}", aMember.getName(), aMember.getStreet())); sb.AppendLine(String.Format("{0,54} {1}", "", aMember.getCity())); sb.AppendLine(String.Format("{0,54} {1}", "", aMember.getState())); sb.AppendLine(String.Format("{0,54} {1}", "", aMember.getZip())); //Add detail headings sb.AppendLine(String.Format("Service Date Service Provider")); sb.AppendLine(String.Format("------------ ------- --------")); detailCount = 0; }// constructor
/** * Creates a new SchedulerInterface which then runs the accounting procedure. */ public SchedulerInterface() { //for communciation with the tester UserInterface ui = new UserInterface(); ui.message("\nRunning the accounting procedure ...\n"); //Use today's date for all reports DateTime now = DateTime.Today; try { //Generate provider reports ui.message("Generating the providers' reports ..."); Providers providers = new Providers(); providers.open(); List <Person> allProviders = providers.getAll(); foreach (Person person in allProviders) { Provider provider = (Provider)person; ProviderReportGenerator gen = new ProviderReportGenerator(provider, now); ProviderReport theReport = gen.getReport(); if (theReport.getDetailCount() > 0) { theReport.sendByEmail(provider.getName()); } } providers.close(); //Generate member reports ui.message("Generating the members' reports ..."); Members members = new Members(); members.open(); List <Person> allMembers = members.getAll(); foreach (Person person in allMembers) { Member member = (Member)person; MemberReportGenerator gen = new MemberReportGenerator(member, now); MemberReport theReport = gen.getReport(); if (theReport.getDetailCount() > 0) { theReport.sendByEmail(member.getName()); } } members.close(); //Generate accounts payable report ui.message("Generating the accounts payable report ..."); AccountsPayableReportGenerator generator = new AccountsPayableReportGenerator(now); generator.getReport().sendByEmail("Accounts Payable"); //Generate EFT data ui.message("Generating the EFT data ..."); EFTReportGenerator eftGenerator = new EFTReportGenerator(now); eftGenerator.getReport().print("EFT Data"); ui.message("\nAccounting procedure completed successfully.\n\n"); } catch (FileNotFoundException ex) { //occurs if a file cannot be created ui.errorMessage(ex.Message); } }//default constructor
/** Creates a new provider report generator which creates a new provider report. * @param provider the provider about whom the report is generated * @param endDate a date within the week for which the report is to be * generated * @throws FileNotFoundException if the file cannot be created. */ public ProviderReportGenerator(Provider provider, DateTime endDate) { Claims claims = null; Members members = null; Services services = null; //Create a new provider report report = new ProviderReport(provider, endDate); try { //create and open the collections of claims, members and services claims = new Claims(); claims.open(); members = new Members(); members.open(); services = new Services(); services.open(); int noConsultations = 0; //use to count number of consultations double totalFee = 0; //use to accumulate fee //get all claims submitted by provider List <Claim> providerClaims = claims.findByProvider(provider.getNumber()); //for each claim foreach (Claim nextClaim in providerClaims) { //test whether within date range if (nextClaim.getSubmissionDate() > report.getStartDateRange() && nextClaim.getSubmissionDate() < report.getEndDateRange()) { //get the member to whom the service was provided String memberName; Member member = members.find(nextClaim.getMemberNumber()); if (member == null) { memberName = "Invalid Number"; } else { memberName = member.getName(); } //get the fee for the service double serviceFee; Service service = services.find(nextClaim.getServiceCode()); if (service == null) { serviceFee = 0; //indicates invalid code } else { serviceFee = service.getFee(); } //add claim details to report report.addDetail(nextClaim.getSubmissionDate(), nextClaim.getServiceDate(), nextClaim.getMemberNumber(), memberName, nextClaim.getServiceCode(), serviceFee); //increment number of consultations noConsultations++; //accumulate fee totalFee += serviceFee; } //if date in specified week } //for //add summary details to report report.addSummary(noConsultations, totalFee); }//try catch (Exception ex) { report.addErrorMessage(ex.Message); } finally { if (claims != null) { claims.close(); } if (members != null) { members.close(); } if (services != null) { services.close(); } } }//constructor