Exemplo n.º 1
0
        public static Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionByPhysicianLastName(string lastName)
        {
            Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            YellowstonePathology.Business.Mongo.Server            server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient");
            MongoCollection physicianCollection       = server.Database.GetCollection <BsonDocument>("Physician");
            MongoCollection clientCollection          = server.Database.GetCollection <BsonDocument>("Client");

            MongoCursor physicianCursor = physicianCollection.FindAs <BsonDocument>(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("LastName", "FirstName"));

            foreach (BsonDocument physicianDocument in physicianCursor)
            {
                MongoCursor      physicianClientCursor = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("PhysicianId", physicianDocument.GetValue("PhysicianId")));
                List <BsonValue> clientIdList          = new List <BsonValue>();
                foreach (BsonDocument physicianClientDocument in physicianClientCursor)
                {
                    clientIdList.Add(physicianClientDocument.GetValue("ClientId"));
                }

                MongoCursor clientCursor = clientCollection.FindAs <BsonDocument>(Query.In("ClientId", clientIdList)).SetSortOrder(SortBy.Ascending("ClientName"));
                foreach (BsonDocument clientDocument in clientCursor)
                {
                    YellowstonePathology.Business.Client.PhysicianClientDistribution physicianClientDistribution = BuildPhysicianClientDistribution(clientDocument, physicianDocument);
                    result.Add(physicianClientDistribution);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public static YellowstonePathology.Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionByClientId(int clientId)
        {
            Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            YellowstonePathology.Business.Mongo.Server            server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianClientCollection = server.Database.GetCollection <BsonDocument>("PhysicianClient");
            MongoCollection physicianCollection       = server.Database.GetCollection <BsonDocument>("Physician");
            MongoCollection clientCollection          = server.Database.GetCollection <BsonDocument>("Client");
            BsonDocument    clientDocument            = clientCollection.FindOneAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId)));
            MongoCursor     physicianClientCursor     = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId)));

            List <BsonValue> physicianIdList = new List <BsonValue>();

            foreach (BsonDocument physicianClientDocument in physicianClientCursor)
            {
                physicianIdList.Add(physicianClientDocument.GetValue("PhysicianId"));
            }

            MongoCursor physicianCursor = physicianCollection.FindAs <BsonDocument>(Query.In("PhysicianId", physicianIdList)).SetSortOrder(SortBy.Ascending("LastName", "FirstName"));

            foreach (BsonDocument physicianDocument in physicianCursor)
            {
                YellowstonePathology.Business.Client.PhysicianClientDistribution physicianClientDistribution = BuildPhysicianClientDistribution(clientDocument, physicianDocument);
                result.Add(physicianClientDistribution);
            }

            return(result);
        }
        public static YellowstonePathology.Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionCollection(int physicianId, int clientId)
        {
            YellowstonePathology.Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            string sql = "Select c.ClientId, c.ClientName, ph.PhysicianId, ph.DisplayName [PhysicianName], c.DistributionType, c.Fax [FaxNumber], c.LongDistance " +
                "from tblPhysicianClient pc " +
                "join tblPhysicianClientDistribution pcd on pc.PhysicianClientId = pcd.PhysicianClientId " +
                "join tblPhysicianClient pc2 on pcd.DistributionId = pc2.PhysicianClientId " +
                "join tblClient c on pc2.ClientId = c.ClientId " +
                "join tblPhysician ph on pc2.Physicianid = ph.PhysicianId " +
                "where pc.ClientId = @ClientId and pc.PhysicianId = @PhysicianId";

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = sql;
            cmd.Parameters.Add("@PhysicianId", SqlDbType.Int).Value = physicianId;
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        string distributionType = dr["DistributionType"].ToString();
                        YellowstonePathology.Business.Client.PhysicianClientDistribution physicianClientDistribution = YellowstonePathology.Business.Client.PhysicianClientDistributionFactory.GetPhysicianClientDistribution(distributionType);
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physicianClientDistribution, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(physicianClientDistribution);
                    }
                }
            }
            return result;
        }
Exemplo n.º 4
0
        public static YellowstonePathology.Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionCollection(int physicianId, int clientId)
        {
            YellowstonePathology.Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            string sql = "Select c.ClientId, c.ClientName, ph.PhysicianId, ph.DisplayName [PhysicianName], c.DistributionType, c.Fax [FaxNumber], c.LongDistance " +
                         "from tblPhysicianClient pc " +
                         "join tblPhysicianClientDistribution pcd on pc.PhysicianClientId = pcd.PhysicianClientId " +
                         "join tblPhysicianClient pc2 on pcd.DistributionId = pc2.PhysicianClientId " +
                         "join tblClient c on pc2.ClientId = c.ClientId " +
                         "join tblPhysician ph on pc2.Physicianid = ph.PhysicianId " +
                         "where pc.ClientId = @ClientId and pc.PhysicianId = @PhysicianId";

            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = sql;
            cmd.Parameters.Add("@PhysicianId", SqlDbType.Int).Value = physicianId;
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value    = clientId;
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        string distributionType = dr["DistributionType"].ToString();
                        YellowstonePathology.Business.Client.PhysicianClientDistribution      physicianClientDistribution = YellowstonePathology.Business.Client.PhysicianClientDistributionFactory.GetPhysicianClientDistribution(distributionType);
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physicianClientDistribution, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(physicianClientDistribution);
                    }
                }
            }
            return(result);
        }
        public static Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionByPhysicianLastNameV2(string lastName)
        {
            Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select c.ClientId, c.ClientName, ph.PhysicianId, ph.DisplayName [PhysicianName], c.DistributionType, c.Fax [FaxNumber], c.LongDistance " +
                 "from tblClient c " +
                 "join tblPhysicianClient pp on c.clientid = pp.clientid " +
                 "Join tblPhysician ph on pp.ProviderId = ph.ObjectId " +
                 "where ph.LastName like @LastName + '%' order by ph.LastName, ph.FirstName, c.ClientName";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@LastName", SqlDbType.VarChar, 50).Value = lastName;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        Business.Client.PhysicianClientDistribution physicianClientDistribution = new Business.Client.PhysicianClientDistribution();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physicianClientDistribution, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(physicianClientDistribution);
                    }
                }
            }
            return result;
        }
        public static Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionByPhysicianLastName(string lastName)
        {
            Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient");
            MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician");
            MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client");

            MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.Matches("LastName", BsonRegularExpression.Create("^" + lastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("LastName", "FirstName"));

            foreach (BsonDocument physicianDocument in physicianCursor)
            {
                MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", physicianDocument.GetValue("PhysicianId")));
                List<BsonValue> clientIdList = new List<BsonValue>();
                foreach (BsonDocument physicianClientDocument in physicianClientCursor)
                {
                    clientIdList.Add(physicianClientDocument.GetValue("ClientId"));
                }

                MongoCursor clientCursor = clientCollection.FindAs<BsonDocument>(Query.In("ClientId", clientIdList)).SetSortOrder(SortBy.Ascending("ClientName"));
                foreach (BsonDocument clientDocument in clientCursor)
                {
                    YellowstonePathology.Business.Client.PhysicianClientDistribution physicianClientDistribution = BuildPhysicianClientDistribution(clientDocument, physicianDocument);
                    result.Add(physicianClientDistribution);
                }
            }

            return result;
        }
        public static YellowstonePathology.Business.Client.PhysicianClientDistributionCollection GetPhysicianClientDistributionByClientId(int clientId)
        {
            Business.Client.PhysicianClientDistributionCollection result = new Client.PhysicianClientDistributionCollection();
            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient");
            MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician");
            MongoCollection clientCollection = server.Database.GetCollection<BsonDocument>("Client");
            BsonDocument clientDocument = clientCollection.FindOneAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId)));
            MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId)));

            List<BsonValue> physicianIdList = new List<BsonValue>();
            foreach (BsonDocument physicianClientDocument in physicianClientCursor)
            {
                physicianIdList.Add(physicianClientDocument.GetValue("PhysicianId"));
            }

            MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.In("PhysicianId", physicianIdList)).SetSortOrder(SortBy.Ascending("LastName", "FirstName"));

            foreach (BsonDocument physicianDocument in physicianCursor)
            {
                YellowstonePathology.Business.Client.PhysicianClientDistribution physicianClientDistribution = BuildPhysicianClientDistribution(clientDocument, physicianDocument);
                result.Add(physicianClientDistribution);
            }

            return result;
        }