public void RunScript_GetFieldValue_OptionObject2015_FormCountEquals0()
        {
            // Arrange
            FieldObject fieldObject = new FieldObject()
            {
                FieldNumber = "123",
                FieldValue  = "TESTING"
            };
            RowObject rowObject = new RowObject()
            {
                Fields = new List <FieldObject>()
                {
                    fieldObject
                },
                RowId = "1||1"
            };
            FormObject formObject = new FormObject()
            {
                CurrentRow = rowObject,
                FormId     = "1"
            };
            OptionObject2015 optionObject = new OptionObject2015()
            {
                Forms = new List <FormObject>()
                {
                    formObject
                }
            };
            string parameter = "GetFieldValue,123";

            // Act
            OptionObject2015 returnOptionObject = GetFieldValue.RunScript(optionObject, parameter);

            // Assert
            Assert.AreEqual(0, returnOptionObject.Forms.Count);
        }
        public static OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter)
        {
            OptionObject2015 returnOptionObject = new OptionObject2015();

            string[] parameters    = parameter.Split(',');
            string   fieldNumber   = parameters.Length >= 2 ? parameters[1] : "";
            string   returnMessage = "The FieldValue is ";

            foreach (var form in optionObject.Forms)
            {
                foreach (var currentField in form.CurrentRow.Fields)
                {
                    if (currentField.FieldNumber == fieldNumber)
                    {
                        returnMessage += currentField.FieldValue;
                    }
                }
            }

            returnOptionObject.ErrorCode = 3;
            returnOptionObject.ErrorMesg = returnMessage + ". Since no FieldObjects were modified, no Forms should be returned.";

            returnOptionObject.EntityID        = optionObject.EntityID;
            returnOptionObject.EpisodeNumber   = optionObject.EpisodeNumber;
            returnOptionObject.Facility        = optionObject.Facility;
            returnOptionObject.NamespaceName   = optionObject.NamespaceName;
            returnOptionObject.OptionId        = optionObject.OptionId;
            returnOptionObject.OptionStaffId   = optionObject.OptionStaffId;
            returnOptionObject.OptionUserId    = optionObject.OptionUserId;
            returnOptionObject.ParentNamespace = optionObject.ParentNamespace;
            returnOptionObject.ServerName      = optionObject.ServerName;
            returnOptionObject.SystemCode      = optionObject.SystemCode;
            returnOptionObject.SessionToken    = optionObject.SessionToken;

            return(returnOptionObject);
        }
Ejemplo n.º 3
0
        private void sendNotificationToMailingList(OptionObject2015 hardStopToReturn)
        {
            // Data drive configuration
            try
            {
                MailMessage mail       = new MailMessage("*****@*****.**", TxPlanHardStopConfig.GetTxPlanHardStopConfig().mailList);
                SmtpClient  SmtpServer = new SmtpClient("10.20.20.214");

                mail.Subject = "HARD STOP: " + System.DateTime.Now.ToString("MM/dd/yyyy h:mm");
                mail.Body    = "A hard stop occurred at " + System.DateTime.Now.ToString("MM/dd/yyyy h:mm") + " for client: " + client + ".  ";
                mail.Body   += "\n  Terri, this an contain whatever you like.\n";
                mail.Body   += "Value:  " + hardStopToReturn.ErrorMesg;

                SmtpServer.Port        = 25;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "3edcVFR$3edc");

                SmtpServer.Send(mail);
                log.Debug("SDJL: Mail Sent at: " + DateTime.Now.ToString("MM/dd/yyyy h:mm"));
            }
            catch (Exception e)
            {
                log.Debug("SDJL Send Email Exception: " + e.ToString());
            }
        }
Ejemplo n.º 4
0
        public void IsFieldModified_OptionObject2015_IsFalse()
        {
            // Arrange
            FieldObject fieldObject01 = new FieldObject("123", "");
            FieldObject fieldObject02 = new FieldObject("124", "");
            FieldObject fieldObject03 = new FieldObject("125", "");
            RowObject   rowObject01   = new RowObject("1||1", new List <FieldObject>()
            {
                fieldObject01, fieldObject02, fieldObject03
            });
            FormObject       formObject   = new FormObject("1", rowObject01);
            OptionObject2015 optionObject = new OptionObject2015()
            {
                Forms = new List <FormObject>()
                {
                    formObject
                }
            };

            // Act

            // Assert
            Assert.IsFalse(optionObject.IsFieldModified("123"));
        }
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.OpenUrl, "https://rarelysimple.com"));
 }
Ejemplo n.º 6
0
 public GetOdbcDataCommand(OptionObject2015 optionObject2015, IGetDataRepository repository)
 {
     _optionObject2015 = optionObject2015;
     _repository       = repository;
 }
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.OpenForm, "[PM]USER100"));
 }
Ejemplo n.º 8
0
 public HelloWorldCommand(OptionObject2015 optionObject2015)
 {
     _optionObject2015 = optionObject2015;
 }
Ejemplo n.º 9
0
        public OptionObject2015 Execute()
        {
            string[] temp = _parameter.Split(',');
            var      returnOptionObject = new OptionObject2015();
            var      formObject         = new FormObject();
            var      startTimeField     = new FieldObject();
            var      endTimeField       = new FieldObject();
            var      durationField      = new FieldObject();
            string   returnMessage      = "";

            try
            {
                formObject.FormId          = temp[1];
                startTimeField.FieldNumber = temp[2];
                endTimeField.FieldNumber   = temp[3];
                durationField.FieldNumber  = temp[4];
                foreach (var form in _optionObject2015.Forms)
                {
                    foreach (var field in form.CurrentRow.Fields)
                    {
                        if (field.FieldNumber == startTimeField.FieldNumber)
                        {
                            startTimeField.FieldValue = field.FieldValue;
                        }
                        else if (field.FieldNumber == endTimeField.FieldNumber)
                        {
                            endTimeField.FieldValue = field.FieldValue;
                        }
                        else if (field.FieldNumber == durationField.FieldNumber)
                        {
                            durationField.FieldValue     = field.FieldValue;
                            formObject.MultipleIteration = form.MultipleIteration;
                        }
                    }
                }
                if (temp[5] == "Dur")
                {
                    // calculate the duration from the start time and end time
                    durationField.FieldValue = ChangeDuration(DateTime.Parse(startTimeField.FieldValue), DateTime.Parse(endTimeField.FieldValue)).TotalMinutes.ToString();
                }
                else
                {
                    // calculate the end time from the start time and duration
                    endTimeField.FieldValue = ChangeEndTime(DateTime.Parse(startTimeField.FieldValue), double.Parse(durationField.FieldValue)).ToString("hh:mmtt");
                }

                if (DateTime.Parse(startTimeField.FieldValue) > DateTime.Parse(endTimeField.FieldValue))
                {
                    logger.Error("Start Time must be before End Time");
                    throw new IndexOutOfRangeException("Start Time must be before End Time");
                }

                //var fields = new FieldObject[1];
                var fields = new List <FieldObject>
                {
                    temp[5] == "Dur" ? durationField : endTimeField
                };
                var currentRow = new RowObject
                {
                    Fields = fields
                };
                foreach (var form in _optionObject2015.Forms)
                {
                    if (form.FormId == formObject.FormId)
                    {
                        currentRow.RowId       = form.CurrentRow.RowId;
                        currentRow.ParentRowId = form.CurrentRow.ParentRowId;
                    }
                }
                currentRow.RowAction  = "EDIT";
                formObject.CurrentRow = currentRow;
                //var forms = new FormObject[1];
                //forms[0] = formObject;
                //returnOptionObject.Forms = forms;
                returnOptionObject.Forms.Add(formObject);
            }
            catch (FormatException)
            {
                logger.Info("The start date or duration is invalid!");
                //returnMessage = "\nStop: The start date or duration is invalid! ";
                //returnOptionObject.ErrorCode = 3;
            }
            catch (ArgumentOutOfRangeException eo)
            {
                logger.Error(eo, "Error: {errorMessage}", eo.Message);
                returnMessage = eo.Message;
                returnOptionObject.ErrorCode = 1;
            }
            catch (Exception e)
            {
                returnMessage = e.Message + " -Duration/Time Error - \n\n" +
                                e.GetType().ToString() + "\n" +
                                e.StackTrace;
                returnOptionObject.ErrorCode = 3;
                logger.Error(e, "Error: {errorMessage}", e.Message);
            }

            returnOptionObject.ErrorMesg = returnMessage;

            returnOptionObject.EntityID        = _optionObject2015.EntityID;
            returnOptionObject.EpisodeNumber   = _optionObject2015.EpisodeNumber;
            returnOptionObject.Facility        = _optionObject2015.Facility;
            returnOptionObject.NamespaceName   = _optionObject2015.NamespaceName;
            returnOptionObject.OptionId        = _optionObject2015.OptionId;
            returnOptionObject.OptionStaffId   = _optionObject2015.OptionStaffId;
            returnOptionObject.OptionUserId    = _optionObject2015.OptionUserId;
            returnOptionObject.ParentNamespace = _optionObject2015.ParentNamespace;
            returnOptionObject.ServerName      = _optionObject2015.ServerName;
            returnOptionObject.SystemCode      = _optionObject2015.SystemCode;
            returnOptionObject.SessionToken    = _optionObject2015.SessionToken;

            return(returnOptionObject);
        }
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.Confirm, "The code means the RunScript is prompting a confirmation."));
 }
Ejemplo n.º 11
0
 public ChkChrsCommand(OptionObject2015 optionObject2015, string parameter)
 {
     _optionObject2015 = optionObject2015;
     _parameter        = parameter;
 }
        public void GetReturnOptionObject_NoCurrentRowModifiedReturnsWithoutException()
        {
            OptionObject2015 expected = new OptionObject2015("USER37", "unittestuser", "", "1", "", 0, "UAT", "AVPM", "AVPM", "SERVER", "TOKEN");

            FieldObject fieldObject01 = new FieldObject("214.74", "2");
            FieldObject fieldObject02 = new FieldObject("214.98", "12/07/2020");
            RowObject   rowObject01   = new RowObject("33||1");

            rowObject01.AddFieldObject(fieldObject01);
            rowObject01.AddFieldObject(fieldObject02);
            FormObject form33 = new FormObject("33", rowObject01, false);

            expected.AddFormObject(form33);

            FieldObject fieldObject03 = new FieldObject("214.75", "");
            FieldObject fieldObject04 = new FieldObject("214.76", "");
            FieldObject fieldObject05 = new FieldObject("214.77", "");
            FieldObject fieldObject06 = new FieldObject("214.78", "");
            FieldObject fieldObject07 = new FieldObject("214.79", "");
            FieldObject fieldObject08 = new FieldObject("214.8", "");
            FieldObject fieldObject09 = new FieldObject("214.81", "");
            FieldObject fieldObject10 = new FieldObject("214.82", "");
            FieldObject fieldObject11 = new FieldObject("214.83", "");
            FieldObject fieldObject12 = new FieldObject("214.85", "");
            FieldObject fieldObject13 = new FieldObject("214.86", "30");
            FieldObject fieldObject14 = new FieldObject("214.91", "");
            FieldObject fieldObject15 = new FieldObject("214.93", "");
            FieldObject fieldObject16 = new FieldObject("214.94", "");
            FieldObject fieldObject17 = new FieldObject("214.96", "12/3/2020");
            FieldObject fieldObject18 = new FieldObject("214.97", "12/4/2020");
            RowObject   rowObject02   = new RowObject("34||1", "33||1");

            rowObject02.AddFieldObject(fieldObject03);
            rowObject02.AddFieldObject(fieldObject04);
            rowObject02.AddFieldObject(fieldObject05);
            rowObject02.AddFieldObject(fieldObject06);
            rowObject02.AddFieldObject(fieldObject07);
            rowObject02.AddFieldObject(fieldObject08);
            rowObject02.AddFieldObject(fieldObject09);
            rowObject02.AddFieldObject(fieldObject10);
            rowObject02.AddFieldObject(fieldObject11);
            rowObject02.AddFieldObject(fieldObject12);
            rowObject02.AddFieldObject(fieldObject13);
            rowObject02.AddFieldObject(fieldObject14);
            rowObject02.AddFieldObject(fieldObject15);
            rowObject02.AddFieldObject(fieldObject16);
            rowObject02.AddFieldObject(fieldObject17);
            rowObject02.AddFieldObject(fieldObject18);

            FieldObject fieldObject19 = new FieldObject("214.75", "");
            FieldObject fieldObject20 = new FieldObject("214.76", "");
            FieldObject fieldObject21 = new FieldObject("214.77", "");
            FieldObject fieldObject22 = new FieldObject("214.78", "");
            FieldObject fieldObject23 = new FieldObject("214.79", "");
            FieldObject fieldObject24 = new FieldObject("214.8", "");
            FieldObject fieldObject25 = new FieldObject("214.81", "");
            FieldObject fieldObject26 = new FieldObject("214.82", "");
            FieldObject fieldObject27 = new FieldObject("214.83", "");
            FieldObject fieldObject28 = new FieldObject("214.85", "");
            FieldObject fieldObject29 = new FieldObject("214.86", "110");
            FieldObject fieldObject30 = new FieldObject("214.91", "");
            FieldObject fieldObject31 = new FieldObject("214.93", "");
            FieldObject fieldObject32 = new FieldObject("214.94", "");
            FieldObject fieldObject33 = new FieldObject("214.96", "12/4/2020");
            FieldObject fieldObject34 = new FieldObject("214.97", "");
            RowObject   rowObject03   = new RowObject("34||2", "33||1");

            rowObject03.AddFieldObject(fieldObject19);
            rowObject03.AddFieldObject(fieldObject20);
            rowObject03.AddFieldObject(fieldObject21);
            rowObject03.AddFieldObject(fieldObject22);
            rowObject03.AddFieldObject(fieldObject23);
            rowObject03.AddFieldObject(fieldObject24);
            rowObject03.AddFieldObject(fieldObject25);
            rowObject03.AddFieldObject(fieldObject26);
            rowObject03.AddFieldObject(fieldObject27);
            rowObject03.AddFieldObject(fieldObject28);
            rowObject03.AddFieldObject(fieldObject29);
            rowObject03.AddFieldObject(fieldObject30);
            rowObject03.AddFieldObject(fieldObject31);
            rowObject03.AddFieldObject(fieldObject32);
            rowObject03.AddFieldObject(fieldObject33);
            rowObject03.AddFieldObject(fieldObject34);

            rowObject03.SetFieldValue("214.96", "12/5/2020");

            FormObject form34 = new FormObject("34")
            {
                MultipleIteration = true
            };

            form34.OtherRows.Add(rowObject02);
            form34.OtherRows.Add(rowObject03);
            expected.AddFormObject(form34);

            OptionObject2015 actual = (OptionObject2015)expected.ToReturnOptionObject();

            Assert.AreEqual(expected.OptionId, actual.OptionId);
        }
Ejemplo n.º 13
0
        public OptionObject2015 RunScript(OptionObject2015 inputObject, String scriptParameter)
        {/*
          * var config = new NLog.Config.LoggingConfiguration();
          *
          * // Targets where to log to: File and Console
          * var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "c:\\temp\\log_06_04_2020.txt" };
          * var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
          *
          * // Rules for mapping loggers to targets
          * config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole);
          * config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
          *
          * // Apply config
          * NLog.LogManager.Configuration = config;
          */
            Logger log = LogManager.GetCurrentClassLogger();

            log.Debug("SDJL - BEGIN RunScript");

            // Actually perform the action
            OptionObject2015 returnObject = CopyObject(inputObject);

            DateTime dateOfService;
            String   recipientOfBloodTransfusion = ""; // ti_1
            String   longTermHemoDialysis        = ""; //ti_2
            String   recipientClottingFactor     = ""; // ti_3
            String   stuckByNeedle        = "";        // ti_4
            String   birthMotherHepatitis = "";        // ti_5

            // ti_6
            String yellowDiscoloration = "";
            String swellingAbdomen     = "";
            String abnormalLiver       = "";
            String nausea = "";
            String abnormalBloodClotting = "";
            String lossAppetiteWeight    = "";
            String dilationArteries      = "";


            String sexPartnersHepBC = ""; // ti_7
            String tattooPiercing   = ""; // ti_8


            // ti_9a
            String closeContactActiveTB = "";
            String hadPositiveTBTest    = "";
            String treatedForTB         = "";
            String hadAbnormalChestXRay = "";

            // ti_9b
            String diagnosedWithHIV          = "";
            String blackLung                 = "";
            String kidneyFailure             = "";
            String diabetes                  = "";
            String bleedingClottingDisorders = "";
            String silicosis                 = "";
            String specificMalignancies      = "";
            String anyOtherImmuneDisorder    = "";

            // ti_10
            String riskyPlaces = "";

            // ti_11
            String employedHealthCareVolunteerHighRisk = "";

            // ti_12
            String correctionFacility           = "";
            String homelessShelter              = "";
            String nursingHome                  = "";
            String residentialTreatmentFacility = "";
            String mentalInstitution            = "";
            String transitionalLiving           = "";

            // ti_13[0..6] - Field Number: 86.36 - Mark all of the following that currently apply
            String continuousCough       = "";
            String prolongedLossAppetite = "";
            String coughedUpBlood        = "";
            String unexplainedWeightLoss = "";
            String swollenLymphNodes     = "";
            String recurrentFevers       = "";

            //ti_14 - Field Number 86.48 - Have you had multiple sexual partners
            String multipleSexPartners = "";

            // ti_15 - Field Number: 86.49 - Have you ever had anal sex?
            String analSex = "";

            // ti_16 - FieldNumber: 86.37 -  How often have you used protection
            Int64 usedProtection = 0;

            // ti_17 - FieldNumber: 86.50 - Have you used a needle to inject any substance.
            String usedNeedle = "";

            // ti_18 - FieldNumber: 86.51 - .. your sexual partner ever injected any substance with a needle.
            String sexPartnerUsedNeedle = "";

            // ti_19 - FieldNumber: 86.38 - Hav you or any of your sexual partners ever had...
            String gonorrhea      = "";
            String hpv            = "";
            String cervicalCancer = "";
            String syphilis       = "";
            String genitalHerpes  = "";
            String chlamydia      = "";
            String hepatitis      = "";


            // Return values;
            String referForHepTest = "";


            //Add your script call(s) here
            switch (scriptParameter)
            {
            case "HS_TIInfectiousDisease Calculate":
                foreach (FormObject form in inputObject.Forms)
                {
                    foreach (FieldObject field in form.CurrentRow.Fields)
                    {
                        if (field.FieldNumber.Equals("86.29"))
                        {
                            String dateOfServiceString = field.FieldValue;
                            try
                            {
                                dateOfService = DateTime.Parse(dateOfServiceString);
                            }
                            catch (FormatException e)
                            {
                                returnObject.Forms.ElementAt(0).CurrentRow.RowAction = "EDIT";
                                returnObject.ErrorCode = 3;
                                returnObject.ErrorMesg = "Invalid Date Format";
                                log.Debug("SDJL: Exception Caught: " + e.StackTrace);
                                return(returnObject);
                            }
                        }
                        // ti_1
                        if (field.FieldNumber.Equals("86.42"))
                        {
                            recipientOfBloodTransfusion = field.FieldValue;
                        }
                        // ti_2
                        if (field.FieldNumber.Equals("86.42"))
                        {
                            longTermHemoDialysis = field.FieldValue;
                        }
                        // ti_3
                        if (field.FieldNumber.Equals("86.52"))
                        {
                            recipientClottingFactor = field.FieldValue;
                        }
                        // ti_4
                        if (field.FieldNumber.Equals("86.43"))
                        {
                            stuckByNeedle = field.FieldValue;
                        }
                        // ti_5
                        if (field.FieldNumber.Equals("86.44"))
                        {
                            birthMotherHepatitis = field.FieldValue;
                        }

                        // ti_6
                        if (field.FieldNumber.Equals("86.31"))
                        {
                            Console.WriteLine("SDJL - ti_6 - RAW: '" + field.FieldValue + "'");
                            String   markAllOfTheFollowing = field.FieldValue;
                            String[] markAllSelected       = markAllOfTheFollowing.Split('&');

                            foreach (String selection in markAllSelected)
                            {
                                switch (selection)
                                {
                                case "1":
                                    yellowDiscoloration = "Y";
                                    break;

                                case "2":
                                    swellingAbdomen = "Y";
                                    break;

                                case "3":
                                    abnormalLiver = "Y";
                                    break;

                                case "4":
                                    nausea = "Y";
                                    break;

                                case "5":
                                    abnormalBloodClotting = "Y";
                                    break;

                                case "6":
                                    lossAppetiteWeight = "Y";
                                    break;

                                case "7":
                                    dilationArteries = "Y";
                                    break;
                                }
                            }
                        }

                        // ti_7
                        if (field.FieldNumber.Equals("86.32"))
                        {
                            sexPartnersHepBC = field.FieldValue;
                        }

                        // ti_8
                        if (field.FieldNumber.Equals("86.45"))
                        {
                            tattooPiercing = field.FieldValue;
                        }

                        // ti_9
                        if (field.FieldNumber.Equals("86.33"))
                        {
                            Console.WriteLine("SDJL - 9A RAW: '" + field.FieldValue + "'");
                            String   selectedValues = field.FieldValue;
                            String[] selection      = selectedValues.Split('&');
                            foreach (String value in selection)
                            {
                                switch (value)
                                {
                                case "1":
                                    closeContactActiveTB = "Y";
                                    break;

                                case "2":
                                    hadPositiveTBTest = "Y";
                                    break;

                                case "3":
                                    treatedForTB = "Y";
                                    break;

                                case "4":
                                    hadAbnormalChestXRay = "Y";
                                    break;
                                }
                            }
                        }

                        // ti_9b
                        if (field.FieldNumber.Equals("86.34"))
                        {
                            String   selection   = field.FieldValue;
                            String[] allSelected = selection.Split('&');

                            foreach (String value in allSelected)
                            {
                                switch (value)
                                {
                                case "1":
                                    diagnosedWithHIV = "Y";
                                    break;

                                case "2":
                                    blackLung = "Y";
                                    break;

                                case "3":
                                    kidneyFailure = "Y";
                                    break;

                                case "4":
                                    diabetes = "Y";
                                    break;

                                case "5":
                                    bleedingClottingDisorders = "Y";
                                    break;

                                case "6":
                                    silicosis = "Y";
                                    break;

                                case "7":
                                    specificMalignancies = "Y";
                                    break;

                                case "8":
                                    anyOtherImmuneDisorder = "Y";
                                    break;
                                }
                            }
                        }

                        // ti_10
                        if (field.FieldNumber.Equals("86.46"))
                        {
                            riskyPlaces = field.FieldValue;
                        }

                        // ti_11
                        if (field.FieldNumber.Equals("86.47"))
                        {
                            employedHealthCareVolunteerHighRisk = field.FieldValue;
                        }

                        // ti_12
                        if (field.FieldNumber.Equals("86.35"))
                        {
                            String   allSelected = field.FieldValue;
                            String[] selected    = allSelected.Split('&');
                            foreach (String selection in selected)
                            {
                                switch (selection)
                                {
                                case "1":
                                    correctionFacility = "Y";
                                    break;

                                case "2":
                                    homelessShelter = "Y";
                                    break;

                                case "3":
                                    nursingHome = "y";
                                    break;

                                case "4":
                                    residentialTreatmentFacility = "Y";
                                    break;

                                case "5":
                                    mentalInstitution = "Y";
                                    break;

                                case "6":
                                    transitionalLiving = "Y";
                                    break;
                                }
                            }
                        }

                        //ti_13
                        if (field.FieldNumber.Equals("86.36"))
                        {
                            String   allSelected = field.FieldValue;
                            String[] selected    = allSelected.Split('&');
                            foreach (String selection in selected)
                            {
                                switch (selection)
                                {
                                case "1":
                                    continuousCough = "Y";
                                    break;

                                case "2":
                                    prolongedLossAppetite = "Y";
                                    break;

                                case "3":
                                    coughedUpBlood = "Y";
                                    break;

                                case "4":
                                    unexplainedWeightLoss = "Y";
                                    break;

                                case "5":
                                    swollenLymphNodes = "Y";
                                    break;

                                case "6":
                                    recurrentFevers = "Y";
                                    break;
                                }
                            }
                        }

                        // ti_14
                        if (field.FieldNumber.Equals("86.48"))
                        {
                        }

                        // ti_15
                        if (field.FieldNumber.Equals("86.49"))
                        {
                            multipleSexPartners = field.FieldValue;
                        }

                        // ti_16
                        if (field.FieldNumber.Equals("86.37"))
                        {
                            usedProtection = 0;
                            if (!field.FieldValue.Equals(""))
                            {
                                log.Debug("SDJL: Parsing Used Protection");
                                try
                                {
                                    usedProtection = Int64.Parse(field.FieldValue);
                                }
                                catch (Exception e)
                                {
                                    log.Debug("SDJL: Exception Caught: usedProtection: " + field.FieldValue + "   Exception: " + e.StackTrace);
                                }
                            }
                        }

                        // ti_17
                        if (field.FieldNumber.Equals("86.5"))
                        {
                            usedNeedle = field.FieldValue;
                        }

                        // ti_18
                        if (field.FieldNumber.Equals("86.51"))
                        {
                            sexPartnerUsedNeedle = field.FieldValue;
                        }

                        // ti_19
                        if (field.FieldNumber.Equals("86.38"))
                        {
                            String   allSelected = field.FieldValue;
                            String[] selected    = allSelected.Split('&');
                            foreach (String selection in selected)
                            {
                                switch (selection)
                                {
                                case "1":
                                    gonorrhea = "Y";
                                    break;

                                case "2":
                                    hpv = "Y";
                                    break;

                                case "3":
                                    cervicalCancer = "Y";
                                    break;

                                case "4":
                                    syphilis = "Y";
                                    break;

                                case "5":
                                    genitalHerpes = "Y";
                                    break;

                                case "6":
                                    chlamydia = "Y";
                                    break;

                                case "7":
                                    hepatitis = "Y";
                                    break;
                                }
                            }
                        }
                    }
                }


                /*
                 *
                 *
                 */

                // PERFORM SCORE CALCULATIONS FOR CLIENT RECOMMENDATIONS
                // There are 6 seperate scores that are calculated. to determine which check box to select
                // 1.)  symptomsExperienced
                // 2.)  tattooPiercing
                // 3.)  risksExperienced
                // 4.)  selfNeedle
                // 5.)  moreSymptoms
                // 6.)  multipleSexPartners

                // 1.)  from symptomsExperiences
                Double score1 = 0;

                // score = ti_1 + ti_2 + ti_3 + ti_4 + ti_5 + ti_7 + sum(ti_6)
                score1 += recipientOfBloodTransfusion.Equals("Y") ? 1 : 0; // ti_1
                score1 += longTermHemoDialysis.Equals("Y") ? 1 : 0;        // ti_2
                score1 += recipientClottingFactor.Equals("Y") ? 1 : 0;     // ti_3
                score1 += stuckByNeedle.Equals("Y") ? 1 : 0;               // ti_4
                score1 += birthMotherHepatitis.Equals("Y") ? 1 : 0;        // ti_5
                score1 += sexPartnersHepBC.Equals("Y") ? 1 : 0;            // ti_7

                // Score1 += (sum of ti_6 elements)
                score1 += yellowDiscoloration.Equals("Y") ? 1 : 0;
                score1 += swellingAbdomen.Equals("Y") ? 1 : 0;
                score1 += abnormalLiver.Equals("Y") ? 1 : 0;
                score1 += nausea.Equals("Y") ? 1 : 0;
                score1 += abnormalBloodClotting.Equals("Y") ? 1 : 0;
                score1 += lossAppetiteWeight.Equals("Y") ? 1 : 0;
                score1 += dilationArteries.Equals("Y") ? 1 : 0;

                if (score1 > 0)
                {
                    referForHepTest = "Y";
                }

                // score 2 - ti_8
                Double score2 = 0.0;
                String notifyClientsOfRisks = "";

                score2 += tattooPiercing.Equals("Y") ? 1 : 0;
                if (score2 > 0)
                {
                    notifyClientsOfRisks = "Y";
                }


                // score 3 = sum(ti_9 elements) + ti_12 +
                // ti_10 + ti_11 + sum(ti_9) + sum(ti_9b) + sum(ti_12)
                Double score3          = 0.0;
                String recommendTBTest = "";

                score3 += riskyPlaces.Equals("Y") ? 1 : 0;                         // ti_10
                score3 += employedHealthCareVolunteerHighRisk.Equals("Y") ? 1 : 0; //ti_11

                // sum(ti_9)
                score3 += closeContactActiveTB.Equals("Y") ? 1 : 0;
                score3 += hadPositiveTBTest.Equals("Y") ? 1 : 0;
                score3 += treatedForTB.Equals("Y") ? 1 : 0;
                score3 += hadAbnormalChestXRay.Equals("Y") ? 1 : 0;

                // sum(ti_9b)
                score3 += diagnosedWithHIV.Equals("Y") ? 1 : 0;
                score3 += blackLung.Equals("Y") ? 1 : 0;
                score3 += kidneyFailure.Equals("Y") ? 1 : 0;
                score3 += diabetes.Equals("Y") ? 1 : 0;
                score3 += bleedingClottingDisorders.Equals("Y") ? 1 : 0;
                score3 += silicosis.Equals("Y") ? 1 : 0;
                score3 += specificMalignancies.Equals("Y") ? 1 : 0;
                score3 += anyOtherImmuneDisorder.Equals("Y") ? 1 : 0;

                // sum(ti_12)
                score3 += correctionFacility.Equals("Y") ? 1 : 0;
                score3 += homelessShelter.Equals("Y") ? 1 : 0;
                score3 += nursingHome.Equals("Y") ? 1 : 0;
                score3 += residentialTreatmentFacility.Equals("Y") ? 1 : 0;
                score3 += mentalInstitution.Equals("Y") ? 1 : 0;
                score3 += transitionalLiving.Equals("Y") ? 1 : 0;

                if (score3 > 0)
                {
                    recommendTBTest = "Y";
                }

                // score 4 - ti_17 - Have you used a needle
                Double score4              = 0.0;
                String highRiskOfTB        = "";
                String encourageHIVHEPTest = "";

                score4  = 0;
                score4 += usedNeedle.Equals("Y") ? 1 : 0;
                if (score4 > 0)
                {
                    encourageHIVHEPTest = "Y";
                }


                // score 5 - sum of ti_13 elements (Mark all of the following...)
                Double score5 = 0.0;

                score5 += continuousCough.Equals("Y") ? 1 : 0;
                score5 += prolongedLossAppetite.Equals("Y") ? 1 : 0;
                score5 += coughedUpBlood.Equals("Y") ? 1 : 0;
                score5 += unexplainedWeightLoss.Equals("Y") ? 1 : 0;
                score5 += swollenLymphNodes.Equals("Y") ? 1 : 0;
                score5 += recurrentFevers.Equals("Y") ? 1 : 0;
                if (score5 > 0)
                {
                    highRiskOfTB = "Y";
                }
                // score 6 - ti_14 + ti_15 + ti_16 + ti_17 + ti_18 + sum(ti_19[i]*5)
                Double score6 = 0;

                score6 += multipleSexPartners.Equals("Y") ? 1 : 0;  // ti_14
                score6 += analSex.Equals("Y") ? 1 : 0;              // ti_15
                score6 += (usedProtection < 3) ? 1 : 0;             // ti_16
                score6 += usedNeedle.Equals("Y") ? 1 : 0;           // ti_17
                score6 += sexPartnerUsedNeedle.Equals("Y") ? 1 : 0; // ti_18

                // sum(ti_19)
                score6 += gonorrhea.Equals("Y") ? 5 : 0;
                score6 += hpv.Equals("Y") ? 5 : 0;
                score6 += cervicalCancer.Equals("Y") ? 5 : 0;
                score6 += syphilis.Equals("Y") ? 5 : 0;
                score6 += genitalHerpes.Equals("Y") ? 5 : 0;
                score6 += chlamydia.Equals("Y") ? 5 : 0;
                score6 += hepatitis.Equals("Y") ? 5 : 0;

                String highRiskOfHIV   = "";
                String mediumRiskOfHIV = "";
                String lowRiskOfHIV    = "";

                if (score6 > 44)
                {
                    highRiskOfHIV = "Y";
                }
                else if (score6 > 24)
                {
                    mediumRiskOfHIV = "Y";
                }
                else
                {
                    lowRiskOfHIV = "Y";
                }

                Double total = score1 + score2 + score3 + score4 + score5 + score6;

                // Construct the string Avatar expects to set the check boxes and
                // radio buttons correctly.  NOTE - ORDER IS IMPORTANT HERE!

                String stdRiskFactors = "";
                if (referForHepTest.Equals("Y"))
                {
                    stdRiskFactors = "1";
                }
                if (notifyClientsOfRisks.Equals("Y"))
                {
                    if (stdRiskFactors.Length > 0)
                    {
                        stdRiskFactors += "&";
                    }
                    stdRiskFactors += "2";
                }
                if (recommendTBTest.Equals("Y"))
                {
                    if (stdRiskFactors.Length > 0)
                    {
                        stdRiskFactors += "&";
                    }
                    stdRiskFactors += "3";
                }
                if (usedNeedle.Equals("Y"))
                {
                    if (stdRiskFactors.Length > 0)
                    {
                        stdRiskFactors += "&";
                    }
                    stdRiskFactors += "4";
                }
                if (highRiskOfTB.Equals("Y"))
                {
                    if (stdRiskFactors.Length > 0)
                    {
                        stdRiskFactors += "&";
                    }
                    stdRiskFactors += "5";
                }

                String hivRiskLevel = "1";     // default
                // Set Radio buttons
                if (highRiskOfHIV.Equals("Y"))
                {
                    hivRiskLevel = "1";
                }
                else if (mediumRiskOfHIV.Equals("Y"))
                {
                    hivRiskLevel = "2";
                }
                else if (lowRiskOfHIV.Equals("Y"))
                {
                    hivRiskLevel = "3";
                }

                // Set the values in the return object
                // loop through fields until we find the check boxes and radio buttons.
                foreach (FieldObject field in returnObject.Forms.ElementAt(0).CurrentRow.Fields)
                {
                    if (field.FieldNumber.Equals("283.36"))
                    {
                        field.FieldValue = stdRiskFactors;
                    }
                    if (field.FieldNumber.Equals("283.37"))
                    {
                        field.FieldValue = hivRiskLevel;
                    }
                }
                returnObject.Forms.ElementAt(0).CurrentRow.RowAction = "EDIT";
                returnObject.ErrorCode = 0;
                returnObject.ErrorMesg = "";
                // TIIInfectiousDiseaseCalculateScriptLinkService.ErrorTest(inputObject);
                break;
            }
            log.Debug("SDJL - END RunScript");
            return(returnObject);
        }
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.Error, "The code means the RunScript experienced an Error and to stop processing."));
 }
Ejemplo n.º 15
0
        private OptionObject2015 SetFieldValue(OptionObject2015 optionObject, string parameter)
        {
            OptionObject2015  returnOptionObject = new OptionObject2015();
            List <FormObject> forms = new List <FormObject>();

            foreach (var form in optionObject.Forms)
            {
                List <FieldObject> fields = new List <FieldObject>();
                foreach (var currentField in form.CurrentRow.Fields)
                {
                    switch (currentField.FieldNumber)
                    {
                    case "123":
                        if (string.IsNullOrEmpty(currentField.FieldValue))
                        {
                            FieldObject fieldObject = new FieldObject()
                            {
                                Enabled     = currentField.Enabled,
                                FieldNumber = currentField.FieldNumber,
                                FieldValue  = "I have set the FieldValue.",
                                Lock        = currentField.Lock,
                                Required    = currentField.Required
                            };
                            fields.Add(fieldObject);
                        }
                        else
                        {
                            FieldObject fieldObject = new FieldObject()
                            {
                                Enabled     = currentField.Enabled,
                                FieldNumber = currentField.FieldNumber,
                                FieldValue  = currentField.FieldValue + " (I have appended the FieldValue.)",
                                Lock        = currentField.Lock,
                                Required    = currentField.Required
                            };
                            fields.Add(fieldObject);
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (fields.Count > 0)
                {
                    RowObject rowObject = new RowObject()
                    {
                        Fields      = fields,
                        ParentRowId = form.CurrentRow.ParentRowId,
                        RowAction   = "EDIT",
                        RowId       = form.CurrentRow.RowId,
                    };
                    FormObject formObject = new FormObject()
                    {
                        CurrentRow        = rowObject,
                        FormId            = form.FormId,
                        MultipleIteration = form.MultipleIteration
                    };
                    forms.Add(formObject);
                }
            }
            returnOptionObject.Forms = forms;

            returnOptionObject.ErrorCode = 0;
            returnOptionObject.ErrorMesg = "If FieldNumber 123 is found in OptionObject, then it should be the only FieldObject returned. Otherwise, no Forms should be returned.";

            returnOptionObject.EntityID        = optionObject.EntityID;
            returnOptionObject.EpisodeNumber   = optionObject.EpisodeNumber;
            returnOptionObject.Facility        = optionObject.Facility;
            returnOptionObject.NamespaceName   = optionObject.NamespaceName;
            returnOptionObject.OptionId        = optionObject.OptionId;
            returnOptionObject.OptionStaffId   = optionObject.OptionStaffId;
            returnOptionObject.OptionUserId    = optionObject.OptionUserId;
            returnOptionObject.ParentNamespace = optionObject.ParentNamespace;
            returnOptionObject.ServerName      = optionObject.ServerName;
            returnOptionObject.SystemCode      = optionObject.SystemCode;
            returnOptionObject.SessionToken    = optionObject.SessionToken;

            return(returnOptionObject);
        }
Ejemplo n.º 16
0
        public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter)
        {
            OptionObject2015 returnOptionObject = new OptionObject2015();
            string           scriptName         = parameter != null?parameter.Split(',')[0] : "";

            logger.Debug("Script '" + scriptName + "' requested.");

            switch (scriptName)
            {
            case "GetErrorCode0":
                returnOptionObject = GetErrorCode0(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode1":
                returnOptionObject = GetErrorCode1(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode2":
                returnOptionObject = GetErrorCode2(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode3":
                returnOptionObject = GetErrorCode3(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode4":
                returnOptionObject = GetErrorCode4(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode5":
                returnOptionObject = GetErrorCode5(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode6":
                returnOptionObject = GetErrorCode6(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetFieldValue":
                returnOptionObject = GetFieldValue(optionObject, parameter);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "SetFieldValue":
                returnOptionObject = SetFieldValue(optionObject, parameter);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            default:
                logger.Warn("ScriptName '" + scriptName + "' does not match an existing script.");
                returnOptionObject.ErrorCode = 3;
                returnOptionObject.ErrorMesg = "No script was found with the name '" + parameter + "'.";

                returnOptionObject.EntityID        = optionObject.EntityID;
                returnOptionObject.EpisodeNumber   = optionObject.EpisodeNumber;
                returnOptionObject.Facility        = optionObject.Facility;
                returnOptionObject.NamespaceName   = optionObject.NamespaceName;
                returnOptionObject.OptionId        = optionObject.OptionId;
                returnOptionObject.OptionStaffId   = optionObject.OptionStaffId;
                returnOptionObject.OptionUserId    = optionObject.OptionUserId;
                returnOptionObject.ParentNamespace = optionObject.ParentNamespace;
                returnOptionObject.ServerName      = optionObject.ServerName;
                returnOptionObject.SystemCode      = optionObject.SystemCode;
                returnOptionObject.SessionToken    = optionObject.SessionToken;
                break;
            }

            return(returnOptionObject);
        }
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.Success, "The code means the RunScript was successful."));
 }
Ejemplo n.º 18
0
        public OptionObject2015 Execute()
        {
            string[] temp = _parameter.Split(',');
            var      returnOptionObject = new OptionObject2015();
            var      formObject         = new FormObject();
            var      verifyDataField    = new FieldObject();
            string   holdValidChars     = temp[3];
            string   fieldDesc          = temp[4];
            string   holdValidsAddr     = "^[a-zA-Z0-9 ]*$";
            string   holdValidsName     = "^[a-zA-Z0-9, ]*$";
            string   holdValids;

            //RegexStringValidator re = new RegexStringValidator(holdValidChars);
            if (holdValidChars == "N")
            // valid characters for a name field
            {
                holdValids = holdValidsName;
            }
            else
            // valid characters for an address field
            {
                holdValids = holdValidsAddr;
            }

            RegexStringValidator re = new RegexStringValidator(holdValids);

            string returnMessage = "";

            try
            {
                formObject.FormId           = temp[1];
                verifyDataField.FieldNumber = temp[2];

                foreach (var form in _optionObject2015.Forms)
                {
                    foreach (var field in form.CurrentRow.Fields)
                    {
                        if (field.FieldNumber == verifyDataField.FieldNumber)
                        {
                            verifyDataField.FieldValue   = field.FieldValue;
                            formObject.MultipleIteration = form.MultipleIteration;
                        }
                    }
                }
                // allow regular characters

                re.Validate(verifyDataField.FieldValue);
                //var fields = new FieldObject[1];
                //fields[0] = verifyDataField;
                var currentRow = new RowObject
                {
                    Fields = new List <FieldObject>
                    {
                        verifyDataField
                    }
                };
                foreach (var form in _optionObject2015.Forms)
                {
                    if (form.FormId == formObject.FormId)
                    {
                        currentRow.RowId       = form.CurrentRow.RowId;
                        currentRow.ParentRowId = form.CurrentRow.ParentRowId;
                    }
                }
            }
            catch (ArgumentException eo)
            {
                returnMessage = "There are one or more special characters in the '"
                                + fieldDesc + "' field";
                returnOptionObject.ErrorCode = 1;
                logger.Error(eo, returnMessage);
            }

            catch (Exception e)
            {
                returnMessage = e.Message + " -Validate Character Field- \n\n" +
                                e.GetType().ToString() + "\n" +
                                e.StackTrace;
                returnOptionObject.ErrorCode = 3;
                logger.Error(e, "An error occurred. Error: {errorMessage}.", e.Message);
            }

            returnOptionObject.ErrorMesg = returnMessage;

            returnOptionObject.EntityID        = _optionObject2015.EntityID;
            returnOptionObject.EpisodeNumber   = _optionObject2015.EpisodeNumber;
            returnOptionObject.Facility        = _optionObject2015.Facility;
            returnOptionObject.NamespaceName   = _optionObject2015.NamespaceName;
            returnOptionObject.OptionId        = _optionObject2015.OptionId;
            returnOptionObject.OptionStaffId   = _optionObject2015.OptionStaffId;
            returnOptionObject.OptionUserId    = _optionObject2015.OptionUserId;
            returnOptionObject.ParentNamespace = _optionObject2015.ParentNamespace;
            returnOptionObject.ServerName      = _optionObject2015.ServerName;
            returnOptionObject.SystemCode      = _optionObject2015.SystemCode;
            returnOptionObject.SessionToken    = _optionObject2015.SessionToken;

            return(returnOptionObject);
        }
Ejemplo n.º 19
0
        public OptionObject2015 RunScript(OptionObject2015 inputObject, String scriptParameter)
        {
            OptionObject2015 returnObject = CopyObject(inputObject);// = new OptionObject2015();

            try
            {
                // For testing purposes
                //returnObject.ErrorMesg = "IGNORE - Test Message from David Lloyd";
                //returnObject.ErrorMesg = "TEST ERROR MESSAGE";
                //sendNotificationToMailingList(returnObject);

                returnObject.ErrorCode = 0;  // Default value
                returnObject.ErrorMesg = ""; // Default value


                log.Debug("-----------------------------------------");
                log.Debug("SDJL - BEGIN TxPlanHardStop RunScript 13 '" + scriptParameter + "'");

                // Actually perform the action
                //Add your script call(s) here
                switch (scriptParameter)
                {
                case "HS_TxPlanHardStop NoteOptionLoad":
                    log.Debug("SDJL - HS_TxPlanHardStop NoteOptionLoad");
                    break;

                case "HS_TxPlanHardStop SelectType":
                    foreach (FormObject form in inputObject.Forms)
                    {
                        log.Debug("Form ID: " + form.FormId);
                        foreach (FieldObject field in form.CurrentRow.Fields)
                        {
                            log.Debug("SDJL FieldNumber '" + field.FieldNumber + "'");
                            log.Debug("SDJL FieldValue '" + field.FieldValue + "'");
                            // NOTE - move to switch statement once you find out what the
                            // correct values to serach for are here.
                            switch (field.FieldNumber)
                            {
                            case "50010":
                                draftOrFinal = field.FieldValue;
                                break;

                            case "51200":
                                // Client
                                client = field.FieldValue;
                                break;

                            case "51001":
                                typeOfService = field.FieldValue;
                                break;

                            case "51011":
                                dateOfServiceStr = field.FieldValue;
                                try
                                {
                                    dateOfService = DateTime.Parse(dateOfServiceStr);
                                }
                                catch (FormatException e)
                                {
                                    returnObject.ErrorCode = 3;
                                    returnObject.ErrorMesg = "Invalid Date Formate: Date Of Service";
                                    log.Debug("SDJL Exception Caught: " + e.StackTrace());
                                }
                                break;

                            case "3003":
                                serviceStartTimeStr = field.FieldValue;
                                break;

                            case "3004":
                                serviceEndTimeStr = field.FieldValue;
                                break;

                            case "7000":
                                practitioner = field.FieldValue;
                                break;

                            case "7000.2":
                                coPractitioner = field.FieldValue;
                                break;

                            case "7000.12":
                                incidentToPractitioner = field.FieldValue;
                                break;

                            case "7000.3":
                                claimType = field.FieldValue;
                                break;

                            case "7052":
                                modeOfDelivery = field.FieldValue;
                                break;

                            case "7053":
                                specialStudiesCode = field.FieldValue;
                                break;

                            case "10034":
                                primaryDiagnoisisArrayStr = field.FieldValue;
                                break;

                            case "10050":
                                primaryDiagnoisisArrayStr = field.FieldValue;
                                break;

                            case "10035":
                                secondaryDiagnosis = field.FieldValue;
                                break;

                            case "10051":
                                secondaryDiagnosisArrayStr = field.FieldValue;
                                break;

                            case "10750":
                                progress = field.FieldValue;
                                break;

                            case "10751":
                                noteType = field.FieldValue;
                                break;

                            default:
                                log.Debug("Unknown Field Number: '" + field.FieldNumber + "'");
                                break;
                            }
                        }
                    }
                    log.Debug("SDJL - Client  = '" + client + "'");
                    log.Debug("Date Of Service Str = '" + dateOfServiceStr + "'");
                    log.Debug("Date Of Service = '" + dateOfService.ToString("MM-dd-yyyy"));
                    log.Debug("SDJL - serviceStartTimeStr'" + serviceStartTimeStr + "'");
                    log.Debug("SDJL - serviceEndTimeStr'" + serviceEndTimeStr + "'");
                    log.Debug("SDJL - practitioner'" + practitioner + "'");
                    log.Debug("SDJL - coPractitioner'" + coPractitioner + "'");
                    log.Debug("SDJL - incidentToPractitioner'" + incidentToPractitioner + "'");
                    log.Debug("SDJL - claimType'" + claimType + "'");
                    log.Debug("SDJL - modeOfDelivery'" + modeOfDelivery + "'");
                    log.Debug("SDJL - modeOfDelivery'" + modeOfDelivery + "'");
                    log.Debug("SDJL - primaryDiagnoisisArrayStr '" + primaryDiagnoisisArrayStr + "'");
                    log.Debug("SDJL - secondaryDiagnosis '" + secondaryDiagnosis + "'");
                    log.Debug("SDJL - secondaryDiagnosisArrayStr '" + secondaryDiagnosisArrayStr + "'");
                    log.Debug("SDJL - progress '" + progress + "'");
                    log.Debug("SDJL - Note Type '" + noteType + "'");
                    log.Debug("SDJL - typeOfService  '" + typeOfService + "'");
                    log.Debug("SDJL - currentDate = '" + DateTime.Now.ToString("MM-dd-yyyy"));
                    log.Debug("SDJL - draftOrFinal = '" + draftOrFinal + "'");

                    // PERFORM SQL query - Retrieve plan end date, last updated date
                    //    SELECT patid, last_updated, plan_date, plan_end_date, tx_plan_number
                    //        FROM tx_plan WHERE patid='<client>' ORDER BY last_updated DESC

                    /*
                     *   if most recent treatment plan.end date < current date
                     *           hard stop
                     *
                     *
                     *     if most recent treatment plan.end_date >= date_of_service
                     *           if (treatment plan status != final)
                     *               hard stop
                     */
                    // TODO - Data drive connection string in configuration file.
                    // TODO - connection string username/password needs to be in secure (encrypted) storage.
                    // TODO - This should be in an init method.
                    String connectionString = "DRIVER={InterSystems ODBC};SERVER=10.50.10.148;PORT=1972;DATABASE=AVCWS;UID=UATHS:HSData1;PWD=hsdata!001;";

                    // Retrieve the latest updated treatment plan for the client.
                    string queryString =
                        "SELECT TOP 1 patid, last_updated, plan_date, plan_end_date, tx_plan_number, plan_status_value FROM tx_plan WHERE patid=? ORDER BY last_updated DESC";
                    log.Debug("Before OdbcConnection");
                    using (OdbcConnection connection = new OdbcConnection(connectionString))
                    {
                        log.Debug("SDJL - 23c - Before create command");
                        OdbcCommand command = new OdbcCommand(queryString, connection);
                        command.Parameters.Add("@client", OdbcType.VarChar).Value = client.Trim();
                        log.Debug("SDJL command='" + command.CommandText + "'");
                        log.Debug("SDJL Paramters = '" + command.Parameters.ToString() + "'");


                        log.Debug("SDJL - After Open");
                        connection.Open();
                        log.Debug("SDJL - After Open");

                        // The row will contain the latest updated treatment plan.
                        OdbcDataReader reader = command.ExecuteReader();
                        log.Debug("SDJL - Before Reader");
                        while (reader.Read())
                        {
                            planStartDate   = (DateTime)reader[2];
                            planEndDate     = (DateTime)reader[3];
                            planStatusValue = (String)reader[5];
                            log.Debug("SDJL - Treatment planStartDate = '" + planStartDate + "'");
                            log.Debug("SDJL - Treatment planEndDate = '" + planEndDate + "'");
                            log.Debug("SDJL - Treatment planStatusValue = '" + planStatusValue + "'");
                        }
                        log.Debug("SDJL - After Reader");
                        // Close the reader - done.
                        reader.Close();
                    }

                    // ACTUAL BUSINESS LOGIC
                    // Avatar return codes
                    // 1 - Returns an error message and stops further processing of scripts
                    // 2 - Returns a message with OK/Cancel buttons
                    // 3 - Returns a message with an OK button
                    // 4 - Returns a message with Yes/No buttons
                    // 5 - Returns a URL to be opened in a new browser window
                    // 6 - Returns a list of FormIDs to launch Avatar forms
                    // 0 - Process Option Object and show no message

                    if (requiresTP(typeOfService))
                    {
                        log.Debug("SDJL - Hard Stop Point 0");
                        if (planEndDate < DateTime.Now)
                        {
                            log.Debug("SDJL - Hard Stop 1");
                            returnObject.ErrorCode = 1;
                            returnObject.ErrorMesg = "Hard Stop: Plan End Date: '" + planEndDate + "' is before today";
                        }
                        else
                        {
                            log.Debug("SDJL - Hard Stop 1 - Point 2");
                        }
                        if (planEndDate >= dateOfService)
                        {
                            bool planStatusValueEqualsFinal = String.Equals(planStatusValue, "Final", StringComparison.CurrentCultureIgnoreCase);
                            log.Debug("SDJL - Hard Stop 2, Point 1.2 planStatusValue='" + planStatusValue + "' testCompare='" + planStatusValueEqualsFinal + "'");
                            if (!planStatusValueEqualsFinal)
                            {
                                log.Debug("SDJL - Hard Stop 2, Point 2 - '" + planStatusValue + "'");
                                returnObject.ErrorCode = 1;
                                returnObject.ErrorMesg = "Hard Stop: Plan End Date: '" + planEndDate + "' is before the date of service '" + dateOfService + "'.  Treatment plan is NOT FINAL.";
                            }
                            else
                            {
                                log.Debug("SDJL - Hard Stop 2, Point 3.  Treatment plan is final.");
                            }
                        }
                        else
                        {
                            log.Debug("SDJL - Hard Stop 2 - Point 4 - planEndDate < dateOfService");
                        }
                        if (planStartDate > dateOfService)
                        {
                            log.Debug("SDJL - Hard Stop 3, Point 1");
                            returnObject.ErrorCode = 1;
                            returnObject.ErrorMesg = "Hard Stop: Plan Start Date: '" + planStartDate + "' is after the date of service '" + dateOfService + "'";
                        }
                        else
                        {
                            log.Debug("SDJL - Hard Stop 3, Point 2 - planStartDate <= dateOfService");
                        }
                    }
                    else
                    {
                        log.Debug("Service '" + typeOfService + "' does not require require hard stop");
                    }
                    break;
                }
                log.Debug("SDJL - END TxPlanHardStop RunScript 13 '" + scriptParameter + "'");
                log.Debug("SDJL - Before Return RETVAL = '" + returnObject.ErrorCode + "' message='" + returnObject.ErrorMesg + "'");

                // Send notification to mailing list
                if (returnObject.ErrorCode != 0)
                {
                    sendNotificationToMailingList(returnObject);
                }
                log.Debug("---------------------------------------");
            }
            catch (Exception e)
            {
                log.Debug("SDJL - Exception: " + e.ToString());
            }
            return(returnObject);
        }
Ejemplo n.º 20
0
 public SetFieldValueCommand(OptionObject2015 optionObject2015, string parameter)
 {
     _optionObject = optionObject2015;
     _parameter    = parameter;
 }
 public GetErrorCode5Command(OptionObject2015 optionObject2015)
 {
     _optionObject = optionObject2015;
 }
Ejemplo n.º 22
0
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.Informational, "The code means the RunScript was successful, however is providing an alert or informational notice."));
 }
Ejemplo n.º 23
0
 public AddDurationAndTimeCommand(OptionObject2015 optionObject2015, string parameter)
 {
     _optionObject2015 = optionObject2015;
     _parameter        = parameter;
 }
Ejemplo n.º 24
0
 public static OptionObject2015 RunScript(OptionObject2015 optionObject)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.Warning, "The code means the RunScript is providing a warning requiring a response from the user."));
 }
Ejemplo n.º 25
0
 public DefaultCommand(OptionObject2015 optionObject2015, string parameter)
 {
     _optionObject2015 = optionObject2015;
     _parameter        = parameter;
 }
Ejemplo n.º 26
0
 public static OptionObject2015 RunScript(OptionObject2015 optionObject, string scriptName)
 {
     return(optionObject.ToReturnOptionObject(ErrorCode.Alert, "No script was found with the name '" + scriptName + "'."));
 }
        public OptionObject2015 RunScript(OptionObject2015 optionObject, string parameter)
        {
            OptionObject2015 returnOptionObject = new OptionObject2015();
            string           scriptName         = parameter != null?parameter.Split(',')[0] : "";

            logger.Debug("Script '" + scriptName + "' requested.");

            switch (scriptName)
            {
            case "GetErrorCode0":
                returnOptionObject = GetErrorCode0.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode1":
                returnOptionObject = GetErrorCode1.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode2":
                returnOptionObject = GetErrorCode2.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode3":
                returnOptionObject = GetErrorCode3.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode4":
                returnOptionObject = GetErrorCode4.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode5":
                returnOptionObject = GetErrorCode5.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetErrorCode6":
                returnOptionObject = GetErrorCode6.RunScript(optionObject);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "GetFieldValue":
                returnOptionObject = GetFieldValue.RunScript(optionObject, parameter);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            case "SetFieldValue":
                returnOptionObject = SetFieldValue.RunScript(optionObject, parameter);
                logger.Debug("Script '" + scriptName + "' returned.");
                break;

            default:
                logger.Warn("ScriptName '" + scriptName + "' does not match an existing script.");
                returnOptionObject = DefaultScript.RunScript(optionObject, scriptName);
                break;
            }

            return(returnOptionObject);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Returns the desired command based on the provided <see cref="OptionObject2015"/> and parameter.
        /// </summary>
        /// <param name="optionObject"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static IRunScriptCommand GetCommand(OptionObject2015 optionObject, string parameter)
        {
            if (optionObject == null)
            {
                logger.Error("The provided {object} is null", nameof(OptionObject2015));
                return(new DefaultCommand(optionObject, parameter));
            }

            // Determine ScriptName
            logger.Debug("Parameter for scriptName is:  " + parameter);
            string scriptName = parameter != null?parameter.Split(',')[0] : "";

            logger.Debug("Script '" + scriptName + "' requested.");

            // Get Dependencies
            // Replace with this line when ready to do ODBC from SBOX and BLD
            //ConnectionStringCollection odbcConnectionStrings = ConnectionStringSelector.GetConnectionStringCollection(optionObject.Facility, optionObject.NamespaceName);
            ConnectionStringCollection odbcConnectionStrings = ConnectionStringSelector.GetConnectionStringCollection(optionObject.Facility);

            logger.Debug("Facility is: " + optionObject.Facility);
            var repository = new GetOdbcDataRepository(odbcConnectionStrings);

            logger.Debug("Repository is: " + repository.ToString());
            var smtpService = new SmtpService();

            logger.Debug("SMTP is: " + smtpService.ToString());

            // Select Command, Not Case Sensitive
            switch (scriptName.ToUpperInvariant().Trim())
            {
            // General Commands
            case "ADDDURATIONANDTIME":
                logger.Debug(nameof(AddDurationAndTimeCommand) + " selected.");
                return(new AddDurationAndTimeCommand(optionObject, parameter));

            case "CHKCHRS":
                logger.Debug(nameof(ChkChrsCommand) + " selected.");
                return(new ChkChrsCommand(optionObject, parameter));

            // PM Commands
            case "DIAGNOSISFORMLOAD":
                logger.Debug(nameof(DiagnosisFormLoadCommand) + " selected.");
                return(new DiagnosisFormLoadCommand(optionObject, repository));

            // CWS Commands

            // Testing and Sample ("Utility") Commands
            case "GETODBCDATA":
                logger.Debug(nameof(GetOdbcDataCommand) + " selected.");
                return(new GetOdbcDataCommand(optionObject, repository));

            case "HELLOWORLD":
                logger.Debug(nameof(HelloWorldCommand) + " selected.");
                return(new HelloWorldCommand(optionObject));

            case "SENDTESTEMAIL":
                logger.Debug(nameof(SendTestEmailCommand) + " selected.");
                return(new SendTestEmailCommand(optionObject, parameter, smtpService));

            // If nothing matches
            default:
                logger.Warn(nameof(DefaultCommand) + " selected because ScriptName '" + scriptName + "' does not match an existing command.");
                return(new DefaultCommand(optionObject, parameter));
            }
        }
        public void OptionObject2015_HasFormObject()
        {
            OptionObject2015 optionObject = new OptionObject2015();

            Assert.IsNotNull(optionObject.Forms);
        }
        public void SetFieldValue_OptionObject2015_AreEqual()
        {
            string expected = "Test";

            var fieldObject01 = new FieldObject
            {
                FieldNumber = "122"
            };
            var fieldObject02 = new FieldObject
            {
                FieldNumber = "123"
            };
            var fieldObject03 = new FieldObject
            {
                FieldNumber = "123"
            };
            var fieldObject04 = new FieldObject
            {
                FieldNumber = "123"
            };
            var rowObject01 = new RowObject
            {
                RowId = "1||1"
            };

            rowObject01.Fields.Add(fieldObject01);
            var rowObject02 = new RowObject
            {
                RowId = "2||1"
            };

            rowObject02.Fields.Add(fieldObject02);
            var rowObject03 = new RowObject
            {
                RowId = "2||2"
            };

            rowObject03.Fields.Add(fieldObject03);
            var rowObject04 = new RowObject
            {
                RowId = "2||3"
            };

            rowObject04.Fields.Add(fieldObject04);
            var formObject01 = new FormObject
            {
                FormId     = "1",
                CurrentRow = rowObject01
            };
            var formObject02 = new FormObject
            {
                FormId     = "2",
                CurrentRow = rowObject02
            };

            formObject02.OtherRows.Add(rowObject03);
            formObject02.OtherRows.Add(rowObject04);
            formObject02.MultipleIteration = true;
            var optionObject = new OptionObject2015();

            optionObject.Forms.Add(formObject01);
            optionObject.Forms.Add(formObject02);

            optionObject = (OptionObject2015)OptionObjectHelpers.SetFieldValue(optionObject, "122", "Test");
            string actual = OptionObjectHelpers.GetFieldValue(optionObject, "122");

            Assert.AreEqual(expected, actual);
        }