Пример #1
0
        /// <summary>
        /// Inserts a new patient with relevant required dataset paramaters
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        private DataSet InsertNewPatientRecord(Patient patient)
        {
            PatientController ct = new PatientController();
            int sessionId        = (int)Session[SessionKey.DatasetId];
            int?institutionId    = null;

            // if current dataset isn't mapped to institution, add institution based on user selection
            if (!hasInstitutionDataset)
            {
                string institutionIdValue = NewPatientInstitutionSelect.Value;
                if (string.IsNullOrEmpty(institutionIdValue))
                {
                    throw new InvalidScreeningException("An Institution is required for adding a patient to this dataset.");
                }
                else
                {
                    institutionId = int.Parse(institutionIdValue);
                }
            }
            // insert patient
            DataSet dimensionDs = ct.InsertNewPatientRecord(patient, sessionId);

            // if an insitution is required, create dimension
            if (patient.PrimaryKeyHasValue && !hasInstitutionDataset && institutionId.HasValue)
            {
                int patientId         = (int)patient[Patient.PatientId];
                PatientInstitution pi = new PatientInstitution();
                pi[PatientInstitution.PatientId]     = patientId;
                pi[PatientInstitution.InstitutionId] = institutionId.Value;
                pi.Save();
            }
            // return new dimension
            return(dimensionDs);
        }
    protected void AddButtonClick(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        if (!Request.Form["Institutions"].Equals("") && !Request.Form["SelectPatientName"].Equals(""))
        {
            UserGroupDa userGroupDa   = new UserGroupDa();
            int         patientId     = int.Parse(Request.Form["SelectPatientName"]);
            int         institutionId = int.Parse(Request.Form["Institutions"]);

            SecurityController sc = new SecurityController();

            PatientInstitution ptInstitution = new PatientInstitution();
            ptInstitution[PatientInstitution.InstitutionId] = institutionId;
            ptInstitution[PatientInstitution.PatientId]     = patientId;
            //ptInstitution[PatientInstitution.EnteredBy] = sc.GetUserName();
            //ptInstitution[PatientInstitution.EnteredTime] = DateTime.Now;

            ptInstitution.Save();

            this.ShowInstitutionSelect(patientId);
            //this.Page_Load(sender, (System.EventArgs)e);
        }
        else
        {
            valMsg.Text = "You must select a patient and institution.";
        }
    }
Пример #3
0
        private void InsertDimension(object atts, int patientId, SqlTransaction trans)
        {
            DataRow dr;

            if (atts is XmlNode)
            {
                dr = this.AttributesToRow(((XmlNode)atts).Attributes);
            }
            else
            {
                dr = (DataRow)atts;
            }

            string dimType = (string)dr["type"];

            switch (dimType)
            {
            case "Institution":
                InstitutionDa ida           = new InstitutionDa();
                int           institutionId = ida.GetPrimKey((string)dr["value"]);
                this._CheckId(institutionId, dimType, dr);
                PatientInstitutionDa pida = new PatientInstitutionDa();

                if (VerifyUnique((pida.GetPatientInstitution(patientId, institutionId, trans)).Tables[0]))
                {
                    // NEW CODE, insert record though middle tier
                    PatientInstitution ptInstitution = new PatientInstitution();
                    ptInstitution[PatientInstitution.PatientId]     = patientId;
                    ptInstitution[PatientInstitution.InstitutionId] = institutionId;
                    ptInstitution.Save();

                    // OLD CODE, inserts now handled by middle tier
                    // pida.InsertPatientInstitution(patientId, institutionId, trans);  add trans logic after concurrency fully tested- spy 2/21
                    // pida.InsertPatientInstitution(patientId, institutionId, trans);
                }
                break;

            case "Physician":
                PhysicianDa pda = new PhysicianDa();
                //to get Physician primary key need to pass first and last name in from dataset defined in XML
                int physicianId = pda.GetPrimKey((string)dr["value"], (string)dr["value2"]);
                this._CheckId(physicianId, dimType, dr);

                PatientPhysicianDa ppda = new PatientPhysicianDa();
                if (VerifyUnique((ppda.ValidatePatientPhysician(patientId, physicianId)).Tables[0]))
                {
                    // NEW CODE, insert record though middle tier
                    PatientPhysician ptPhysician = new PatientPhysician();
                    ptPhysician[PatientPhysician.PatientId]   = patientId;
                    ptPhysician[PatientPhysician.PhysicianId] = physicianId;
                    ptPhysician.Save();

                    // OLD CODE, inserts now handled by middle tier
                    //should be creating Patient Physician biz object and passing object to PatientPhysicianDa
                    //ppda.InsertPatientPhysicianDimension(patientId, physicianId, _sc.GetUserName(), trans);
                }
                break;

            case "Protocol":
                ProtocolDa protDa     = new ProtocolDa();
                int        protocolId = protDa.GetPrimKey((string)dr["value"]);
                this._CheckId(protocolId, dimType, dr);

                PatientProtocolDa ptProtDa = new PatientProtocolDa();
                if (VerifyUnique((ptProtDa.ValidatePatientProtocol(patientId, protocolId)).Tables[0]))
                {
                    // NEW CODE, insert record though middle tier
                    PatientProtocol ptProtocol = new PatientProtocol();
                    ptProtocol[PatientProtocol.PatientId]  = patientId;
                    ptProtocol[PatientProtocol.ProtocolId] = protocolId;
                    ptProtocol.Save();

                    // OLD CODE, inserts now handled by middle tier
                    //ptProtDa.InsertPatientProtocolDimension(patientId, protocolId, _sc.GetUserName(), trans);
                }
                break;

            case "Disease":
                DiseaseDa disDa     = new DiseaseDa();
                int       diseaseId = disDa.GetPrimKey((string)dr["value"]);
                this._CheckId(diseaseId, dimType, dr);

                PatientDiseaseDa ptDiseaseDa = new PatientDiseaseDa();
                if (VerifyUnique((ptDiseaseDa.GetPatientDisease(patientId, diseaseId)).Tables[0]))
                {
                    // NEW CODE, insert record though middle tier
                    PatientDisease ptDisease = new PatientDisease();
                    ptDisease[PatientDisease.PatientId] = patientId;
                    ptDisease[PatientDisease.DiseaseId] = diseaseId;
                    ptDisease.Save();

                    // OLD CODE, inserts now handled by middle tier
                    //ptDiseaseDa.InsertPatientDisease(patientId, diseaseId, trans);
                }
                break;
            }
        }