private IList <DiagnosisKeyInputEntity> ReadFromWorkflow(int index, int pageSize) { var snapshot = _dateTimeProvider.Snapshot; // Select TemporaryExposureKeys from Workflow table which are ready to be processed (TEK is: AuthorisedByCaregiver, StartDateOfTekInclusion and IsSymptomatic are set, Unpublished PublishAfter not in the future) var selectTeksFromWorkflowQuery = _workflowDbContext.TemporaryExposureKeys .Where(x => x.Owner.AuthorisedByCaregiver != null && x.Owner.StartDateOfTekInclusion != null && x.PublishingState == PublishingState.Unpublished && x.PublishAfter <= snapshot && x.Owner.IsSymptomatic.HasValue ) .Skip(index) .Take(pageSize) .Select(x => new { x.Id, DailyKey = new DailyKey(x.KeyData, x.RollingStartNumber, UniversalConstants.RollingPeriodRange.Hi), //Constant cos iOS xxx requires all RP to be 144 DateOfSymptomsOnset = x.Owner.StartDateOfTekInclusion.Value, Symptomatic = x.Owner.IsSymptomatic.Value }).ToList(); // Map TEKS from selectTeksFromWorkflowQuery to a List of DiagnosisKeyInputEntities var diagnosisKeyInputEntities = selectTeksFromWorkflowQuery.Select(x => { var dsos = x.DailyKey.RollingStartNumber.DaysSinceSymptomOnset(x.DateOfSymptomsOnset); var trl = _transmissionRiskLevelCalculation.Calculate(dsos); var result = new DiagnosisKeyInputEntity { DailyKey = x.DailyKey, TekId = x.Id, Local = new LocalTekInfo { DaysSinceSymptomsOnset = dsos, //Added here as the new format has this as well as the EFGS format. TransmissionRiskLevel = trl, Symptomatic = x.Symptomatic } }; return(result); }).ToList(); return(diagnosisKeyInputEntities); }
private IList <DiagnosisKeyInputEntity> ReadFromWorkflow(int index, int pageSize) { var snapshot = _DateTimeProvider.Snapshot; var q1 = _WorkflowDbContext.TemporaryExposureKeys .Where(x => x.Owner.AuthorisedByCaregiver != null && x.Owner.DateOfSymptomsOnset != null && x.PublishingState == PublishingState.Unpublished && x.PublishAfter <= snapshot ) .Skip(index) .Take(pageSize) .Select(x => new { x.Id, DailyKey = new DailyKey(x.KeyData, x.RollingStartNumber, UniversalConstants.RollingPeriodRange.Hi), //Constant cos iOS xxx requires all RP to be 144 DateOfSymptomsOnset = x.Owner.DateOfSymptomsOnset.Value }).ToList(); var q2 = q1.Select(x => { var dsos = x.DailyKey.RollingStartNumber.DaysSinceSymptomOnset(x.DateOfSymptomsOnset); var trl = _TransmissionRiskLevelCalculation.Calculate(dsos); var result = new DiagnosisKeyInputEntity { DailyKey = x.DailyKey, TekId = x.Id, Local = new LocalTekInfo { DaysSinceSymptomsOnset = dsos, //Added here as the new format has this as well as the EFGS format. TransmissionRiskLevel = trl, }, }; return(result); }).ToList(); return(q2); }