예제 #1
0
        /// <summary>
        /// Builds the Sql string for a single dimension included in an "And" dimension group by creating a
        /// DimensionGroup object.
        /// </summary>
        /// <param name="dimNod">The dimension XmlNode.</param>
        /// <param name="dg">DimensionGroup object that the Dimension belongs to.  This object is being build with each
        /// recursive call to this method.</param>
        /// <returns></returns>
        private string GetAndDimensionString(XmlNode dimNod, DimensionGroup dg)
        {
            string selectStr = "";
            string dimType   = dimNod.Attributes["type"].Value;

            //BaseDataAccess da = null;
            int key = 0;

            switch (dimType)
            {
            case "Institution":
                dg.institution = true;
                InstitutionDa ida = new InstitutionDa();
                key       = ida.GetPrimKey(dimNod.Attributes["value"].Value);
                selectStr = "Dataset_Patients.patientid in(SELECT PatientId FROM PatientInstitutions WHERE institutionid = " + key.ToString() + ") ";
                break;

            case "Physician":
                dg.physician = true;
                PhysicianDa pda = new PhysicianDa();
                key       = pda.GetPrimKey(dimNod.Attributes["value"].Value, dimNod.Attributes["value2"].Value);
                selectStr = "Dataset_Patients.patientid in(SELECT PatientId FROM PatientPhysicians WHERE PhysicianId = " + key.ToString() + ") ";
                break;

            case "Protocol":
                dg.protocol = true;
                ProtocolDa protda = new ProtocolDa();
                key       = protda.GetPrimKey(dimNod.Attributes["value"].Value);
                selectStr = "Dataset_Patients.patientid in (Select patientId from PatientProtocols where protocolId = " + key.ToString() + ") ";
                break;

            case "Disease":
                dg.disease = true;
                DiseaseDa dda = new DiseaseDa();
                key       = dda.GetPrimKey(dimNod.Attributes["value"].Value);
                selectStr = "Dataset_Patients.patientid in(SELECT PatientId FROM PatientDiseases WHERE DiseaseId = " + key.ToString() + ") ";
                break;

            case "All":
                dg.all    = true;
                selectStr = " ";
                break;
            }
            return(selectStr);
        }
예제 #2
0
        /// <summary>
        /// Builds the Sql string for a single dimension included in an "Or" dimension group by creating a
        /// DimensionGroup object.
        /// </summary>
        /// <param name="dimNod">The dimension XmlNode.</param>
        /// <param name="dg">DimensionGroup object that the Dimension belongs to.  This object is being build with each
        /// recursive call to this method.</param>
        private void GetOrDimensionString(XmlNode dimNod, DimensionGroup dg)
        {
            string dimType = dimNod.Attributes["type"].Value;

            //BaseDataAccess da = null;
            int key = 0;

            switch (dimType)
            {
            case "Institution":
                dg.institution = true;
                InstitutionDa ida = new InstitutionDa();
                key = ida.GetPrimKey(dimNod.Attributes["value"].Value);
                dg.orInstitution += key.ToString() + ", ";
                break;

            case "Physician":
                dg.physician = true;
                PhysicianDa pda = new PhysicianDa();
                key             = pda.GetPrimKey(dimNod.Attributes["value"].Value, dimNod.Attributes["value2"].Value);
                dg.orPhysician += key.ToString() + ", ";
                break;

            case "Protocol":
                dg.protocol = true;
                ProtocolDa protda = new ProtocolDa();
                key            = protda.GetPrimKey(dimNod.Attributes["value"].Value);
                dg.orProtocol += key.ToString() + ", ";
                break;

            case "Disease":
                dg.disease = true;
                DiseaseDa diseaseda = new DiseaseDa();
                key           = diseaseda.GetPrimKey(dimNod.Attributes["value"].Value);
                dg.orDisease += key.ToString() + ", ";
                break;

            case "All":
                dg.all = true;
                break;
            }
        }
예제 #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;
            }
        }