public IActionResult Post([FromBody] CentralRegistry entity) { if (null == entity) { return(BadRequest()); } if (entity.Id.IsNullOrEmpty()) { entity.Id = LiveGuid.NewGuid(); } try { _registryManagerService.Save(entity); return(Ok()); } catch (Exception e) { var msg = $"Error saving {nameof(CentralRegistry)}"; Log.Error(msg); Log.Error($"{e}"); return(StatusCode(500, msg)); } }
public Encounter() { //Status = "Created"; Id = LiveGuid.NewGuid(); EncounterDate = DateTime.Now; VisitType = SharedKernel.Model.VisitType.None; }
public virtual void AssignId() { if (typeof(TId) == typeof(Guid)) { Id = (TId)(object)LiveGuid.NewGuid(); } }
public InvalidMessage(Guid clientId, MessageType type, string message) { Id = LiveGuid.NewGuid(); ClientId = clientId; Type = type; Message = message; }
public IActionResult SaveRestProtocol([FromBody] RestProtocol entity) { if (null == entity) { return(BadRequest()); } if (entity.Id.IsNullOrEmpty()) { entity.Id = LiveGuid.NewGuid(); } try { _emrManagerService.SaveRestProtocol(entity); return(Ok(entity)); } catch (Exception e) { var msg = $"Error saving {nameof(RestProtocol)}"; Log.Error(msg); Log.Error($"{e}"); return(StatusCode(500, msg)); } }
public ClientState(Guid clientId, LiveState state) { Id = LiveGuid.NewGuid(); ClientId = clientId; StatusDate = DateTime.Now; Status = state; }
public void should_check_null_guids() { var blank2 = new Guid(); Assert.IsTrue(blank2.IsNullOrEmpty()); var blank3 = Guid.Empty; Assert.IsTrue(blank3.IsNullOrEmpty()); var blank4 = LiveGuid.NewGuid(); Assert.IsFalse(blank4.IsNullOrEmpty()); Guid?blank5 = null; Assert.IsTrue(blank5.IsNullOrEmpty()); blank5 = new Guid(); Assert.IsTrue(blank5.IsNullOrEmpty()); blank5 = Guid.Empty; Assert.IsTrue(blank5.IsNullOrEmpty()); blank5 = LiveGuid.NewGuid(); Assert.IsFalse(blank5.IsNullOrEmpty()); }
private void Activate() { RequestDate = DateTime.Now; ActivationCode = LiveGuid.NewGuid().ToString(); ActivationDate = DateTime.Now; ExpiryDate = DateTime.Now.AddYears(1); }
public async Task <int> Load() { int count = 0; try { /* * DomainEvents.Dispatch( * new ExtractActivityNotification(extractId, new DwhProgress( * nameof(PatientExtract), * nameof(ExtractStatus.Loading), * found, 0, 0, 0, 0))); * */ const int take = 1000; var eCount = await _tempHtsClientsExtractRepository.GetCleanCount(); var pageCount = _tempHtsClientsExtractRepository.PageCount(take, eCount); int page = 1; while (page <= pageCount) { var tempHtsClients = await _tempHtsClientsExtractRepository.GetAll(a => a.ErrorType == 0, page, take); var batch = tempHtsClients.ToList(); count += batch.Count; //Auto mapper var extractRecords = Mapper.Map <List <TempHtsClients>, List <HtsClients> >(batch); foreach (var record in extractRecords) { record.Id = LiveGuid.NewGuid(); } //Batch Insert var inserted = _htsClientsExtractRepository.BatchInsert(extractRecords); if (!inserted) { Log.Error($"Extract {nameof(HtsClients)} not Loaded"); return(0); } Log.Debug("saved batch"); page++; /* * DomainEvents.Dispatch( * new ExtractActivityNotification(extractId, new DwhProgress( * nameof(PatientExtract), * nameof(ExtractStatus.Loading), * found, count, 0, 0, 0))); */ } DomainEvents.Dispatch(new HtsNotification(new ExtractProgress(nameof(HtsClients), "Loading...", Found, 0, 0, 0, 0))); return(count); } catch (Exception e) { Log.Error(e, $"Extract {nameof(HtsClients)} not Loaded"); throw; } }
public void should_Evaluate_Count_Range() { // 1 to 4 var q4 = _form.Questions.First(x => x.Rank == 4); var obs = _encounter.Obses.First(x => x.QuestionId == q4.Id); _questionValidation = q4.Validations.First(x => x.ValidatorId.ToLower() == "Range".ToLower() && x.ValidatorTypeId.ToLower() == "Count".ToLower() && x.Revision == 0); _questionValidation.MinLimit = "1"; _questionValidation.MaxLimit = "4"; obs.ValueMultiCoded = $"{LiveGuid.NewGuid()},{LiveGuid.NewGuid()}"; _responseMinMax = new Response(obs.EncounterId, _encounter.ClientId, q4, obs); var isvalid = _questionValidation.Evaluate(_responseMinMax); Assert.IsTrue(isvalid); Console.WriteLine($"{q4}={obs.ValueMultiCoded} | {_questionValidation}"); _responseMinMax.Obs.ValueMultiCoded = String.Empty; Assert.Throws <ArgumentException>(() => _questionValidation.Evaluate(_responseMinMax)); _responseMinMax.Obs.ValueMultiCoded = null; Assert.Throws <ArgumentException>(() => _questionValidation.Evaluate(_responseMinMax)); _responseMinMax.Obs.ValueMultiCoded = $"{LiveGuid.NewGuid()},{LiveGuid.NewGuid()},{LiveGuid.NewGuid()},{LiveGuid.NewGuid()},{LiveGuid.NewGuid()}"; }
private Encounter(Guid clientId, Guid formId, Guid encounterTypeId, DateTime encounterDate, Guid providerId, Guid deviceId, Guid practiceId, DateTime?started, DateTime?stopped, Guid userId, bool isComplete, Guid?indexClientId, VisitType visitType) : this(LiveGuid.NewGuid(), clientId, formId, encounterTypeId, encounterDate, providerId, deviceId, practiceId, started, stopped, userId, isComplete, indexClientId, visitType) { }
public void SetUp() { _id1 = LiveGuid.NewGuid(); _id2 = LiveGuid.NewGuid(); _searchHits = new List <SearchHit> { new SearchHit(_id1), new SearchHit(_id1), new SearchHit(_id2) }; }
public void should_have_assigned_id_value() { var id = LiveGuid.NewGuid(); var t = new TestEntity(id, "Subaru"); Assert.AreEqual(id, t.Id); Console.WriteLine(t); }
private PSmartStore(string shr, Guid clientId) { Shr = shr; Date_Created = Status_Date = DateTime.Now; Uuid = LiveGuid.NewGuid(); Status = "PENDING"; ClientId = clientId; }
public async Task <int> Load(Guid extractId, int found, bool diffSupport) { int count = 0; var mapper = diffSupport ? ExtractDiffMapper.Instance : ExtractMapper.Instance; try { DomainEvents.Dispatch( new ExtractActivityNotification(extractId, new DwhProgress( nameof(PatientExtract), nameof(ExtractStatus.Loading), found, 0, 0, 0, 0))); const int take = 500; var eCount = await _tempPatientExtractRepository.GetCleanCount(); var pageCount = _tempPatientExtractRepository.PageCount(take, eCount); int page = 1; while (page <= pageCount) { var tempPatientExtracts = await _tempPatientExtractRepository.GetAll(a => a.ErrorType == 0, page, take); var batch = tempPatientExtracts.ToList(); count += batch.Count; //Auto mapper var extractRecords = mapper.Map <List <TempPatientExtract>, List <PatientExtract> >(batch); foreach (var record in extractRecords) { record.Id = LiveGuid.NewGuid(); } //Batch Insert var inserted = _patientExtractRepository.BatchInsert(extractRecords); if (!inserted) { Log.Error($"Extract {nameof(PatientExtract)} not Loaded"); return(0); } Log.Debug("saved batch"); page++; DomainEvents.Dispatch( new ExtractActivityNotification(extractId, new DwhProgress( nameof(PatientExtract), nameof(ExtractStatus.Loading), found, count, 0, 0, 0))); } await _mediator.Publish(new DocketExtractLoaded("NDWH", nameof(PatientExtract))); return(count); } catch (Exception e) { Log.Error(e, $"Extract {nameof(PatientExtract)} not Loaded"); throw; } }
public async Task <int> Load(Guid extractId, int found) { try { DomainEvents.Dispatch( new ExtractActivityNotification(extractId, new DwhProgress( nameof(PatientArtExtract), nameof(ExtractStatus.Loading), found, 0, 0, 0, 0))); //load temp extracts without errors StringBuilder querybuilder = new StringBuilder(); querybuilder.Append($" SELECT * FROM {nameof(TempPatientArtExtract)}s s"); querybuilder.Append($" INNER JOIN PatientExtracts p ON "); querybuilder.Append($" s.PatientPK = p.PatientPK AND "); querybuilder.Append($" s.SiteCode = p.SiteCode "); querybuilder.Append($" WHERE s.CheckError = 0"); string query = querybuilder.ToString(); var tempPatientArtExtracts = _tempPatientArtExtractRepository.GetFromSql(query); const int take = 1000; int skip = 0; var count = tempPatientArtExtracts.Count(); while (skip < count) { var batch = tempPatientArtExtracts.Skip(skip).Take(take).ToList(); //Auto mapper var extractRecords = Mapper.Map <List <TempPatientArtExtract>, List <PatientArtExtract> >(batch); foreach (var record in extractRecords) { record.Id = LiveGuid.NewGuid(); } //Batch Insert var inserted = _patientArtExtractRepository.BatchInsert(extractRecords); if (!inserted) { Log.Error($"Extract {nameof(PatientArtExtract)} not Loaded"); return(0); } Log.Debug("saved batch"); skip = skip + take; DomainEvents.Dispatch( new ExtractActivityNotification(extractId, new DwhProgress( nameof(PatientArtExtract), nameof(ExtractStatus.Loading), found, skip, 0, 0, 0))); } return(count); } catch (Exception e) { Log.Error(e, $"Extract {nameof(PatientArtExtract)} not Loaded"); return(0); } }
public async Task <int> Extract(DbExtract extract, DbProtocol dbProtocol) { int batch = 500; var list = new List <TempPatientAdverseEventExtract>(); int count = 0; int loaded = 0; using (var rdr = await _reader.ExecuteReader(dbProtocol, extract)) { while (rdr.Read()) { count++; // AutoMapper profiles var extractRecord = Mapper.Map <IDataRecord, TempPatientAdverseEventExtract>(rdr); extractRecord.Id = LiveGuid.NewGuid(); if (extractRecord.HasData()) { loaded++; list.Add(extractRecord); } if (count == batch) { _extractRepository.BatchInsert(list); count = 0; DomainEvents.Dispatch( new ExtractActivityNotification(extract.Id, new DwhProgress( nameof(PatientAdverseEventExtract), nameof(ExtractStatus.Finding), loaded, 0, 0, 0, 0))); list = new List <TempPatientAdverseEventExtract>(); } } if (count > 0) { // save remaining list; _extractRepository.BatchInsert(list); } _extractRepository.CloseConnection(); } // TODO: Notify Completed; DomainEvents.Dispatch( new ExtractActivityNotification(extract.Id, new DwhProgress( nameof(PatientAdverseEventExtract), nameof(ExtractStatus.Found), loaded, 0, 0, 0, 0))); return(loaded); }
protected Entity() { Type idType = typeof(TId); if (idType == typeof(Guid)) { Id = (TId)(object)LiveGuid.NewGuid(); } }
public DwhManifest(int siteCode, List <int> patientPks, string siteName, EmrDto emrDto) { Id = LiveGuid.NewGuid(); SiteCode = siteCode; PatientPks = patientPks; Name = siteName; EmrId = emrDto.EmrId; EmrName = emrDto.Name; EmrSetup = emrDto.EmrSetup; }
public Task <int> Extract(DbExtract extract, DbProtocol dbProtocol) { var mapper = dbProtocol.SupportsDifferential ? ExtractDiffMapper.Instance : ExtractMapper.Instance; int batch = 500; var list = new List <TempCwcVisitExtract>(); int count = 0; int loaded = 0; using (var rdr = _reader.ExecuteReaderSync(dbProtocol, extract)) { while (rdr.Read()) { count++; loaded++; // AutoMapper profiles var extractRecord = mapper.Map <IDataRecord, TempCwcVisitExtract>(rdr); extractRecord.Id = LiveGuid.NewGuid(); list.Add(extractRecord); if (count == batch) { _extractRepository.BatchInsert(list); count = 0; DomainEvents.Dispatch( new MnchExtractActivityNotification(extract.Id, new DwhProgress( nameof(CwcVisitExtract), nameof(ExtractStatus.Finding), loaded, 0, 0, 0, 0))); list = new List <TempCwcVisitExtract>(); } } if (count > 0) { // save remaining list; _extractRepository.BatchInsert(list); } _extractRepository.CloseConnection(); } // TODO: Notify Completed; DomainEvents.Dispatch( new MnchExtractActivityNotification(extract.Id, new DwhProgress( nameof(CwcVisitExtract), nameof(ExtractStatus.Found), loaded, 0, 0, 0, 0))); return(Task.FromResult(loaded)); }
public DwhManifestMessageBag(List <DwhManifestMessage> messages) { Session = LiveGuid.NewGuid(); var sessionStart = DateTime.Now; foreach (var message in messages) { message.Manifest.InitSession(Session, sessionStart, string.Empty); } Messages = messages; }
public static ExtractRequest GenerateExtractRequest(int count = 10) { return(new ExtractRequest { Id = LiveGuid.NewGuid(), Name = @"Patients", Description = @"All Patients", SqlScript = @"select * from Patients", RecordCount = count, Updated = DateTime.Now.AddHours(1) }); }
public void should_Save_Or_Update_Obs_New() { var newObs = _obs; newObs.Id = LiveGuid.NewGuid(); _obsRepository.SaveOrUpdate(newObs); _obsRepository = new ObsRepository(_liveSetting); var savedNewObs = _obsRepository.Get(newObs.Id); Assert.AreEqual(newObs.Id, savedNewObs.Id); Assert.IsNotNull(savedNewObs); }
public static ObsPartnerScreening Create(DateTime screeningDate, Guid ipvScreening, Guid physicalAssult, Guid threatened, Guid sexuallyUncomfortable, Guid hivStatus, Guid eligibility, DateTime bookingDate, string remarks, Guid?pnsAccepted, Guid?iPVOutcome, string occupation, Guid?pNSRealtionship, Guid?livingWithClient, Guid?pNSApproach, Guid encounterId, Guid indexClientId) { var obs = new ObsPartnerScreening(LiveGuid.NewGuid(), screeningDate, ipvScreening, physicalAssult, threatened, sexuallyUncomfortable, hivStatus, eligibility, bookingDate, remarks, pnsAccepted, iPVOutcome, occupation, pNSRealtionship, livingWithClient, pNSApproach, encounterId, indexClientId); return(obs); }
public static List <Registry> GenerateRegistry() { var registry = new Registry { Id = LiveGuid.NewGuid(), Name = "DWH", Purpose = "DWH", Code = "DWH" }; registry.AddRequest(GenerateExtractRequest()); return(new List <Registry>() { registry }); }
public async Task <int> Load(Guid extractId, int found) { try { DomainEvents.Dispatch( new ExtractActivityNotification(extractId, new DwhProgress( nameof(PatientExtract), nameof(ExtractStatus.Loading), found, 0, 0, 0, 0))); //load temp extracts without errors var tempPatientExtracts = _tempPatientExtractRepository.GetAll().Where(a => a.CheckError == false); const int take = 1000; int skip = 0; var count = tempPatientExtracts.Count(); while (skip < count) { var batch = tempPatientExtracts.Skip(skip).Take(take).ToList(); //Auto mapper var extractRecords = Mapper.Map <List <TempPatientExtract>, List <PatientExtract> >(batch); foreach (var record in extractRecords) { record.Id = LiveGuid.NewGuid(); } //Batch Insert var inserted = _patientExtractRepository.BatchInsert(extractRecords); if (!inserted) { Log.Error($"Extract {nameof(PatientExtract)} not Loaded"); return(0); } Log.Debug("saved batch"); skip = skip + take; DomainEvents.Dispatch( new ExtractActivityNotification(extractId, new DwhProgress( nameof(PatientExtract), nameof(ExtractStatus.Loading), found, skip, 0, 0, 0))); } return(count); } catch (Exception e) { Log.Error(e, $"Extract {nameof(PatientExtract)} not Loaded"); throw; } }
public async Task <int> Load(bool diffSupport) { var mapper = diffSupport ? ExtractDiffMapper.Instance : ExtractMapper.Instance; int count = 0; try { const int take = 1000; var eCount = await _tempHtsClientsLinkageExtractRepository.GetCleanCount(); var pageCount = _tempHtsClientsLinkageExtractRepository.PageCount(take, eCount); int page = 1; while (page <= pageCount) { var tempHtsClientLinkages = await _tempHtsClientsLinkageExtractRepository.GetAll(QueryUtil.Linkage, page, take); var batch = tempHtsClientLinkages.ToList(); count += batch.Count; //Auto mapper var extractRecords = mapper.Map <List <TempHtsClientLinkage>, List <HtsClientLinkage> >(batch); foreach (var record in extractRecords) { record.Id = LiveGuid.NewGuid(); } //Batch Insert var inserted = _clientsLinkageExtractRepository.BatchInsert(extractRecords); if (!inserted) { Log.Error($"Extract {nameof(HtsClientLinkage)} not Loaded"); return(0); } Log.Debug("saved batch"); page++; } DomainEvents.Dispatch(new HtsNotification(new ExtractProgress(nameof(HtsClientLinkage), "Loading...", Found, 0, 0, 0, 0))); return(count); } catch (Exception e) { Log.Error(e, $"Extract {nameof(HtsClientLinkage)} not Loaded"); throw; } }
public void should_group_by() { var cid = LiveGuid.NewGuid(); var encounters = Builder <Encounter> .CreateListOfSize(2).All().With(x => x.ClientId = cid).Build(); foreach (var encounter in encounters) { var obses = Builder <Obs> .CreateListOfSize(3).All().With(x => x.EncounterId = encounter.Id).Build(); foreach (var obse in obses) { encounter.Obses.Add(obse); } } var allObs = encounters.SelectMany(x => x.Obses).ToList(); Assert.True(allObs.Count > 0); var obsGroups = allObs .GroupBy(x => x.EncounterId).ToList(); Assert.True(obsGroups.Count == 2); foreach (var obsGroup in obsGroups) { Console.WriteLine($"{obsGroup.ToList().First().EncounterId}"); foreach (var o in obsGroup.ToList()) { Console.WriteLine($" {o.Id}"); } } foreach (var obsGroup in obsGroups) { // obsGroup. } foreach (var obs in allObs) { Console.WriteLine($"{obs.Id} | {obs.EncounterId} | {obs.ValueText}"); } }
public void should_Get_Obs_Value_Single() { // Single | Numeric | Multi | DateTime | Text _response.Question.Concept.ConceptTypeId = "Single"; _response.Obs.ValueCoded = LiveGuid.NewGuid(); var obsVal = _response.GetValue(); Assert.IsNotNull(obsVal); Assert.IsInstanceOfType(obsVal.Value, typeof(Guid?)); _response.Obs.ValueCoded = null; var obsValEmpty = _response.GetValue(); Assert.IsInstanceOfType(obsValEmpty.Value, typeof(Guid?)); Console.WriteLine(obsVal); Console.WriteLine(new string('-', 30)); Console.WriteLine(obsValEmpty); }
public void should_SaveOrUpdate_Update() { var guid = LiveGuid.NewGuid(); var client = _registryService.Find(_indexId); client.Person.FirstName = "Joni"; client.Identifiers.First().Identifier = "999999"; _registryService.SaveOrUpdate(client); var cientNew = _registryService.Find(_indexId); Assert.IsNotNull(cientNew); Assert.AreEqual("Joni", cientNew.Person.FirstName); Assert.AreEqual("999999", cientNew.Identifiers.First().Identifier); var states = cientNew.ClientStates.ToList(); Assert.True(states.Count == 2); Assert.NotNull(states.FirstOrDefault(x => x.Status == LiveState.HtsEnrolled)); Assert.NotNull(states.FirstOrDefault(x => x.Status == LiveState.HtsFamAcceptedYes)); Console.WriteLine(cientNew); }