예제 #1
0
        /** Creates a new Claim Submitter object
         *  @param theProvider the provider submitting the claim
         *  @param theMember the member to whom the service was provided
         */
        public ClaimSubmitter(Provider theProvider, Member theMember)
        {
            try
            {
                ui = new UserInterface();

                services = new Services();
                claims   = new Claims();
                services.open();
                claims.open();

                //get the service date
                DateTime serviceDate = ui.promptForDate
                                           ("Service Date (" + UserInterface.DATE_FORMAT + "): ");

                //get the correct service
                Service theService  = null;
                bool    correctCode = false;
                do
                {
                    //get the service code
                    String serviceCode = ui.promptForString("Service Code: ");
                    theService = services.find(serviceCode);
                    if (theService == null)
                    {
                        ui.errorMessage("Invalid code.  Please re-enter.");
                    }
                    else
                    {
                        //confirm the service
                        String answer = ui.promptForString("Service: "
                                                           + theService.getName()
                                                           + "  \nIs this correct? (Y)es or (N)o: ");
                        if (answer != null && answer.Length >= 1 &&
                            Char.ToUpper(answer[0]) == 'Y')
                        {
                            correctCode = true;
                        }
                    }
                } while (!correctCode);


                //Create new claim.  The constructor initializes
                //the submission date and time with the system time.
                Claim aClaim = new Claim(theService.getCode(),
                                         theProvider.getNumber(), theMember.getNumber(),
                                         serviceDate);
                claims.add(aClaim);
                //Display success confirmation and service fee
                ui.message("Your claim has been submitted successfully.");
                ui.message("Service fee due to you: "
                           + ui.formatAsCurrency(theService.getFee()));

                services.close();
                claims.close();
            }
            catch (Exception ex)
            {
                //File format is incorrect
                ui.errorMessage(ex.Message);
            }
        }//default constructor
예제 #2
0
        /**
         * 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
예제 #3
0
        /** Creates a new member report generator which creates a new member report.
         *  @param member the member 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 MemberReportGenerator(Member member, DateTime endDate)
        {
            Claims    claims    = null;
            Providers providers = null;
            Services  services  = null;

            //Create a new member report
            report = new MemberReport(member, endDate);

            try
            {
                //create and open the claims, providers and services collections
                claims = new Claims();
                claims.open();
                providers = new Providers();
                providers.open();
                services = new Services();
                services.open();

                //Get all claims submitted for services to this member, ordered by
                //service date
                List <Claim> memberClaims =
                    claims.findByMember(member.getNumber());

                //for each claim
                foreach (Claim nextClaim in memberClaims)
                {
                    //test whether within date range
                    if (nextClaim.getSubmissionDate() > (report.getStartDateRange()) &&
                        nextClaim.getSubmissionDate() < (report.getEndDateRange()))
                    {
                        //get provider
                        String   providerName;
                        Provider provider = providers
                                            .find(nextClaim.getProviderNumber());
                        if (provider == null)
                        {
                            providerName = "Invalid Number";
                        }
                        else
                        {
                            providerName = provider.getName();
                        }

                        //get service
                        String  serviceName;
                        Service service = services.find(nextClaim.getServiceCode());
                        if (service == null)
                        {
                            serviceName = "Invalid Code";
                        }
                        else
                        {
                            serviceName = service.getName();
                        }

                        //add service details to report
                        report.addDetail(nextClaim.getServiceDate(), serviceName,
                                         providerName);
                    } //if date in specified week
                }     //for
            }         //try
            catch (Exception ex)
            {
                report.addErrorMessage(ex.Message);
            }
            finally
            {
                if (claims != null)
                {
                    claims.close();
                }
                if (providers != null)
                {
                    providers.close();
                }
                if (services != null)
                {
                    services.close();
                }
            }
        }//constructor