public static YellowstonePathology.Business.Client.Model.PhysicianClientCollection GetPhysicianClientListByClientId(int clientId) { YellowstonePathology.Business.Client.Model.PhysicianClientCollection result = new Client.Model.PhysicianClientCollection(); BsonValue bsonClientId = BsonValue.Create(clientId); 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", bsonClientId)); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("ClientId", bsonClientId)); 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")); BsonValue bsonPhysicianClientId = null; foreach (BsonDocument physicianDocument in physicianCursor) { foreach (BsonDocument physicianClientDocument in physicianClientCursor) { if (physicianClientDocument.GetValue("PhysicianId").Equals(physicianDocument.GetValue("PhysicianId"))) { bsonPhysicianClientId = physicianClientDocument.GetValue("PhysicianClientId"); break; } } YellowstonePathology.Business.Client.Model.PhysicianClient physicianClient = BuildPhysicianClient(clientDocument, physicianDocument, bsonPhysicianClientId); result.Add(physicianClient); } return result; }
public static YellowstonePathology.Business.Client.Model.PhysicianClientCollection GetPhysicianClientListByPhysicianLastName(string physicianLastName) { YellowstonePathology.Business.Client.Model.PhysicianClientCollection result = new Client.Model.PhysicianClientCollection(); 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("^" + physicianLastName + ".*", "i"))).SetSortOrder(SortBy.Ascending("LastName", "FirstName")); foreach (BsonDocument physicianDocument in physicianCursor) { BsonValue physicianId = physicianDocument.GetValue("PhysicianId"); MongoCursor physicianClientCursor = physicianClientCollection.FindAs<BsonDocument>(Query.EQ("PhysicianId", 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) { BsonValue physicianClientId = null; foreach(BsonDocument physicianClientDocument in physicianClientCursor) { if(physicianClientDocument.GetValue("ClientId").Equals(clientDocument.GetValue("ClientId"))) { physicianClientId = physicianClientDocument.GetValue("PhysicianClientId"); break; } } YellowstonePathology.Business.Client.Model.PhysicianClient physicianClient = BuildPhysicianClient(clientDocument, physicianDocument, physicianClientId); result.Add(physicianClient); } } return result; }
public static YellowstonePathology.Business.Client.Model.PhysicianClientCollection GetPhysicianClientListByPhysicianLastNameV2(string physicianLastName) { YellowstonePathology.Business.Client.Model.PhysicianClientCollection result = new Client.Model.PhysicianClientCollection(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Select pp.PhysicianClientId, c.ClientId, c.ClientName, ph.PhysicianId, ph.ObjectId [ProviderId], ph.DisplayName [PhysicianName], c.DistributionType, c.Fax [FaxNumber], c.Telephone, c.LongDistance, c.FacilityType, ph.NPI " + "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 = physicianLastName; using (SqlConnection cn = new SqlConnection(YellowstonePathology.Properties.Settings.Default.CurrentConnectionString)) { cn.Open(); cmd.Connection = cn; using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { YellowstonePathology.Business.Client.Model.PhysicianClient physicianClient = new Client.Model.PhysicianClient(); YellowstonePathology.Business.Persistence.SqlDataReaderPropertyWriter sqlDataReaderPropertyWriter = new Persistence.SqlDataReaderPropertyWriter(physicianClient, dr); sqlDataReaderPropertyWriter.WriteProperties(); result.Add(physicianClient); } } } return result; }