public void DefaultTimesheetStatus()
        {
            TimesheetForm form;

            form = new TimesheetForm();

            Assert.IsTrue(String.Equals(form.review_status, "Pending"));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: text2doc [image|json] <filename>");
                return;
            }

            // Create empty document
            var document = new Appserver.TextractDocument.TextractDocument();

            switch (args[0])
            {
            case "image":
                Console.WriteLine("##\n##\n## Form Processing Image to Textract: ");
                // Get json response
                if (!File.Exists(Path.Combine(Environment.CurrentDirectory, args[1])))
                {
                    Console.WriteLine(Path.Combine(Environment.CurrentDirectory, args[1]));
                    Console.WriteLine("Could not open file {0}\n", args[1]);
                    Console.WriteLine(Environment.CurrentDirectory);
                    return;
                }
                var imageFile = File.OpenRead(args[1]);
                Console.WriteLine("Sending to Textract\n");
                var handler  = new TextractHandler();
                var response = handler.HandleAsyncJob(imageFile);

                // Write to file
                File.WriteAllText("test.json", JsonConvert.SerializeObject(response, Formatting.Indented));


                document.FromTextractResponse(response);
                Console.WriteLine("Received Response from Textract\n");
                break;

            case "json":
                Console.WriteLine("##\n##\n## Form Processing JSON to Textract: ");
                var jsonFile = File.OpenText(args[1]);

                using (StreamReader reader = jsonFile)
                {
                    document.FromJson((JObject)JToken.ReadFrom(new JsonTextReader(reader)));
                }
                break;
            }

            var p = document.GetPage(0);

            foreach (var l in p.GetFormItems())
            {
                Console.WriteLine(String.Format("Key: {0}\nValue: {1}", l.Key.ToString(), l.Value.ToString()));
            }

            Console.WriteLine("##\n##\n## Beginning Conversion to Timesheet Document:\n##\n");

            var ts = new TimesheetForm();
        }
        public void TenRowTimesheet()
        {
            string path = TestContext.CurrentContext.TestDirectory + @"\FormSubmit\TenRowTimesheet.json";

            if (!File.Exists(path))
            {
                System.Console.WriteLine(path);
                Assert.IsTrue(false);
            }

            string        k   = File.ReadAllText(path).Replace("\r", "");
            TimesheetForm obj = new TimesheetForm();

            obj.clientName        = "Donald Duck";
            obj.prime             = "123456";
            obj.providerName      = "Daughy Duck";
            obj.providerNum       = "654321";
            obj.brokerage         = "Not sure";
            obj.scpaName          = "SC/PA";
            obj.serviceAuthorized = "All";
            obj.units             = 20;
            obj.type      = "Feeding";
            obj.frequency = "Daily";

            obj.addTimeRow("2020-03-20", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-21", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-22", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-23", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-24", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-25", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-26", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-27", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-28", "9:00", "10:00", "1", "true");
            obj.addTimeRow("2020-03-29", "9:00", "10:00", "1", "true");

            obj.totalHours        = "10";
            obj.serviceGoal       = "Feed them";
            obj.progressNotes     = "Eating more fish";
            obj.employerSignature = true;
            obj.employerSignDate  = "2020-04-01";
            obj.authorization     = true;
            obj.approval          = true;
            obj.providerSignature = true;
            obj.providerSignDate  = "2020-04-01";

            // Due to Windows adding \r for newlines we remove these, and for whatever reason Windows
            // Also adds a newline at the end of the file even if it doesn't exist, so we add that.
            string j = JsonConvert.SerializeObject(obj, Formatting.Indented).Replace("\r", "") + "\n";

            Assert.IsTrue(String.Equals(j, k));
        }
        public void EmptyTimesheet()
        {
            string path = TestContext.CurrentContext.TestDirectory + @"\FormSubmit\emptyTimesheet.json";

            if (!File.Exists(path))
            {
                Console.WriteLine(path);
                Assert.IsTrue(false);
            }

            string        k = File.ReadAllText(path).Replace("\r", "");
            TimesheetForm obj;

            obj = new TimesheetForm();

            // Due to Windows adding \r for newlines we remove these, and for whatever reason Windows
            // Also adds a newline at the end of the file even if it doesn't exist, so we add that.
            string j = JsonConvert.SerializeObject(obj, Formatting.Indented).Replace("\r", "") + "\n";

            Assert.IsTrue(String.Equals(j, k));
        }
Exemple #5
0
        protected override void ConvertForm(AbstractFormObject form)
        {
            TimesheetForm ts = (TimesheetForm)form;

            totalHours = new PWAsubmissionVals(ts.totalHours);

            timesheet = new PWAtimesheetEntries();
            var entries = new List <PWAtimesheetVals>();

            foreach (var entry in ts.Times)
            {
                entries.Add(new PWAtimesheetVals
                {
                    date       = entry.date,
                    starttime  = entry.starttime,
                    endtime    = entry.endtime,
                    group      = entry.group,
                    totalHours = entry.totalHours,
                    wasEdited  = false
                });
            }

            timesheet.value = entries;
        }
Exemple #6
0
    /*******************************************************************************
    *  /// Static Methods
    *******************************************************************************/

    public static AbstractFormObject FromTextract(TextractDocument doc, FormType formType)
    {
        // Here we'll Determine the type of object (timesheet or mileage form) and then
        // return the correct type.

        // Grab the first page and make sure it is the front
        if (doc.PageCount() < 2)
        {
            throw new ArgumentException();
        }

        AbstractFormObject form;

        switch (formType)
        {
        case FormType.OR526_ATTENDANT:
        case FormType.OR507_RELIEF:
            form = new TimesheetForm();
            break;

        case FormType.OR004_MILEAGE:
            form = new MileageForm();
            break;

        default:
            throw new ArgumentException();
        }
        // Do a silly assignment because C# won't let me assign the variable in the foreach loop instead
        // and there is no default constructor
        Page        frontpage  = doc.GetPage(0);
        bool        frontfound = false;
        List <Page> backpages  = new List <Page>();

        // Improve front page detection
        foreach (var page in doc.Pages)
        {
            if (!frontfound)
            {
                // Search for Service Delivered On:
                foreach (var line in page.GetLines())
                {
                    // Ever form has "Service Delivered On:" on the front page, so we use
                    // this to determine if this is the front or back.
                    frontfound = line.ToString().Contains("vice Delivered O");
                    if (frontfound)
                    {
                        break;
                    }
                }
                if (frontfound)
                {
                    frontpage = page;
                }
                else
                {
                    backpages.Add(page);
                }
            }
            else
            {
                backpages.Add(page);
            }
        }

        if (!frontfound)
        {
            throw new ArgumentException();
        }
        var formitems = frontpage.GetFormItems();

        // Top Form Information

        form.clientName        = formitems[0].Value.ToString().Trim(); // Customer Name
        form.prime             = formitems[1].Value.ToString().Trim(); // Prime
        form.providerName      = formitems[2].Value.ToString().Trim(); // Provider Name
        form.providerNum       = formitems[3].Value.ToString().Trim(); // Provider Num
        form.brokerage         = formitems[4].Value.ToString().Trim(); // CM Organization
        form.scpaName          = formitems[5].Value.ToString().Trim(); // SC/PA Name
        form.serviceAuthorized = formitems[6].Value.ToString().Trim(); // Service

        // Table
        var tables = frontpage.GetTables();

        if (tables.Count == 0)
        {
            Console.WriteLine("No Table Information");
            return(form);
        }
        form.AddTables(tables);
        // Populate back form objects
        form.AddBackForm(backpages[0]);

        return(form);
    }