/// <summary>
        /// Update Patient's Study Id and/or warn if already exits.
        /// </summary>
        /// <param name="e"></param>
        protected void UpdateStudyId(CaisisAjaxEventArgs e)
        {
            string newStudyId = e.ClientParam;

            if (PatientPage != null && !string.IsNullOrEmpty(newStudyId) && !string.IsNullOrEmpty(PatientPage.PatientProtocolId))
            {
                // ok to update when study id doesn't exits
                if (!ProtocolMgmtDa.StudyIdExists(newStudyId, int.Parse(PatientPage.BaseProtocolId)))
                {
                    int             ptProtocolId = int.Parse(PatientPage.PatientProtocolId);
                    PatientProtocol biz          = new PatientProtocol();
                    biz.Get(ptProtocolId);
                    biz[PatientProtocol.PtProtocolStudyId] = newStudyId;
                    biz.Save();

                    // CREATE STUDY ID IDENTIFIER
                    PatientProtocolController.CreateStudyIdIdentifier(biz);

                    // echo back value to client
                    e.ReturnValue = newStudyId;
                }
                // otherwise exists, and warn
                else
                {
                    // echo back to client study id exits
                    e.ReturnValue = "The StudyId entered already exits in the system.";
                }
            }
            else
            {
                // echo to client there were issues
                e.ReturnValue = "Please Enter a valid StudyId.";
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected void GetLatestItemStatuses(CaisisAjaxEventArgs e)
        {
            DataView navigation = GetFilteredNavigation();

            if (navigation.Count > 0)
            {
                var itemToStatus = from item in GetFilteredNavigation().ToTable().AsEnumerable()
                                   let itemId = EncryptPatientId(item[PatientItem.PatientItemId].ToString())
                                                let status = item[PatientItem.Status].ToString()
                                                             select "['" + PageUtil.EscapeSingleQuotes(itemId) + "','" + PageUtil.EscapeSingleQuotes(status) + "']";
                e.ReturnValue = "[" + string.Join(",", itemToStatus.ToArray()) + "]";
            }
            else
            {
                e.ReturnValue = "[]";
            }
        }
Example #3
0
        /// <summary>
        /// Method which is invoked by client callback and validates identifier value against db value
        /// </summary>
        /// <param name="e"></param>
        protected void HandleValidationCallback(CaisisAjaxEventArgs e)
        {
            PatientController pc = new PatientController();
            string            validateFieldValue = e.ClientParams["Identifier"];
            bool isNew = false;

            try
            {
                UserController uc = new UserController();

                // search by MRN
                if (IdentifierName == DEFAULT_IDENTIFIER)
                {
                    if (uc.CanSearchIdentifier("LastNameMRN"))
                    {
                        isNew = pc.IsNewMRN(validateFieldValue, int.Parse(Session[SessionKey.DatasetId].ToString()));
                    }
                }
                // search by identifier
                else
                {
                    if (uc.CanSearchIdentifier(IdentifierName))
                    {
                        IdentifierDa da = new IdentifierDa();
                        isNew = !da.DoesIdentifierExist(validateFieldValue, IdentifierName);
                    }
                }
            }
            catch (ClientException ex)
            {
                isNew = false;
            }
            // echo back a list of key value pairs to client
            foreach (string key in e.ClientParams.Keys)
            {
                e.ReturnParams.Add(key, e.ClientParams[key]);
            }
            // add if is new identifier value
            e.ReturnParams.Add("IsNew", isNew.ToString().ToLower());
            e.ReturnParams.Add("IdentifierName", IdentifierName);
        }