public PatientSystemData InsertPatientSystem(InsertPatientSystemDataRequest request) { PatientSystemData result = null; try { if (request.PatientSystemsData != null) { var repo = Factory.GetRepository(RepositoryType.PatientSystem); if (request.IsEngageSystem) { request.PatientSystemsData.SystemId = Constants.EngageSystemId; request.PatientSystemsData.Value = EngageId.New(); request.PatientSystemsData.Primary = isSystemPrimary(Constants.EngageSystemId); request.PatientSystemsData.StatusId = (int)Status.Active; request.PatientSystemsData.DataSource = Constants.DataSource; } string id = (string)repo.Insert(request); if (!string.IsNullOrEmpty(id)) { result = (PatientSystemData)repo.FindByID(id); } } return(result); } catch (Exception ex) { throw ex; } }
public BulkInsertResult InsertBatchEngagePatientSystems(InsertBatchEngagePatientSystemsDataRequest request) { BulkInsertResult result = null; try { if (request.PatientIds != null && request.PatientIds.Count > 0) { var repo = Factory.GetRepository(RepositoryType.PatientSystem); List <PatientSystemData> psList = new List <PatientSystemData>(); bool status = isSystemPrimary(Constants.EngageSystemId); List <string> patientIds = request.PatientIds; patientIds.ForEach(p => { PatientSystemData ps = new PatientSystemData { DataSource = Constants.DataSource, PatientId = p, Primary = status, StatusId = (int)Status.Active, SystemId = Constants.EngageSystemId, Value = EngageId.New() }; psList.Add(ps); }); result = (BulkInsertResult)repo.InsertAll(psList.Cast <object>().ToList()); } } catch (Exception ex) { throw ex; } return(result); }