public void Log(int studyId,int patientId,string action)
 {
     if(Session[ParameterNames.Session.LoggedInUserId] != null)
     {
         LogObject log = new LogObject();
         log.Action.Value = action;
         log.ActionTime.Value = DateTime.Now;
         log.PatientId.Value = patientId;
         log.StudyId.Value = studyId;
         log.UserId.Value = (int)Session[ParameterNames.Session.LoggedInUserId];
         log.Save();
     }
 }
 protected void logoutLink_Click(object sender, EventArgs e)
 {
     if(Session[ParameterNames.Session.LoggedInUser] != null)
     {
         int loggedInUserId = (int)((UserObject)Session[ParameterNames.Session.LoggedInUser]).UserId.Value;
         LogObject log = new LogObject();
         log.UserId.Value = loggedInUserId;
         log.Action.Value = Constants.LogActions.Logout;
         log.ActionTime.Value = DateTime.Now;
         log.Save();
     }
     Session.Clear();
     Session.RemoveAll();
     Session.Abandon();
     PagesFactory.Transfer(PagesFactory.Pages.LoginPage);
 }
 protected void Log(int studyId)
 {
     StudyObject study = new StudyObject();
     study.StudyId.Value = studyId;
     study.Load();
     if (study.IsLoaded)
     {
         LogObject log = new LogObject();
         log.Action.Value = Constants.LogActions.ViewedExam;
         log.ActionTime.Value = DateTime.Now;
         log.PatientId.Value = study.PatientId.Value;
         log.StudyId.Value = studyId;
         log.UserId.Value = loggedInUserId;
         log.Save();
     }
 }
 public void ApproveStudy(int studyId, int findingId, int userId, string heading, string description, string impression)
 {
     StudyObject study = new StudyObject();
     study.StudyId.Value = studyId;
     study.Load(userId);
     if (study.IsLoaded)
     {
         UpdateStudy(studyId, findingId, userId, heading, description, impression, Constants.StudyStatusTypes.Verified, true);
         LogObject log = new LogObject();
         log.Action.Value = Constants.LogActions.VerifiedStudy;
         log.ActionTime.Value = DateTime.Now;
         log.PatientId.Value = study.PatientId.Value;
         log.StudyId.Value = study.StudyId.Value;
         log.UserId.Value = userId;
         log.Save();
     }
 }
    protected override void Page_Load_Extended(object sender, EventArgs e)
    {
        int studyId = int.Parse(Request[ParameterNames.Request.StudyId]);
        report = new ReportObject(studyId,true);
        if (report.Load())
        {
            if (IsPostBack == false)
            {
                faxBtn.OnClientClick = ClientClickForFaxBtn();
            }

            lblClientName.Text = report.ClientName;
            lblClientAddress.Text = report.ClientAddress;
            lblModality.Text = report.Modality;
            lblManualStatus.Text = report.ManualStatus;
            lblPatientName.Text = report.PatientName;
            lblDOB.Text = report.DateOfBirth;
            lblRefPhy.Text = report.ReferringPhysician;
            lblStudyDate.Text = report.StudyDate;

            lblTranscription.Text = report.Transcription;
            lblReportDateTime.Text = report.ReportDateTime;
            lblReportDate.Text = report.ReportDate;

            lblRadiologist.Text = report.Radiologist;
            lblStatus.Text = report.Status;
            lblHospitalName.Text = report.HospitalName;

            LogObject log = new LogObject();
            log.UserId.Value = loggedInUserId;
            log.StudyId.Value = studyId;
            log.PatientId.Value = report.PatientId;
            log.Action.Value = Constants.LogActions.ViewedStudy;
            log.ActionTime.Value = DateTime.Now;
            log.Save();
        }
    }
    protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        string status = hfStatus.Value;

        PatientObject patient = new PatientObject();
        patient.ExternalPatientId.Value = tbPatId.Text;
        patient.Load(loggedInUserId);
        patient.DateOfBirth.Value = dcDOB.Date;
        patient.Name.Value = RISUtility.GetFullName(tbPatFName.Text, tbPatLName.Text);
        patient.Gender.Value = rblGender.SelectedValue;
        patient.Save(loggedInUserId);
        StudyObject study = new StudyObject();
        study.PatientId.Value = patient.PatientId.Value;
        Random rand = new Random();
        study.StudyInstance.Value = rand.Next().ToString();
        DateTime dateTime = new DateTime(dcExamDate.Year, dcExamDate.Month, dcExamDate.Day);
        study.StudyDate.Value = dateTime;
        study.ReferringPhysicianId.Value = ddlRef.SelectedValue;
        study.IsManual.Value = "Y";
        study.StudyStatusId.Value = hfStatus.Value;
        study.ModalityId.Value = ddlModality.SelectedValue;
        study.ProcedureId.Value = ddlProcedures.SelectedValue;
        if (ddlClient.SelectedIndex > 0)
        {
            study.ClientId.Value = ddlClient.SelectedValue;
        }
        if (ddlHospital.SelectedIndex > 0)
        {
            study.HospitalId.Value = ddlHospital.SelectedValue;
        }
        study.Save(loggedInUserId);

        study.TechComments.Value = tbTechComments.Text;
        study.Save(loggedInUserId);
        //code for logging
        LogObject log = new LogObject();
        log.UserId.Value = loggedInUserId;
        log.Action.Value = Constants.LogActions.MarkedStudyForVerification;
        log.ActionTime.Value = DateTime.Now;
        log.Save();
        /////
        /// Get User Groups
        //DataTable userGroups = new DataTable();
        //userGroups = RISProcedureCaller.GetUserGroupsWithDefaults(loggedInUserId);
        //if (userGroups.Rows.Count > 0)
        //{
        //    for (int RowCounter = 0; RowCounter <= userGroups.Rows.Count - 1; RowCounter++)
        //    {
        //        StudyGroupObject studygroup = new StudyGroupObject();
        //        studygroup.GroupId.Value  = userGroups.Rows[RowCounter][0];
        //        studygroup.StudyId.Value  = study.StudyId.Value;
        //        studygroup.Save(loggedInUserId);
        //    }
        //}
        StringBuilder args = new StringBuilder();
        args.Append(ParameterNames.Request.ExternalPatientId);
        args.Append("=");
        args.Append(patient.ExternalPatientId.Value);
        args.Append("&");
        args.Append(ParameterNames.Request.PatientName);
        args.Append("=");
        args.Append(patient.Name.Value);
        args.Append("&");
        args.Append(ParameterNames.Request.ReturnPage);
        args.Append("=");
        args.Append(PagesFactory.Pages.AddStudyPage);
        PagesFactory.Transfer(PagesFactory.Pages.DataSavedPage,args.ToString());
    }
    protected void UpdateStudyStatus(int statusId)
    {
        StudyObject study = new StudyObject();
        study.StudyId.Value = int.Parse(lblStudyId.Value);
        study.Load(Constants.Database.NullUserId);
        if (study.IsLoaded == true)
        {
            study.StudyStatusId.Value = statusId;
            study.Save(loggedInUserId);

            LogObject log = new LogObject();
            log.UserId.Value = loggedInUserId;
            log.StudyId.Value = study.StudyId.Value;
            log.PatientId.Value = study.PatientId.Value;
            log.ActionTime.Value = DateTime.Now;

            if (statusId == Constants.StudyStatusTypes.PendingVerification)
                log.Action.Value = Constants.LogActions.MarkedStudyForVerification;
            else if (statusId == Constants.StudyStatusTypes.Verified)
                log.Action.Value = Constants.LogActions.VerifiedStudy;
            log.Save();
        }
    }
    protected override void Page_Load_Extended(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            lblStudyId.Value = Request[ParameterNames.Request.StudyId];
            if (IsFindingInRequest)
                lblFindingId.Value = Request[ParameterNames.Request.FindingId];
            ShowButtons();

            StudyObject study = new StudyObject();
            study.StudyId.Value = int.Parse(Request[ParameterNames.Request.StudyId]);
            study.Load(loggedInUserId);
            lblExamDate.Text = study.StudyDate.Value.ToString();
            PatientObject patient = new PatientObject();
            patient.PatientId.Value = study.PatientId.Value;
            patient.Load(loggedInUserId);
            lblPatientId.Text = (string)patient.ExternalPatientId.Value;
            lblPatientName.Text = (string)patient.Name.Value;
            StudyStatusTypeObject studyStatusType = new StudyStatusTypeObject();
            studyStatusType.StudyStatusTypeId.Value = study.StudyStatusId.Value;
            studyStatusType.Load(loggedInUserId);
            lblStatus.Text = (string)studyStatusType.Status.Value;
            ProcedureObject procedure = new ProcedureObject();
            procedure.ProcedureId.Value = study.ProcedureId.Value;
            procedure.Load(loggedInUserId);
            if (procedure.IsLoaded)
            {
                lblProcedure.Text = (string)procedure.Name.Value;
            }
            ModalityObject modality = new ModalityObject();
            modality.ModalityId.Value = procedure.ModalityId.Value;
            modality.Load(loggedInUserId);
            lblModality.Text = (string)modality.Name.Value;
            if (study.ReferringPhysicianId.Value != null)
            {
                UserObject referringPhysician = new UserObject();
                referringPhysician.UserId.Value = study.ReferringPhysicianId.Value;
                referringPhysician.Load(loggedInUserId);
                lblPhysician.Text = (string)referringPhysician.Name.Value;
            }
            FindingObject finding = new FindingObject();
            if (IsFindingInRequest)
            {
                finding.GetPrimaryKey().Value = int.Parse(Request[ParameterNames.Request.FindingId]);
                finding.Load(loggedInUserId);
            }
            else if (study.LatestFindingId.Value != null)
            {
                finding.FindingId.Value = study.LatestFindingId.Value;
                finding.Load(loggedInUserId);
            }
            if (finding.IsLoaded)
            {
                tbTrancription.Text = (string)finding.TextualTranscript.Value;
                if (finding.AudioUserId.Value != null)
                {
                    UserObject radiologist = new UserObject();
                    radiologist.UserId.Value = finding.AudioUserId.Value;
                    radiologist.Load(loggedInUserId);
                    lblRadiologist.Text = (string)radiologist.Name.Value;
                }
            }
            int studyStatusId = (int)study.StudyStatusId.Value;

            LogObject log = new LogObject();
            log.UserId.Value = loggedInUserId;
            log.StudyId.Value = study.StudyId.Value;
            log.PatientId.Value = study.PatientId.Value;
            log.Action.Value = Constants.LogActions.ViewedStudy;
            log.ActionTime.Value = DateTime.Now;
            log.Save();
        }
    }