コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
        private static YellowstonePathology.Business.Client.PhysicianClientDistribution BuildPhysicianClientDistribution(BsonDocument clientDocument, BsonDocument physicianDocument)
        {
            YellowstonePathology.Business.Client.PhysicianClientDistribution result = new YellowstonePathology.Business.Client.PhysicianClientDistribution();
            result.ClientId         = clientDocument.GetValue("ClientId").AsInt32;
            result.ClientName       = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName"));
            result.LongDistance     = clientDocument.GetValue("LongDistance").AsBoolean;
            result.FaxNumber        = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Fax"));
            result.DistributionType = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("DistributionType"));
            result.PhysicianId      = physicianDocument.GetValue("PhysicianId").AsInt32;
            result.PhysicianName    = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("DisplayName"));

            return(result);
        }
コード例 #4
0
        private static YellowstonePathology.Business.Client.PhysicianClientDistribution BuildPhysicianClientDistribution(BsonDocument clientDocument, BsonDocument physicianDocument)
        {
            YellowstonePathology.Business.Client.PhysicianClientDistribution result = new YellowstonePathology.Business.Client.PhysicianClientDistribution();
            result.ClientId = clientDocument.GetValue("ClientId").AsInt32;
            result.ClientName = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("ClientName"));
            result.LongDistance = clientDocument.GetValue("LongDistance").AsBoolean;
            result.FaxNumber = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("Fax"));
            result.DistributionType = Mongo.ValueHelper.GetStringValue(clientDocument.GetValue("DistributionType"));
            result.PhysicianId = physicianDocument.GetValue("PhysicianId").AsInt32;
            result.PhysicianName = Mongo.ValueHelper.GetStringValue(physicianDocument.GetValue("DisplayName"));

            return result;
        }
コード例 #5
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);
        }