private PatientUtilizationData MapPatientUtilizationData(MEPatientUtilization meN) { var data = new PatientUtilizationData { Id = meN.Id.ToString(), PatientId = meN.PatientId.ToString(), AdmitDate = meN.AdmitDate, DischargeDate = meN.DischargeDate, DispositionId = meN.Disposition.ToString(), LocationId = meN.Location.ToString(), OtherDisposition = Helper.TrimAndLimit(meN.OtherDisposition, 100), OtherLocation = Helper.TrimAndLimit(meN.OtherLocation, 100), OtherType = Helper.TrimAndLimit(meN.OtherType, 100), DataSource = Helper.TrimAndLimit(meN.DataSource, 50), Reason = Helper.TrimAndLimit(meN.Reason, 5000), VisitTypeId = (meN.VisitType == null) ? null : meN.VisitType.ToString(), ProgramIds = Helper.ConvertToStringList(meN.ProgramIds), SourceId = (meN.SourceId == null) ? null : meN.SourceId.ToString(), TypeId = (meN.NoteType == null) ? null : meN.NoteType.ToString(), CreatedById = meN.RecordCreatedBy.ToString(), CreatedOn = meN.RecordCreatedOn, Admitted = meN.Admitted, UpdatedById = (meN.UpdatedBy == null) ? null : meN.UpdatedBy.ToString(), UpdatedOn = meN.LastUpdatedOn }; return(data); }
public object FindByID(string entityID) { PatientUtilizationData utilData = null; try { using (PatientNoteMongoContext ctx = new PatientNoteMongoContext(ContractDBName)) { List <IMongoQuery> queries = new List <IMongoQuery>(); queries.Add(MB.Query.EQ(MEPatientUtilization.IdProperty, ObjectId.Parse(entityID))); queries.Add(MB.Query.EQ(MEPatientUtilization.DeleteFlagProperty, false)); IMongoQuery mQuery = MB.Query.And(queries); MEPatientUtilization meN = ctx.PatientUtilizations.Collection.Find(mQuery).FirstOrDefault(); if (meN != null) { utilData = MapPatientUtilizationData(meN); } } return(utilData); } catch (Exception) { throw; } }
public object Insert(object newEntity) { var data = newEntity as PatientUtilizationData; string noteId = string.Empty; try { if (data != null) { var meN = new MEPatientUtilization(this.UserId) { DeleteFlag = false, OtherDisposition = Trim(data.OtherDisposition, 100), OtherLocation = Trim(data.OtherLocation, 100), OtherType = Trim(data.OtherType, 100), ProgramIds = data.ProgramIds != null?data.ProgramIds.ConvertAll(ObjectId.Parse) : null, DataSource = data.DataSource = Helper.TrimAndLimit(data.DataSource, 50), Reason = data.Reason = Helper.TrimAndLimit(data.Reason, 5000), Version = 1, Admitted = data.Admitted }; if (data.AdmitDate != null && !data.AdmitDate.Equals(new DateTime())) { meN.AdmitDate = data.AdmitDate = data.AdmitDate.GetValueOrDefault().ToUniversalTime(); } else { data.AdmitDate = null; } if (data.DischargeDate != null && !data.DischargeDate.Equals(new DateTime())) { meN.DischargeDate = data.DischargeDate = data.DischargeDate.GetValueOrDefault().ToUniversalTime(); } else { data.DischargeDate = null; } if (!string.IsNullOrEmpty(data.DispositionId)) { meN.Disposition = ObjectId.Parse(data.DispositionId); } if (!string.IsNullOrEmpty(data.LocationId)) { meN.Location = ObjectId.Parse(data.LocationId); } if (!string.IsNullOrEmpty(data.SourceId)) { meN.SourceId = ObjectId.Parse(data.SourceId); } if (!string.IsNullOrEmpty(data.VisitTypeId)) { meN.VisitType = ObjectId.Parse(data.VisitTypeId); } if (!string.IsNullOrEmpty(data.PatientId)) { meN.PatientId = ObjectId.Parse(data.PatientId); } if (!string.IsNullOrEmpty(data.TypeId)) { meN.NoteType = ObjectId.Parse(data.TypeId); } using (Context) { Context.PatientUtilizations.Collection.Insert(meN); AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientUtilization.ToString(), meN.Id.ToString(), DataAuditType.Insert, ContractDBName); noteId = meN.Id.ToString(); } data.CreatedById = meN.RecordCreatedBy.ToString(); data.CreatedOn = meN.RecordCreatedOn; data.Id = meN.Id.ToString(); } return(data); } catch (Exception ex) { throw ex; } }