public async Task <Guid> StartNewFormAsync(FormAccessLevel accessLevel, string key, PreFillLookupCriteria criteria) { var form = await _db.Forms.FirstOrDefaultAsync(f => f.AccessLevel == accessLevel && f.Key == key); if (form is null) { throw new Exception("No matching form"); } var entry = new FormEntry { FormKey = form.Key, PrefillCriteria = criteria, Status = FormStatus.Open, }; var preFillProcessors = await _db.PreFillProcessors.Where(p => p.FormKey == key).ToArrayAsync(); foreach (var processor in preFillProcessors) { await _preFillProcessor.ProcessFormAsync(processor, entry); } if (form.Key == "ocif") { //var ocif = new FormOCIF //{ // Id = entry.Id, // Data = entry.Data, //}; //await _db.AddAsync(ocif); var ocif = new OCIF { ID = entry.Id, JSONData = entry.Data }; await _uiPathDb.AddAsync(ocif); await _uiPathDb.SaveChangesAsync(); } await _db.AddAsync(entry); await _db.SaveChangesAsync(); return(entry.Id); }
public async Task ProcessAsync(ACFormProcessor processor, FormEntry formEntry) { var mappings = JsonSerializer.Deserialize <Dictionary <string, string> >(processor.ConversionSpec); var formData = JsonSerializer.Deserialize <FormData>(formEntry.Data); _logger.LogInformation("Creating UiPath submission for FormEntry {formEntry}", formEntry.Id); formData.data.TryGetValue(mappings["CPTCodes"], out var cptCodes); formData.data.TryGetValue(mappings["DiagnosisCodes"], out var diagnosisCodes); formData.data.TryGetValue(mappings["MemberFirstName"], out var memberFirstName); formData.data.TryGetValue(mappings["MemberLastName"], out var memberLastName); formData.data.TryGetValue(mappings["NPIReferFrom"], out var npiReferFrom); formData.data.TryGetValue(mappings["NPIReferTo"], out var npiReferTo); formData.data.TryGetValue(mappings["MemberDOB"], out var memberDobStr); DateTime.TryParse(memberDobStr.ToString(), out var memberDob); var cpt = JsonSerializer.Deserialize <List <string> >(cptCodes.ToString()); var diag = JsonSerializer.Deserialize <List <string> >(diagnosisCodes.ToString()); var submission = new FormSubmission { FormEntryId = formEntry.Id, PDFPath = $"{formEntry.Id}", CPTCodes = string.Join(",", cpt), DiagnosisCodes = string.Join(",", diag), MemberDOB = memberDob, MemberFirstName = memberFirstName.ToString(), MemberLastName = memberLastName.ToString(), NPIReferFrom = npiReferFrom.ToString(), NPIReferTo = npiReferTo.ToString(), SubmissionDate = formEntry.SubmissionDate.GetValueOrDefault() }; await _uiPathDb.AddAsync(submission); await _uiPathDb.SaveChangesAsync(); _logger.LogInformation("UiPath submission for FormEntry {formEntry} successfully created", formEntry.Id); }