示例#1
0
        public static Domain.PhysicianCollection GetPhysiciansByClientId(int clientId)
        {
            Domain.PhysicianCollection result = new Domain.PhysicianCollection();
            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianClientCollection         = server.Database.GetCollection <BsonDocument>("PhysicianClient");
            MongoCursor     physicianClientCursor             = physicianClientCollection.FindAs <BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId)));

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

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

            MongoCollection physicianCollection = server.Database.GetCollection <BsonDocument>("Physician");
            MongoCursor     physicianCursor     = physicianCollection.FindAs <BsonDocument>(Query.In("PhysicianId", physicianIdList));

            foreach (BsonDocument bsonDocument in physicianCursor)
            {
                Domain.Physician physician = new Domain.Physician();
                YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician);
                result.Add(physician);
            }

            return(result);
        }
示例#2
0
 public override object BuildNew()
 {
     YellowstonePathology.Business.Domain.Physician physician = new Domain.Physician();
     this.Build(physician);
     return(physician);
 }
        public static Domain.PhysicianCollection GetPhysiciansByClientId(int clientId)
        {
            Domain.PhysicianCollection result = new Domain.PhysicianCollection();
            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(YellowstonePathology.Business.Mongo.MongoTestServer.LISDatabaseName);
            MongoCollection physicianClientCollection = server.Database.GetCollection<BsonDocument>("PhysicianClient");
            MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", BsonValue.Create(clientId)));

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

            MongoCollection physicianCollection = server.Database.GetCollection<BsonDocument>("Physician");
            MongoCursor physicianCursor = physicianCollection.FindAs<BsonDocument>(Query.In("PhysicianId", physicianIdList));
            foreach (BsonDocument bsonDocument in physicianCursor)
            {
                Domain.Physician physician = new Domain.Physician();
                YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, physician);
                result.Add(physician);
            }

            return result;
        }
        private static Domain.Physician GetPhysicianFromCommand(SqlCommand cmd)
        {
            Domain.Physician result = null;
            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        result = new Domain.Physician();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(result, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();

                    }
                }
            }
            return result;
        }
        /*        public static Domain.PhysicianCollection GetPhysiciansByClientId(int clientId)
        {
        #if MONGO
            return PhysicianClientGatewayMongo.GetPhysiciansByClientId(clientId);
        #else
            Domain.PhysicianCollection result = new Domain.PhysicianCollection();

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select ph.* " +
               "from tblPhysician ph " +
               "join tblPhysicianClient pc on ph.PhysicianId = pc.PhysicianId " +
               "where pc.ClientId = @ClientId order by ph.LastName";
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
            cmd.CommandType = CommandType.Text;
            result = PhysicianClientGateway.GetPhysicianCollectionFromCommand(cmd);
            return result;
        #endif
        }*/
        private static Domain.PhysicianCollection GetPhysicianCollectionFromCommand(SqlCommand cmd)
        {
            Domain.PhysicianCollection result = new Domain.PhysicianCollection();
            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.BaseData.SqlConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Domain.Physician physician = new Domain.Physician();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physician, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(physician);
                    }
                }
            }
            return result;
        }
        private static YellowstonePathology.Business.Client.Model.ProviderClient BuildHomeBaseProviderClient(XElement providerElement)
        {
            YellowstonePathology.Business.Client.Model.ProviderClient result = new Client.Model.ProviderClient();
            YellowstonePathology.Business.Domain.Physician physician = new Domain.Physician();
            YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriterP = new Persistence.XmlPropertyWriter(providerElement, physician);
            xmlPropertyWriterP.Write();
            result.Physician = physician;

            XElement clientElement = providerElement.Element("Client");
            if (clientElement != null)
            {
                YellowstonePathology.Business.Client.Model.Client client = new Client.Model.Client();
                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriterC = new Persistence.XmlPropertyWriter(clientElement, client);
                xmlPropertyWriterC.Write();
                result.Client = client;
            }

            XElement providerClientElement = providerElement.Element("ProviderClient");
            if (providerClientElement != null)
            {
                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriterPC = new Persistence.XmlPropertyWriter(providerClientElement, result);
                xmlPropertyWriterPC.Write();
            }
            return result;
        }
        /*        public static Domain.ClientCollection GetClientsByPhysicianId(int physicianId)
        {
        #if MONGO
            return PhysicianClientGatewayMongo.GetClientsByPhysicianId(physicianId);
        #else
            Domain.ClientCollection result = new Domain.ClientCollection();

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select c.* " +
               "from tblClient c " +
               "join tblPhysicianClient pc on c.ClientId = pc.ClientId " +
               "where pc.PhysicianId = @PhysicianId ";
            cmd.Parameters.Add("@PhysicianId", SqlDbType.Int).Value = physicianId;
            cmd.CommandType = CommandType.Text;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.BaseData.SqlConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(client, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        result.Add(client);
                    }
                }
            }
            return result;
        #endif
        }*/
        /*        public static Domain.PhysicianClient GetPhysicianClient(int physicianId, int clientId)
        {
        #if MONGO
            return PhysicianClientGatewayMongo.GetPhysicianClient(physicianId, clientId);
        #else
            Domain.PhysicianClient result = null;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Select * from tblPhysicianClient where PhysicianId = @PhysicianId and ClientId = @ClientId";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@PhysicianId", SqlDbType.Int).Value = physicianId;
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;

            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Business.BaseData.SqlConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        result = new Domain.PhysicianClient();
                        YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(result, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                    }
                }
            }

            return result;
        #endif
        }

        public static View.ClientPhysicianView GetClientPhysicianViewByClientId(int clientId)
        {
        #if MONGO
            return PhysicianClientGatewayMongo.GetClientPhysicianViewByClientId(clientId);
        #else
            View.ClientPhysicianView result = null;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "with phys as(select p.* from tblPhysician p join tblPhysicianClient pc on p.PhysicianId = pc.PhysicianId where pc.ClientId = @ClientId) " +
                "select c.*," +
                " ( select phys.*" +
                "   from phys order by phys.FirstName for xml Path('Physician'), type) Physicians" +
                " from tblClient c where c.ClientId = @ClientId for xml Path('Client'), root('ClientPhysicianView')";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
            XElement resultElement = PhysicianClientGateway.GetXElementFromCommand(cmd);
            if (resultElement != null)
            {
                result = PhysicianClientGateway.BuildClientPhysicianView(resultElement);
            }
            return result;
        #endif
        }*/
        private static View.ClientPhysicianView BuildClientPhysicianView(XElement sourceElement)
        {
            View.ClientPhysicianView result = new View.ClientPhysicianView();
            XElement clientElement = sourceElement.Element("Client");
            YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter = new Persistence.XmlPropertyWriter(clientElement, result);
            xmlPropertyWriter.Write();

            XElement physiciansElement = clientElement.Element("Physicians");
            if(physiciansElement != null)
            {
                List<XElement> physicianElements = physiciansElement.Elements("Physician").ToList<XElement>();
                foreach (XElement physicianElement in physicianElements)
                {
                    Domain.Physician physician = new Domain.Physician();
                    YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriter1 = new Persistence.XmlPropertyWriter(physicianElement, physician);
                    xmlPropertyWriter1.Write();
                    result.Physicians.Add(physician);
                }
            }
            return result;
        }
 public override object BuildNew()
 {
     YellowstonePathology.Business.Domain.Physician physician = new Domain.Physician();
     this.Build(physician);
     return physician;
 }
        public static View.ClientPhysicianView GetClientPhysicianViewByClientIdV2(int clientId)
        {
            /*View.ClientPhysicianView result = null;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "with phys as(select p.* from tblPhysician p join tblPhysicianClient pc on p.ObjectId = pc.ProviderId where pc.ClientId = @ClientId) " +
                "select c.*," +
                " ( select phys.*" +
                "   from phys order by phys.FirstName for xml Path('Physician'), type) Physicians" +
                " from tblClient c where c.ClientId = @ClientId for xml Path('Client'), root('ClientPhysicianView')";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
            XElement resultElement = PhysicianClientGateway.GetXElementFromCommand(cmd);
            if (resultElement != null)
            {
                result = PhysicianClientGateway.BuildClientPhysicianView(resultElement);
            }
            return result;*/

            View.ClientPhysicianView result = null;
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select * from tblClient c where c.ClientId = @ClientId " +
                "select p.*from tblPhysician p join tblPhysicianClient pc on p.ObjectId = pc.ProviderId where pc.ClientId = @ClientId order by p.FirstName";
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@ClientId", SqlDbType.Int).Value = clientId;
            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.KeyInfo))
                {
                    while (dr.Read())
                    {
                        result = new View.ClientPhysicianView();
                        Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(result, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                    }
                    if (dr.IsClosed == false)
                    {
                        dr.NextResult();
                        while (dr.Read())
                        {
                            Domain.Physician physician = new Domain.Physician();
                            Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physician, dr);
                            sqlDataReaderPropertyWriter.WriteProperties();
                            result.Physicians.Add(physician);
                        }
                    }
                }
            }
            return result;
        }
示例#10
0
        /*private static YellowstonePathology.Business.Client.Model.ProviderClient BuildHomeBaseProviderClient(XElement providerElement)
        {
            YellowstonePathology.Business.Client.Model.ProviderClient result = new Client.Model.ProviderClient();
            YellowstonePathology.Business.Domain.Physician physician = new Domain.Physician();
            YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriterP = new Persistence.XmlPropertyWriter(providerElement, physician);
            xmlPropertyWriterP.Write();
            result.Physician = physician;

            XElement clientElement = providerElement.Element("Client");
            if (clientElement != null)
            {
                YellowstonePathology.Business.Client.Model.Client client = new Client.Model.Client();
                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriterC = new Persistence.XmlPropertyWriter(clientElement, client);
                xmlPropertyWriterC.Write();
                result.Client = client;
            }

            XElement providerClientElement = providerElement.Element("ProviderClient");
            if (providerClientElement != null)
            {
                YellowstonePathology.Business.Persistence.XmlPropertyWriter xmlPropertyWriterPC = new Persistence.XmlPropertyWriter(providerClientElement, result);
                xmlPropertyWriterPC.Write();
            }
            return result;
        }*/
        private static YellowstonePathology.Business.Client.Model.ProviderClientCollection BuildProviderClientCollection(SqlCommand cmd)
        {
            YellowstonePathology.Business.Client.Model.ProviderClientCollection result = new Client.Model.ProviderClientCollection();
            YellowstonePathology.Business.Client.Model.ClientCollection clientCollection = new YellowstonePathology.Business.Client.Model.ClientCollection();
            using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString))
            {
                cn.Open();
                cmd.Connection = cn;
                using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.KeyInfo))
                {
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Client.Model.ProviderClient providerClient = new Client.Model.ProviderClient();
                        YellowstonePathology.Business.Domain.Physician physician = new Domain.Physician();
                        Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physician, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        providerClient.Physician = physician;
                        result.Add(providerClient);
                    }
                    dr.NextResult();
                    while (dr.Read())
                    {
                        YellowstonePathology.Business.Client.Model.Client client = new YellowstonePathology.Business.Client.Model.Client();
                        Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(client, dr);
                        sqlDataReaderPropertyWriter.WriteProperties();
                        clientCollection.Add(client);
                    }
                    dr.NextResult();
                    while (dr.Read())
                    {
                        string providerClientId = dr["PhysicianClientId"].ToString();
                        string physicianObjectId = dr["ProviderId"].ToString();
                        foreach(Client.Model.ProviderClient providerClient in result)
                        {
                            if(providerClient.Physician.ObjectId == physicianObjectId)
                            {
                                providerClient.PhysicianClientId = providerClientId;
                                break;
                            }
                        }
                    }
                }
            }

            foreach (Client.Model.ProviderClient providerClient in result)
            {
                foreach (Client.Model.Client client in clientCollection)
                {
                    if (client.ClientId == providerClient.Physician.HomeBaseClientId)
                    {
                        providerClient.Client = client;
                        break;
                    }
                }
            }

            return result;
        }