コード例 #1
0
        /// <summary>
        /// Gets all the Comments in a an application.
        /// There is a Comment ResponseVariable for each screen.
        /// </summary>
        /// <param name="formResultId"></param>
        /// <param name="lineFeed">string used to create a break between comments.</param>
        /// <returns></returns>
        private string GetApplicationComments(int formResultId, string newLine, string tab)
        {
            string result = String.Empty;

            try
            {
                Debug.WriteLine("GetApplicationComments formResultId: " + formResultId.ToString());

                string ivIdentifier = "ADAP_Application_Comments_txt";

                def_ResponseVariables rvCmmt = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, ivIdentifier);
                if (rvCmmt != null)
                {
                    string cmmt = rvCmmt.rspValue;
                    if (!String.IsNullOrEmpty(cmmt))
                    {
                        result = cmmt;
                    }
                }

                result = result.Replace("\n", newLine);
                result = result.Replace("\t", tab);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Applications.GetApplicationComments Exception: " + ex.Message);
                result = "Exception: " + ex.Message;
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Used by the create application method to populate the application with data pulled from Ramsell
        /// this uses the ramsellId from within the formResult's responses,
        /// so applications that do not have a response to the RamsellId item will not be effected by this function
        /// </summary>
        /// <param name="frmRes">Form result for the application to populate</param>
        public static void PopulateItemsFromRamsellImport(IFormsRepository formsRepo, def_FormResults frmRes)
        {
            //get rammsellId (or terminate)
            string ramsellMemberId = String.Empty;

            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(frmRes.formResultId, "ADAP_D9_Ramsell");

            if (rv != null)
            {
                ramsellMemberId = rv.rspValue;
            }

            if (String.IsNullOrWhiteSpace(ramsellMemberId))
            {
                Debug.WriteLine("* * * AdapController.PopulateItemsFromRamsellImport: no RamsellId/MemberId present in formResult " + frmRes.formResultId + ", skipping Ramsell import...");
                return;
            }

            //get oauth token
            // string usrId = "38222218";
            // string password = @"P@ssw0rd";
            string usrId    = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("USR");
            string password = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("PWD");

            Debug.WriteLine("Ramsell UseriD / Password: "******" / " + password);

            string oauthToken = Ramsell.GetOauthToken(usrId, password);

            new RamsellImport(formsRepo, frmRes.formResultId).ImportApplication(oauthToken, ramsellMemberId);
        }
コード例 #3
0
        private string GetSupplementalResponseText(def_ItemVariables iv, def_ResponseVariables rv)
        {
            string responseText;

            if (rv == null)
            {
                responseText = "";
            }
            else
            {
                responseText = rv.rspValue;
                if (iv.baseTypeId == 1)
                {
                    if (responseText.Equals("1") || responseText.ToLower().Equals("true"))
                    {
                        return("yes");
                    }
                    if (responseText.Equals("0") || responseText.ToLower().Equals("false"))
                    {
                        return("no");
                    }
                }
            }
            return(responseText);
        }
コード例 #4
0
        private void PrintGenericSection(PdfOutput output, def_Sections section, int indentLevel)
        {
            output.appendSectionBreak();
            double indent = .5 + labelIndent * (indentLevel - 1);

            output.appendWrappedText(section.identifier, indent, 8 - indent, 12);
            output.drawY -= .2;
            formsRepo.GetSectionItems(section);
            foreach (def_SectionItems si in section.def_SectionItems)
            {
                if (si.subSectionId.HasValue)
                {
                    PrintGenericSection(output, formsRepo.GetSubSectionById(si.subSectionId.Value), indentLevel + 1);
                }
                else
                {
                    def_Items itm = formsRepo.GetItemById(si.itemId);//si.def_Items;
                    indent = labelIndent * indentLevel;
                    output.appendWrappedText(itm.label, indent, 8 - indent, output.boldFont);
                    foreach (def_ItemVariables iv in itm.def_ItemVariables)
                    {
                        def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId);
                        string s = (rv == null) ? "N/A" : rv.rspValue;
                        indent = valueIndent + labelIndent * (indentLevel - 1);
                        output.appendWrappedText(iv.identifier + ": " + s, indent, 8 - indent);
                    }
                    output.drawY -= .1;
                }
            }
        }
コード例 #5
0
        public static int ComputeClientAgeInYears(IFormsRepository formsRepo, int formResultId)
        {
            def_ResponseVariables dobRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "sis_cl_dob_dt");

            if (dobRV == null)
            {
                throw new Exception("could not find date-of-birth response variable with identifier \"sis_cl_dob_dt\" under formResultId " + formResultId);
            }

            def_ResponseVariables dintRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "sis_completed_dt");

            if (dintRV == null)
            {
                throw new Exception("could not find interview-date response variable with identifier \"sis_completed_dt\" under formResultId " + formResultId);
            }

            AssertRVHasDate(dobRV);
            AssertRVHasDate(dintRV);

            //http://stackoverflow.com/a/4127396
            DateTime dob      = dobRV.rspDate.Value;
            DateTime intDate  = dintRV.rspDate.Value;
            DateTime zeroTime = new DateTime(1, 1, 1);
            TimeSpan span     = intDate - dob;

            return((zeroTime + span).AddDays(-1).Year - 1);
        }
コード例 #6
0
        /// <summary>
        /// Called by RamsellExport. Returns null, or content to insert into the [ramsellTagName] node in the ramsell export xml.
        ///
        /// Find and export up to one Transformation matching the ramsellTagName.
        ///
        /// For transformations that export multiple ramsell tags, only the one matching [ramsellTagName] will be used.
        /// Those transformations will typically be run multiple times for each of their export tag names
        /// This is necessary because the xml structure is dictated by a schema
        ///
        /// Running the same transformation export multiple times is reasonable because the actual logic is so simple.
        /// The bottleneck will be in pulling responses from the DB. So if optimization is necessary we should
        /// query all the responses once and pass them to this function
        /// </summary>
        /// <param name="ramsellTagName"></param>
        /// <param name="formResultId"></param>
        /// <param name="formsRepo"></param>
        /// <returns>a string to insert into the ramsell export xml with tagname [ramsellTagName],
        /// or null to indicate that no special-case transformation is available</returns>
        public static string GetExportValueForRamsellTag(string ramsellTagName, int formResultId, IFormsRepository formsRepo)
        {
            //check if any transformations relate to this ramsellTagName
            Transformation matchingTrans = GetTransformationforRamsellTagName(ramsellTagName);

            if (matchingTrans == null)
            {
                //no matching transformation was found, return null to indicate that this ramsellTagName still needs to be handled
                return(null);
            }
            else
            {
                //prepare in/out vars for the transformation
                Dictionary <string, string> inRspValsByItemVar = new Dictionary <string, string>();
                foreach (string itemVarIdentifier in matchingTrans.GetItemVariableIdentifiers())
                {
                    def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, itemVarIdentifier);
                    inRspValsByItemVar.Add(itemVarIdentifier, rv == null ? null : rv.rspValue);
                }

                Dictionary <string, string> outRamsellValsByTag = new Dictionary <string, string>();
                foreach (string rmslTagName in matchingTrans.GetRamsellTagNames())
                {
                    outRamsellValsByTag.Add(rmslTagName, null);
                }

                //run transformation
                matchingTrans.GetExportValuesByRamsellTagName(inRspValsByItemVar, outRamsellValsByTag);

                //return content to insert into this node in the xml export,
                //ignoring any other ramsell tagNames exported by this transformation
                return(outRamsellValsByTag[ramsellTagName]);
            }
        }
コード例 #7
0
        private static string GetFormattedResponse(def_ResponseVariables rv, XmlSchemaSimpleType type, IFormsRepository formsRepo)
        {
            string response = rv.rspValue;

            //for boolean items (typically representing checked checkboxes), check if there is a specific output value in lookup tables
            //negative responses to boolean items (rspValue "0") can be ignored in this step because they will be excluded from the output anyways

            if (rv.rspValue == "1") //this if-statement reduces the number of DB reads, doesn't effect output
            {
                def_ItemVariables iv = formsRepo.GetItemVariableById(rv.itemVariableId);
                if (iv.baseTypeId == 1)
                {
                    def_LookupMaster lm = formsRepo.GetLookupMastersByLookupCode(iv.identifier);
                    if (lm != null)
                    {
                        List <def_LookupDetail> ld = formsRepo.GetLookupDetailsByLookupMasterEnterprise(lm.lookupMasterId, SessionHelper.LoginStatus.EnterpriseID);
                        if (ld.Count > 0)
                        {
                            response = ld[0].dataValue;
                        }
                    }
                }
            }

            try
            {
                return(Utilities.FormatDataByXmlDataType(response, type));
            }
            catch (Exception excptn)
            {
                Debug.WriteLine("GetFormattedResponse Message: " + excptn.Message);

                return(GetDefaultValue(type));  // to pass validation
            }
        }
コード例 #8
0
        public static void UpdateSisCScores(IFormsRepository formsRepo, int formResultId, int ageInYears)
        {
            def_Forms frm = formsRepo.GetFormByIdentifier("SIS-C");

            SharedScoring.UpdateSisScoresNoSave
            (
                formsRepo, frm, formResultId,
                getSisCSubscaleCatagories(),
                (int totalRawScore, double avgRawScore, SubscaleCatagory cat) => { return(GetSisCSubscaleStandardScore(avgRawScore, cat, ageInYears)); },
                (int totalRawScore, double avgRawScore, SubscaleCatagory cat) => { return(GetSisCSubscalePercentile(avgRawScore, cat, ageInYears)); }
            );

            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "scr_total_rating");
            double totalRating       = Convert.ToDouble(rv.rspValue);
            double meanRating        = Math.Round(totalRating / 7, 2); //usd only for SIS-C reports

            //save standard scores to database
            double compositeIndex      = GetSisCSupportNeedsIndex(meanRating, ageInYears);
            double compositePercentile = GetSisCSupportNeedsPercentile(meanRating, ageInYears);

            SharedScoring.UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_support_needs_index", compositeIndex);
            SharedScoring.UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_sni_percentile_rank", compositePercentile);

            formsRepo.Save();
        }
コード例 #9
0
        public string GetSisIdFromTrackingNumber(int formId, int trackingNumber)
        {
            List <int>        result     = new List <int>();
            def_ItemVariables ivTrackNum = formsRepo.GetItemVariableByIdentifier("sis_track_num");

            foreach (def_FormResults fr in formsRepo.GetFormResultsByFormId(formId).ToList())
            {
                def_ResponseVariables rvTrackNum = formsRepo.GetResponseVariablesByFormResultItemVarId(fr.formResultId, ivTrackNum.itemVariableId);
                if (rvTrackNum != null && rvTrackNum.rspInt.HasValue && rvTrackNum.rspInt.Value == trackingNumber)
                {
                    result.Add(fr.formResultId);
                }
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < result.Count(); i++)
            {
                sb.Append(result[i]);
                if (i + 1 < result.Count())
                {
                    sb.Append(", ");
                }
            }
            return(sb.ToString());
        }
コード例 #10
0
        protected string GetResponse(int formResultId, def_Items itm, def_ItemVariables iv)
        {
            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId);
            string response          = (rv == null) ? String.Empty : rv.rspValue;

            // special case for drop-downs/radiolists with options in meta-data
            if ((itm != null) && (iv.baseTypeId == 8) && !String.IsNullOrWhiteSpace(itm.prompt) && itm.prompt.Contains(";"))
            {
                try {
                    return(itm.prompt.Split(';')[Convert.ToInt16(response) - 1]);
                }
                catch (Exception e) {
                    Debug.WriteLine(" *** FormResultPdfReport.cs failed to retrieve selected option for ItemVariable "
                                    + iv.itemVariableId + ", response string \"" + response + "\"");
                }
            }

            //special case for YES/NO items
            else if ((response != null) && (iv.baseTypeId == 1))
            {
                if (response.Equals("1"))
                {
                    return("Yes");
                }

                if (response.Equals("0"))
                {
                    return("No");
                }
            }

            return(response);
        }
コード例 #11
0
        protected void buildTableWithItems(PdfOutput output, def_Parts part, int nColumns, string[] headers, params string[] identifiers)
        {
            int nRows = identifiers.Length / nColumns;

            string[][] vals = new string[nRows][];
            for (int row = 0; row < nRows; row++)
            {
                vals[row] = new string[nColumns];
                for (int col = 0; col < nColumns; col++)
                {
                    string    ident = identifiers[row * nColumns + col];
                    def_Items itm   = formsRepo.GetItemByIdentifier(/*formResults,*/ ident);                  //formsRepo.GetAllItems().First(t => t.identifier.Equals(ident));//getItemByIdentifier(part,ident);
                    if (itm == null)
                    {
                        throw new Exception("could not find item with identifer " + ident);
                    }
                    formsRepo.GetItemVariables(itm);
                    def_ItemVariables iv = itm.def_ItemVariables.FirstOrDefault();
                    if (iv == null)
                    {
                        throw new Exception("could not find any itemVariables for item with identifer " + ident);
                    }
                    def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, iv.itemVariableId);                    //iv.def_ResponseVariables.FirstOrDefault();
                    vals[row][col] = ((rv == null) ? "" : rv.rspValue);
                }
            }
            output.appendSimpleTable(headers, vals);
        }
コード例 #12
0
        private string getResponseStringOrEmpty(int formResultId, string ivIdent)
        {
            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, ivIdent);

            if (rv == null || String.IsNullOrWhiteSpace(rv.rspValue))
            {
                return("");
            }
            return(rv.rspValue.Trim());
        }
コード例 #13
0
        private void UpdateAssigned(int formResultId)
        {
            string enWorkerName      = string.Empty;
            string enWorkerSiteValue = string.Empty;
            string enWorkerSite      = string.Empty;

            def_ResponseVariables enWorkerVariable     = null;
            def_ResponseVariables enWorkerSitevariable = null;

            def_FormResults formResult = formsRepo.GetFormResultById(formResultId);
            int             enWorkerId = 0;

            try
            {
                enWorkerVariable = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "C1_InsuranceAssistEnrollPerson");

                if (enWorkerVariable != null)
                {
                    enWorkerName = enWorkerVariable.rspValue;
                }

                enWorkerSitevariable = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "C1_InsuranceAssistEnrollSite");

                if (enWorkerSitevariable != null)
                {
                    enWorkerSite = enWorkerSitevariable.rspValue;
                }

                if (!String.IsNullOrEmpty(enWorkerSite) && !String.IsNullOrEmpty(enWorkerName))
                {
                    enWorkerId = CheckAvailabilityAndGetPersonID(enWorkerSite, enWorkerName);

                    if (enWorkerId > 0)
                    {
                        if (enWorkerId != formResult.assigned)
                        {
                            formResult.assigned    = enWorkerId;
                            formResult.dateUpdated = DateTime.Now;
                            formsRepo.Save();
                        }
                    }
                }

                if (String.IsNullOrEmpty(enWorkerName))
                {
                    formResult.assigned    = null;
                    formResult.dateUpdated = DateTime.Now;
                    formsRepo.Save();
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #14
0
        private static string GetVersion(IFormsRepository formsRepo, def_FormResults oldFormResult)
        {
            def_ResponseVariables relatedFormResultRV = formsRepo.GetResponseVariablesByFormResultIdentifier(oldFormResult.formResultId, Updates.VERSION);

            if (relatedFormResultRV == null)
            {
                return("0");
            }
            else
            {
                return(relatedFormResultRV.rspValue);
            }
        }
コード例 #15
0
        protected string GetSingleResponse(def_Items itm)
        {
            def_ItemResults ir = formsRepo.GetItemResultByFormResItem(formResultId, itm.itemId);

            if (ir == null)
            {
                return(String.Empty);
            }

            formsRepo.GetItemResultsResponseVariables(ir);
            def_ResponseVariables rv = ir.def_ResponseVariables.FirstOrDefault();

            return((rv == null) ? String.Empty : rv.rspValue);
        }
コード例 #16
0
        private string GetStringResponse(int formResultId, string ivIdentifier)
        {
            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, ivIdentifier);

            if (rv == null)
            {
                return(String.Empty);
            }
            if (String.IsNullOrWhiteSpace(rv.rspValue))
            {
                return(String.Empty);
            }
            return(rv.rspValue);
        }
コード例 #17
0
        public static void updateSection1ScoresNoSave(
            IFormsRepository formsRepo,
            def_Forms frm,
            int formResultId)
        {
            def_FormResults fr    = formsRepo.GetFormResultById(formResultId);
            int             entId = fr.EnterpriseID.HasValue ? fr.EnterpriseID.Value : 0;

            string sectionIdentifierPrefix = frm.identifier; //"SIS-A" or "SIS-C"

            foreach (string shortSectionName in new string[] { "1A", "1B" })
            {
                string       sectionIdentifier = sectionIdentifierPrefix + " " + shortSectionName; // e.g. "SIS-A 1A"
                def_Sections sct = formsRepo.GetSectionByIdentifier(sectionIdentifier);
                if (sct == null)
                {
                    throw new Exception("Could not find section with identifier \"" + sectionIdentifier + "\"");
                }

                int rawTotal = 0;

                foreach (def_SectionItems si in formsRepo.GetSectionItemsBySectionIdEnt(sct.sectionId, entId))
                {
                    def_ItemVariables rawScoreIv = formsRepo.GetItemVariablesByItemId(si.itemId)
                                                   .Where(iv => iv.identifier.EndsWith("Support")).SingleOrDefault(); //e.g. "Q1A1_ExMedSupport"

                    if (rawScoreIv != null)
                    {
                        def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultItemVarId(formResultId, rawScoreIv.itemVariableId);
                        if (rv != null && !String.IsNullOrWhiteSpace(rv.rspValue))
                        {
                            int rawScore;
                            if (Int32.TryParse(rv.rspValue, out rawScore))
                            {
                                rawTotal += rawScore;
                            }
                            else
                            {
                                Debug.WriteLine("* * * Skipping item on updating section 1 scores: " +
                                                "Could not parse integer from response value \"{0}\" for itemVariable \"{1}\". (formResultID {2})",
                                                rv.rspValue, rawScoreIv.identifier, formResultId);
                            }
                        }
                    }
                }

                UpdateScoreResponseNoSave(formsRepo, formResultId, "scr_" + shortSectionName + "_raw_total", rawTotal);
            }
        }
コード例 #18
0
        private void UpdateInterviewer(int formResultId)
        {
            string enWorkerName = string.Empty;
            string enWorkerSite = string.Empty;

            def_ResponseVariables enWorkerVariable     = null;
            def_ResponseVariables enWorkerSitevariable = null;
            def_FormResults       formResult           = formsRepo.GetFormResultById(formResultId);
            int enWorkerId = 0;


            enWorkerVariable = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "C1_FormSubmitEnrollmentWorkerName");

            if (enWorkerVariable != null)
            {
                enWorkerName = enWorkerVariable.rspValue;
            }

            enWorkerSitevariable = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, "C1_FormSubmitEnrollmentSiteName");

            if (enWorkerSitevariable != null)
            {
                enWorkerSite = enWorkerSitevariable.rspValue;
            }

            if (!String.IsNullOrEmpty(enWorkerSite) && !String.IsNullOrEmpty(enWorkerName))
            {
                enWorkerId = CheckAvailabilityAndGetPersonID(enWorkerSite, enWorkerName);

                if (enWorkerId > 0)
                {
                    if (enWorkerId != formResult.interviewer)
                    {
                        formResult.interviewer = enWorkerId;
                        formResult.dateUpdated = DateTime.Now;
                        formsRepo.Save();
                    }
                }
            }

            if (String.IsNullOrEmpty(enWorkerName))
            {
                formResult.interviewer = null;
                formResult.dateUpdated = DateTime.Now;
                formsRepo.Save();
            }
        }
コード例 #19
0
        public void CreateEligibilityField(string identifier)
        {
            //  Get the FormResult to get the subject of the current Application
            def_FormResults fr = formsRepo.GetFormResultById(SessionHelper.SessionForm.formResultId);

            // Get the Eligibility Form for the subject
            IEnumerable <def_FormResults> frElgList = formsRepo.GetFormResultsByFormSubject(18, fr.subject);
            var frmRes = frElgList.First <def_FormResults>();
            Dictionary <string, string> DataToPopulate = new Dictionary <string, string>();

            DataToPopulate.Add(identifier, string.Empty);

            foreach (String s in DataToPopulate.Keys)
            {
                def_Items       item = formsRepo.GetItemByIdentifier(s + "_item");
                def_ItemResults ir   = new def_ItemResults()
                {
                    itemId        = item.itemId,
                    sessionStatus = 0,
                    dateUpdated   = DateTime.Now
                };

                var itemResult = formsRepo.GetItemResultByFormResItem(frmRes.formResultId, item.itemId);
                if (itemResult == null)
                {
                    frmRes.def_ItemResults.Add(ir);
                }
                else
                {
                    ir = itemResult;
                }

                foreach (var iv in formsRepo.GetItemVariablesByItemId(item.itemId))
                {
                    // Note for General forms like ADAP there should only be 1 ItemVariable per Item
                    def_ResponseVariables rv = new def_ResponseVariables();
                    rv.itemVariableId = iv.itemVariableId;
                    // rv.rspDate = DateTime.Now;    // RRB 11/11/15 The date, fp, and int fields are for the native data conversion.
                    rv.rspValue = DataToPopulate[s];

                    formsRepo.ConvertValueToNativeType(iv, rv);
                    ir.def_ResponseVariables.Add(rv);
                }
            }

            formsRepo.Save();
        }
コード例 #20
0
        public static void UpdateScoreResponseNoSave(IFormsRepository formsRepo, int formResultId, string itemVariableIdent, double response)
        {
            //if response exists already...
            def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, itemVariableIdent);

            if (rv != null)
            {
                rv.rspValue = response.ToString();
            }

            //if not...
            def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(itemVariableIdent);

            if (iv == null)
            {
                throw new Exception("could not find itemVariable with identifier \"" + itemVariableIdent + "\"");
            }
            def_ItemResults ir = formsRepo.GetItemResultByFormResItem(formResultId, iv.itemId);

            if (ir == null)
            {
                ir = new def_ItemResults()
                {
                    itemId        = iv.itemId,
                    formResultId  = formResultId,
                    dateUpdated   = DateTime.Now,
                    sessionStatus = 0
                };
                formsRepo.AddItemResult(ir);
            }
            rv = ir.def_ResponseVariables.FirstOrDefault(trv => trv.itemVariableId == iv.itemVariableId);
            if (rv == null)
            {
                rv = new def_ResponseVariables()
                {
                    itemResultId   = ir.itemResultId,
                    itemVariableId = iv.itemVariableId,
                    rspValue       = response.ToString()
                };
                formsRepo.AddResponseVariable(rv);
            }
            else
            {
                rv.rspValue = response.ToString();
            }
        }
コード例 #21
0
 private static void AssertRVHasDate(def_ResponseVariables dateRv)
 {
     if (!dateRv.rspDate.HasValue)
     {
         try
         {
             dateRv.rspDate = Convert.ToDateTime(dateRv.rspValue, new System.Globalization.CultureInfo("en-US"));
             if (dateRv == null || !dateRv.rspDate.HasValue)
             {
                 throw new Exception(); //this is intentionally thrown and caught below, so a null result is handled the same way as an exception during conversion
             }
         }
         catch (Exception e)
         {
             throw new Exception("could not find or compute interview-date rspDate in response variable " + dateRv.responseVariableId);
         }
     }
 }
コード例 #22
0
        internal static def_FormResults GetLatestPreQACopy(IFormsRepository formsRepo, int formResultId)
        {
            def_ResponseVariables responseVariable = formsRepo.GetResponseVariablesByFormResultIdentifier(formResultId, RELATED_FORM_RESULT_ID);

            if (responseVariable != null)
            {
                int preQAformResultId = Convert.ToInt32(responseVariable.rspValue);

                def_FormResults preQAformResult = formsRepo.GetFormResultById(preQAformResultId);

                if (preQAformResult.reviewStatus == ReviewStatus.PRE_QA)
                {
                    return(preQAformResult);
                }
            }

            return(null);
        }
コード例 #23
0
        private bool isNullEmptyOrBlank(def_ResponseVariables rv)
        {
            if (rv == null)
            {
                return(true);
            }

            if (rv.rspValue == null)
            {
                return(true);
            }

            if (rv.rspValue.Length == 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #24
0
        private void SaveAssessmentFromDataTable(int formResultId, DataTable dt)
        {
            int prevItemId = -1;

            def_ItemResults itemResult = null;

            foreach (DataRow row in dt.Rows)
            {
                int    currItemId     = Int32.Parse(row["itemId"].ToString());
                int    itemVariableId = Int32.Parse(row["itemVariableId"].ToString());
                string rspValue       = row["rspValue"].ToString();

                if (currItemId != prevItemId)
                {
                    itemResult               = new def_ItemResults();
                    itemResult.dateUpdated   = DateTime.Now;
                    itemResult.itemId        = currItemId;
                    itemResult.sessionStatus = 0;
                    itemResult.formResultId  = formResultId;

                    formsRepo.AddItemResultNoSave(itemResult);
                }

                if (itemResult != null)
                {
                    def_ResponseVariables responseVariable = new def_ResponseVariables();
                    responseVariable.itemVariableId = itemVariableId;
                    responseVariable.rspValue       = rspValue;

                    def_ItemVariables itemVariable = formsRepo.GetItemVariableById(itemVariableId);

                    if (itemVariable != null)
                    {
                        formsRepo.ConvertValueToNativeType(itemVariable, responseVariable);

                        itemResult.def_ResponseVariables.Add(responseVariable);
                    }
                }
                prevItemId = currItemId;
            }

            formsRepo.Save();
        }
コード例 #25
0
        private void InsertNewResponse(def_FormResults fr, string ivIdentifier, string response)
        {
            def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(ivIdentifier);

            def_ResponseVariables rv = new def_ResponseVariables()
            {
                itemVariableId = iv.itemVariableId,
                rspValue       = response
            };

            def_ItemResults ir = new def_ItemResults()
            {
                itemId                = iv.itemId,
                sessionStatus         = 0,
                dateUpdated           = DateTime.Now,
                def_ResponseVariables = { rv }
            };

            fr.def_ItemResults.Add(ir);
        }
コード例 #26
0
        public def_ResponseVariables SaveResponseVariable(def_ItemResults ir, def_ItemVariables iv, string val)
        {
            // Add / Update the associated Response Variable in the database
            def_ResponseVariables rv = ir.def_ResponseVariables.Where(rrv => rrv.itemVariableId == iv.itemVariableId).FirstOrDefault();

            if (rv == null)
            {
                rv = new def_ResponseVariables()
                {
                    //itemResultId = ir.itemResultId,
                    itemVariableId = iv.itemVariableId,
                    rspValue       = val
                };

                try
                {
                    formsRepo.ConvertValueToNativeType(iv, rv);
                }
                catch (Exception xcptn)
                {
                    Debug.WriteLine(iv.identifier + " Exception: " + xcptn.Message);
                }

                ir.def_ResponseVariables.Add(rv);
            }
            else
            {
                rv.rspValue = val;
                try
                {
                    formsRepo.ConvertValueToNativeType(iv, rv);
                }
                catch (Exception xcptn)
                {
                    Debug.WriteLine(iv.identifier + " Exception: " + xcptn.Message);
                }
            }

            return(rv);
        }
コード例 #27
0
        //Public instance methods

        /// <summary>
        /// Used by the create application method to populate the application with data from UAS.
        /// Creates a new forms result object for the application.
        /// </summary>
        /// <param name="subjectUserId">Numerical Identifier of the user creating a new application.</param>
        /// <param name="formId">Numerical Identifier of the form to use for the new application</param>
        /// <param name="DataToPopulate">Dictionary object listing the items to be pulled from UAS.</param>
        /// <returns>Returns the forms result object created by this method.</returns>
        public def_FormResults CreateFormResultPopulatedFromUAS(int entId, int groupId, int subjectUserId, int formId, Dictionary <string, string> DataToPopulate)
        {
            Debug.WriteLine("*** populateFromUAS ***");
            def_FormResults frmRes = Assmnts.Models.FormResults.CreateNewFormResultModel(formId.ToString());

            frmRes.EnterpriseID = entId;
            frmRes.GroupID      = groupId;
            frmRes.subject      = subjectUserId;
            frmRes.interviewer  = subjectUserId;
            frmRes.assigned     = subjectUserId;
            frmRes.reviewStatus = 0;

            foreach (String s in DataToPopulate.Keys)
            {
                def_Items       item = formsRepo.GetItemByIdentifier(s);
                def_ItemResults ir   = new def_ItemResults()
                {
                    itemId        = item.itemId,
                    sessionStatus = 0,
                    dateUpdated   = DateTime.Now
                };

                frmRes.def_ItemResults.Add(ir);

                foreach (var iv in formsRepo.GetItemVariablesByItemId(item.itemId))
                {
                    // Note for General forms like ADAP there should only be 1 ItemVariable per Item
                    def_ResponseVariables rv = new def_ResponseVariables();
                    rv.itemVariableId = iv.itemVariableId;
                    // rv.rspDate = DateTime.Now;    // RRB 11/11/15 The date, fp, and int fields are for the native data conversion.
                    rv.rspValue = DataToPopulate[s];

                    formsRepo.ConvertValueToNativeType(iv, rv);
                    ir.def_ResponseVariables.Add(rv);
                }
            }

            Debug.WriteLine("PopulateFromUAS FormResults populated.");
            return(frmRes);
        }
コード例 #28
0
        /// <summary>
        /// called by RamsellImport
        /// </summary>
        /// <param name="specialCaseValuesByTagname"></param>
        /// <param name="toFormResultId"></param>
        /// <param name="formsRepo"></param>
        public static void ImportSpecialCasesNoSave(Dictionary <string, string> specialCaseValuesByTagname, int toFormResultId, IFormsRepository formsRepo)
        {
            UserData ud = new UserData(formsRepo);

            foreach (string ramsellTagName in specialCaseValuesByTagname.Keys)
            {
                Transformation matchingTrans = GetTransformationforRamsellTagName(ramsellTagName);
                if (matchingTrans == null)
                {
                    continue;
                }

                //prepare in/out vars for the transformation
                Dictionary <string, string> inRamsellValsByTag = new Dictionary <string, string>();
                foreach (string tag in matchingTrans.GetRamsellTagNames())
                {
                    inRamsellValsByTag.Add(tag, specialCaseValuesByTagname.ContainsKey(tag) ? specialCaseValuesByTagname[tag] : null);
                }

                //output is pre-populated with existing responses - though they are typically ignored by transformations
                Dictionary <string, string> outRspValsByItmVar = new Dictionary <string, string>();
                foreach (string ivIdentifier in matchingTrans.GetItemVariableIdentifiers())
                {
                    def_ResponseVariables existingRv = formsRepo.GetResponseVariablesByFormResultIdentifier(toFormResultId, ivIdentifier);
                    outRspValsByItmVar.Add(ivIdentifier, existingRv == null ? null : existingRv.rspValue);
                }

                //run transformation
                matchingTrans.GetImportValuesByItemVarIdentifier(inRamsellValsByTag, outRspValsByItmVar);

                //insert output values into DB
                foreach (string ivIdent in outRspValsByItmVar.Keys)
                {
                    def_ItemVariables iv = formsRepo.GetItemVariableByIdentifier(ivIdent);
                    def_ItemResults   ir = ud.SaveItemResult(toFormResultId, iv.itemId);
                    ud.SaveResponseVariable(ir, iv, outRspValsByItmVar[ivIdent]);
                }
            }
        }
コード例 #29
0
        public ActionResult CreateAdapApplication()
        {
            def_Forms frm = formsRepo.GetFormByIdentifier("ADAP");
            //string userId = Request["userId"];
            int userId = 0;

            try
            {
                userId = Convert.ToInt32(Request["userId"]);
            }
            catch (Exception excptn)
            {
                Debug.WriteLine("Adap Controller CreateAdapApplication exception:" + excptn.Message);
            }

            int?            intSO   = formsRepo.GetStatusDetailByMasterIdentifier(1, "CANCELLED").sortOrder;
            def_FormResults prevRes = formsRepo.GetEntities <def_FormResults>(x => x.formId == frm.formId &&
                                                                              x.subject == userId &&
                                                                              x.formStatus != intSO)
                                      .OrderByDescending(x => x.dateUpdated)
                                      .FirstOrDefault();

            //def_FormResults prevRes = frm.def_FormResults.Where(f => f.subject == userId && intSO != null && f.formStatus != intSO).OrderByDescending(f => f.dateUpdated).FirstOrDefault();


            if ((prevRes == null) || (prevRes.formStatus == formsRepo.GetStatusDetailByMasterIdentifier(1, "APPROVED").sortOrder))
            {
                AuthenticationClient webclient = new AuthenticationClient();
                UserDisplay          ud        = webclient.GetUserDisplay(userId);

                Dictionary <string, string> ItemsToPopulateFromUAS = new Dictionary <string, string>();
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_FirstName_item", String.IsNullOrEmpty(ud.FirstName) ? String.Empty : ud.FirstName);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_LastName_item", String.IsNullOrEmpty(ud.LastName) ? String.Empty : ud.LastName);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D1_MiddleIntl_item", String.IsNullOrEmpty(ud.MiddleName) ? String.Empty : ud.MiddleName.Substring(0, 1));
                ItemsToPopulateFromUAS.Add(
                    "ADAP_D2_DOB_item", (ud.DOB == null) ? String.Empty : Convert.ToDateTime(ud.DOB).ToString("MM/dd/yyyy"));
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].Address1 : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ((ud.Addresses[0].MayContactAddress) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_City_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].City : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_State_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].State : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C1_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 0) ? ud.Addresses[0].ZIP : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_Address_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].Address1 : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_MayContactYN_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ((ud.Addresses[1].MayContactAddress) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_City_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].City : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_State_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].State : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C2_Zip_item", (ud.Addresses != null && ud.Addresses.Count() > 1) ? ud.Addresses[1].ZIP : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone1_Num_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ud.Phones[0].Phone : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone1_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 0) ? ((ud.Phones[0].MayContactPhone) ? "1" : "0") : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone2_Num_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ud.Phones[1].Phone : String.Empty);
                ItemsToPopulateFromUAS.Add(
                    "ADAP_C3_Phone2_MayMsgYN_item", (ud.Phones != null && ud.Phones.Count() > 1) ? ((ud.Phones[1].MayContactPhone) ? "1" : "0") : String.Empty);

                // * * * OT 1-20-16 updated this list based on Docs/ADAP/ADAP_item_list.xslx (revision 80734)
                string[] ItemIdentifiersToPopulateFromPrevApplication = new string[]
                {
                    #region long list of item identifiers
                    "ADAP_D1_LastName_item",
                    "ADAP_D1_FirstName_item",
                    "ADAP_D1_MiddleIntl_item",
                    "ADAP_D1_AltName_item",
                    "ADAP_D2_DOB_item",
                    "ADAP_D3_White_item",
                    "ADAP_D3_Black_item",
                    "ADAP_D3_Asian_item",
                    "ADAP_D3_Native_item",
                    "ADAP_D3_Indian_item",
                    "ADAP_D4_EthnicDrop_item",
                    "ADAP_D4_Mexican_item",
                    "ADAP_D4_Puerto_item",
                    "ADAP_D4_Cuban_item",
                    "ADAP_D4_Other_item",
                    "ADAP_D5_Indian_item",
                    "ADAP_D5_Filipino_item",
                    "ADAP_D5_Korean_item",
                    "ADAP_D5_Other_item",
                    "ADAP_D5_Chinese_item",
                    "ADAP_D5_Japanese_item",
                    "ADAP_D5_Vietnamese_item",
                    "ADAP_D5_NA_item",
                    "ADAP_D6_Native_item",
                    "ADAP_D6_Guam_item",
                    "ADAP_D6_Samoan_item",
                    "ADAP_D6_Other_item",
                    "ADAP_D6_NA_item",
                    "ADAP_D7_LangDrop_item",
                    "ADAP_D7_LangOther_item",
                    "ADAP_D8_CurrGenderDrop_item",
                    "ADAP_D8_BirthGenderDrop_item",
                    "ADAP_D9_Ramsell_item",
                    "ADAP_D10_SSN_item",
                    "ADAP_C1_Address_item",
                    "ADAP_C1_City_item",
                    "ADAP_C1_State_item",
                    "ADAP_C1_Zip_item",
                    "ADAP_C1_County_item",
                    "ADAP_C1_MayContactYN_item",
                    "ADAP_C2_SameAsMailing_item",
                    "ADAP_C2_Address_item",
                    "ADAP_C2_City_item",
                    "ADAP_C2_State_item",
                    "ADAP_C2_Zip_item",
                    "ADAP_C2_County_item",
                    "ADAP_C2_MayContactYN_item",
                    "ADAP_C3_Phone1_Num_item",
                    "ADAP_C3_Phone1_Type_item",
                    "ADAP_C3_Phone1_MayMsgYN_item",
                    "ADAP_C3_Phone2_Num_item",
                    "ADAP_C3_Phone2_Type_item",
                    "ADAP_C3_Phone2_MayMsgYN_item",
                    "ADAP_C4_MayCallYN_item",
                    "ADAP_C4_Name_item",
                    "ADAP_C4_Phone_item",
                    "ADAP_C4_KnowHivYN_item",
                    "ADAP_C5_HasCaseMngrYN_item",
                    "ADAP_C5_Mngr1_Name_item",
                    "ADAP_C5_Mngr1_Clinic_item",
                    "ADAP_C5_Mngr2_Name_item",
                    "ADAP_C5_Mngr2_Clinic_item",
                    "ADAP_C5_CanReferYN_item",
                    "ADAP_M1_Month_item",
                    "ADAP_M1_Year_item",
                    "ADAP_M1_DiagnosisLoc_item",
                    "ADAP_M2_ToldAIDS_item",
                    "ADAP_M3_ToldHepC_item",
                    "ADAP_M4_Clinic_item",
                    "ADAP_I1_Med_Yes_item",
                    "ADAP_I1_Med_Denied_item",
                    "ADAP_I1_Med_No_item",
                    "ADAP_I1_Med_Waiting_item",
                    "ADAP_I1_Med_DontKnow_item",
                    "ADAP_I1_DeniedReason_item",
                    "ADAP_I1_NotAppliedReason_item",
                    "ADAP_I2_AffCareOpt_item",
                    "ADAP_I2_AffCareOther_item",
                    "ADAP_I3_MedicareYN_item",
                    "ADAP_I3_MedNumber_item",
                    "ADAP_I3_PartAYN_item",
                    "ADAP_I3_PartBYN_item",
                    "ADAP_I3_PartADate_item",
                    "ADAP_I3_PartBDate_item",
                    "ADAP_H1_StatusDrop_item",
                    "ADAP_H2_RelnDrop_item",
                    "ADAP_H2_RelnOther_item",
                    "ADAP_H3_FileTaxYN_item",
                    "ADAP_H3_TaxStatusOpt_item",
                    "ADAP_H3_TaxDependants_item",
                    "ADAP_H3_TaxNotFileOpt_item",
                    "ADAP_H3_TaxNotFileOther_item",
                    "ADAP_H3_Relatives_item",
                    "ADAP_H4_ChildrenIn_item",
                    "ADAP_H4_ChildrenOut_item",
                    "ADAP_F1_EmployOpt_item",
                    "ADAP_F1_EmployOther_item",
                    "ADAP_F1_EmployerInsOpt_item",
                    "ADAP_F1_EmployNotEnrolled_item",
                    "ADAP_F2_EmployLast90YN_item",
                    "ADAP_F3_A_Recipient_item",
                    "ADAP_F3_A_IncomeTypeDrop_item",
                    "ADAP_F3_A_Employer_item",
                    "ADAP_F3_A_EmployStart_item",
                    "ADAP_F3_A_TempYN_item",
                    "ADAP_F3_A_IncomeTypeOther_item",
                    "ADAP_F3_A_IncomeAmt_item",
                    "ADAP_F3_A_EmployerForm_item",
                    "ADAP_F3_B_Recipient_item",
                    "ADAP_F3_B_IncomeTypeDrop_item",
                    "ADAP_F3_B_Employer_item",
                    "ADAP_F3_B_EmployStart_item",
                    "ADAP_F3_B_TempYN_item",
                    "ADAP_F3_B_IncomeTypeOther_item",
                    "ADAP_F3_B_IncomeAmt_item",
                    "ADAP_F3_B_EmployerForm_item",
                    "ADAP_F3_C_Recipient_item",
                    "ADAP_F3_C_IncomeTypeDrop_item",
                    "ADAP_F3_C_Employer_item",
                    "ADAP_F3_C_EmployStart_item",
                    "ADAP_F3_C_TempYN_item",
                    "ADAP_F3_C_IncomeTypeOther_item",
                    "ADAP_F3_C_IncomeAmt_item",
                    "ADAP_F3_C_EmployerForm_item",
                    "ADAP_F3_D_Recipient_item",
                    "ADAP_F3_D_IncomeTypeDrop_item",
                    "ADAP_F3_D_Employer_item",
                    "ADAP_F3_D_EmployStart_item",
                    "ADAP_F3_D_TempYN_item",
                    "ADAP_F3_D_IncomeTypeOther_item",
                    "ADAP_F3_D_IncomeAmt_item",
                    "ADAP_F3_D_EmployerForm_item",
                    "ADAP_cert_NoSharing_item",
                    "ADAP_cert_Reminders_item"
                    #endregion
                };

                Applications    appl   = new Applications(formsRepo);
                def_FormResults frmRes = appl.CreateFormResultPopulatedFromUAS(SessionHelper.LoginStatus.EnterpriseID, SessionHelper.LoginStatus.GroupID, userId, frm.formId, ItemsToPopulateFromUAS);
                appl.PopulateItemsFromPrevApplication(frmRes, ItemIdentifiersToPopulateFromPrevApplication);

                frmRes.statusChangeDate = DateTime.Now;

                // Save the FormResult, ItemResults, and ResponseVariables
                int newFormResultId = 0;
                try
                {
                    newFormResultId = formsRepo.AddFormResult(frmRes);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("AddFormResult exception:" + ex.Message);
                }

                Debug.WriteLine("AddFormResult newFormResultId:" + newFormResultId.ToString());

                // query the ramsell system and update the formResult responses based on Ramsell response
                def_ResponseVariables rvMemberId = formsRepo.GetResponseVariablesByFormResultIdentifier(newFormResultId, "ADAP_D9_Ramsell");
                if (rvMemberId != null && !String.IsNullOrWhiteSpace(rvMemberId.rspValue))
                {
                    string memberId = rvMemberId.rspValue;
                    string usrId    = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("USR");
                    string password = UAS.Business.UAS_Business_Functions.GetEntAppConfigAdap("PWD");
                    Debug.WriteLine("Ramsell UseriD / Password: "******" / " + password);

                    string token = Ramsell.GetOauthToken(usrId, password);
                    new RamsellImport(formsRepo, frmRes.formResultId).ImportApplication(token, memberId);
                }
                //AJBoggs.Adap.Services.Api.Ramsell.PopulateItemsFromRamsellImport(formsRepo, frmRes);

                if (SessionHelper.SessionForm == null)
                {
                    SessionHelper.SessionForm = new SessionForm();
                }

                SessionForm sf = SessionHelper.SessionForm;
                sf.formId         = frm.formId;
                sf.formIdentifier = frm.identifier;
                sf.sectionId      = formsRepo.GetSectionByIdentifier("ADAP_demographic").sectionId;
                sf.partId         = formsRepo.GetPartByFormAndIdentifier(frm, "ADAP").partId;

                // *** RRB - should be deprecated - use SessionForm
                // *** BR - line 359 of the ResultsController calls this session variable, so it must be set to prevent an exception.
                //  Other parts of the application may still use that variable, so changing it in the ResultsController may break something else.
                Session["part"] = sf.partId;
                // Should have the partId also - may not be required.

                sf.formResultId = newFormResultId;

                return(RedirectToAction("Template", "Results", new { sectionId = sf.sectionId.ToString() }));
            }
            else
            {
                return(RedirectToAction("AdapPortal", "COADAP", new { userId = userId, error = "Not Approved" }));
            }
        }
コード例 #30
0
        public string GetHtmlForColumn(int columnIndex)
        {
            switch (columnIndex)
            {
            case 0:     //ramsellId / MemberId
                def_ResponseVariables rv = formsRepo.GetResponseVariablesByFormResultIdentifier(vfru.formResultId, "C1_MemberIdentifier") ?? formsRepo.GetResponseVariablesByFormResultIdentifier(vfru.formResultId, "ADAP_D9_Ramsell");
                string ramsellId         = (rv == null) ? null : rv.rspValue;
                string ramsellIdDisplayText;
                if ((ramsellId == null) || String.IsNullOrWhiteSpace(ramsellId))
                {
                    if (vfru.EnterpriseID == 8)
                    {
                        ramsellIdDisplayText = @Resources.AdapPortal.NoId;
                    }
                    else
                    {
                        ramsellIdDisplayText = @Resources.AdapPortal.NoRamsellId;
                    }
                }
                else
                {
                    ramsellIdDisplayText = ramsellId;
                }
                if (UAS_Business_Functions.hasPermission(PermissionConstants.EDIT, PermissionConstants.ASSMNTS))
                {
                    return(isHistorical ? ramsellIdDisplayText : "<a href=\"/ADAP/ToTemplate?formResultId=" + Convert.ToString(vfru.formResultId) + "&Update=Y\">" + ramsellIdDisplayText + "</a>");
                }
                else
                {
                    return(ramsellIdDisplayText);
                }

            case 1:     //FirstName
                return(vfru.FirstName);

            case 2:     //Last name
                return(vfru.LastName);

            case 3:     //DOB
                return(vfru.DOB.HasValue ? vfru.DOB.Value.ToString("MM/dd/yyyy") : String.Empty);

            case 4:     //Status
                def_StatusMaster statusMaster = formsRepo.GetStatusMasterByFormId(vfru.formId);
                int statusMasterId            = statusMaster == null ? 1 : statusMaster.statusMasterId;

                string statusDisplayText = formsRepo.GetStatusTextByDetailSortOrder(statusMasterId, vfru.formStatus).displayText;
                return(isHistorical ? statusDisplayText : "<a href=\"/ADAP/UpdateStatus?formResultId=" + Convert.ToString(vfru.formResultId) + "\">" + statusDisplayText + "</a>");

            case 5:     //Status changed
                return(statusChangeDate == null ? String.Empty : statusChangeDate.ToString());

            case 6:     //Next Recert
                DateTime?nextRecertDate = GetRecert(formsRepo, vfru, allVfrus);
                return(nextRecertDate.HasValue ? nextRecertDate.Value.ToString("MMMM yyyy") : "None Pending");

            case 7:     //type
                var form = formsRepo.GetFormByIdentifier(formIdentifier).title;
                return("<div class=\"form-type-text\" data-formIdentifier=\"" + formIdentifier + "\">" + form + "</div>");

            case 8:     //group
                if (vfru.EnterpriseID == 8)
                {
                    string groupDesc = string.Empty;
                    var    context   = DataContext.getUasDbContext();
                    var    group     = (from g in context.uas_Group
                                        where g.GroupID == vfru.GroupID
                                        select g).FirstOrDefault();
                    groupDesc = group.GroupDescription;
                    return(isHistorical ? vfru.GroupName + " - " + groupDesc : "<a href=\"/ADAP/UpdateTeam?formId=" + Convert.ToString(vfru.formResultId) + "\">" + vfru.GroupName + " - " + groupDesc + "</a>");
                }
                else
                {
                    return(isHistorical ? vfru.GroupName : "<a href=\"/ADAP/UpdateTeam?formId=" + Convert.ToString(vfru.formResultId) + "\">" + vfru.GroupName + "</a>");
                }

            case 9:     //contact info
                return
                    ("<div class=\"row\">" +
                     "<div class=\"col-md-12 text-center\">" +
                     "<a href=\"#\" data-toggle=\"modal\" data-target=\"#contactsModal\" data-formresultid=\"" + Convert.ToString(vfru.formResultId) + "\">" +
                     "Contact" +
                     "</a>" +
                     "<span class=\"text-divider\">|</span>" +
                     "<a href=\"#\" data-toggle=\"modal\" data-target=\"#cmmtModal\" data-userid=\"" + vfru.subject.ToString() + "\" data-formresultid=\"" + Convert.ToString(vfru.formResultId) + "\">" +
                     "Comments" +
                     "</a>" +
                     "<span class=\"text-divider\">|</span>" +
                     "<a href=\"/ADAP/StatusHistory?formResultId=" + Convert.ToString(vfru.formResultId) + "\">" +
                     "History" +
                     "</a>" +
                     "</div>" +
                     "</div>");

            case 10:     //print button
                if (isHistorical)
                {
                    if (historicalSnapshot != null)
                    {
                        return("<a class=\"glyphicon glyphicon-print text-primary\" href=\"/Search/DownloadFile?fileId=" + historicalSnapshot.FileId + "&fileDownloadName=snapshot.pdf\"></a>");
                    }
                    else
                    {
                        return("N/A");
                    }
                }
                else
                {
                    return("<a class=\"glyphicon glyphicon-print text-primary\" href=\"../COADAP/BuildPDFReport?formResultId=" + Convert.ToString(vfru.formResultId) + "\"></a>");
                }

            case 11:     //subject (user id number for applicant)
                return(Convert.ToString(vfru.subject));

            case 12:     //upload and download attachments
                if (isHistorical)
                {
                    return(String.Empty);
                }
                else
                {
                    int frId = vfru.formResultId;
                    return("<div>"
                           + "<div id=\"attachment1" + frId + "\">"
                           + "<form class=\"uploadForm\" action=\"/Search/UploadFile\" method=\"post\" enctype=\"multipart/form-data\">"
                           + "<input type=\"hidden\" name=\"formResultId\" value=\"" + frId + "\" />"
                           + "<input type=\"file\" id=\"file" + frId + "\" name=\"file" + frId + "\">"
                           + "<a href=\"#\" onclick=\"$('#Upload" + frId + "').click()\">Upload</a>"
                           + "&nbsp;&nbsp;&nbsp;"
                           + "<a href=\"#\" class=\"viewFiles\" id=\"view" + frId + "\" onclick=\"downloadAttach(" + frId + ")\" hidden=\"hidden\">View Files</a>"
                           + "&nbsp;&nbsp;&nbsp;"
                           + "<input type=\"submit\" id=\"Upload" + frId + "\" value=\"Upload\" hidden=\"hidden\" />"
                           + "</form>"
                           + "</div>"
                           + "<div id=\"attachment2" + frId + "\" hidden=\"hidden\">"
                           + "<span id=\"dwnldDDL" + frId + "\" class=\"AttachDDL" + frId + "\" style=\"min-width:10px\"></span> "
                           + "<a href=\"#\" onclick=\"downloadFile(" + frId + ")\">Download</a>"
                           + "&nbsp;&nbsp;&nbsp;"
                           + "<a href=\"#\" onclick=\"deleteAttach(" + frId + ")\">Delete Files</a>"
                           + "&nbsp;&nbsp;&nbsp;"
                           + "<a href=\"#\" onclick=\"cancelAttach(" + frId + ")\">Cancel</a>"
                           + "</div>"
                           + "<div id=\"attachment3" + frId + "\" hidden=\"hidden\">"
                           + "<span id=\"dltDDL" + frId + "\" class=\"AttachDDL" + frId + "\"></span> "
                           + "<a href=\"#\" onclick=\"deleteFile(" + frId + ")\">Delete</a>"
                           + "&nbsp;&nbsp;&nbsp;"
                           + "<a href=\"#\" onclick=\"downloadAttach(" + frId + ")\">Cancel</a>"
                           + "</div>"
                           + "</div>");
                }

            default:
                throw new Exception("invalid column index: " + columnIndex);
            }
        }