private async Task <LabTestDetail> PrepareLabTestDetailAsync(IDictionary <int, string> attributes) { var labTestDetail = new LabTestDetail(); labTestDetail.CustomAttributes = _modelExtensionBuilder.BuildModelExtension <PatientLabTest>(); //clinicalEventDetail = _mapper.Map<ClinicalEventDetail>(clinicalEventForUpdate); foreach (var newAttribute in attributes) { var customAttribute = await _customAttributeRepository.GetAsync(ca => ca.Id == newAttribute.Key); if (customAttribute == null) { throw new KeyNotFoundException($"Unable to locate custom attribute {newAttribute.Key}"); } var attributeDetail = labTestDetail.CustomAttributes.SingleOrDefault(ca => ca.AttributeKey == customAttribute.AttributeKey); if (attributeDetail == null) { throw new KeyNotFoundException($"Unable to locate custom attribute on patient lab test {newAttribute.Key}"); } attributeDetail.Value = newAttribute.Value; } return(labTestDetail); }
private List <LabTestDetail> PrepareLabTestDetail(int attributeArray) { List <LabTestDetail> labTests = new List <LabTestDetail>(); var rowCount = GetRowCountFromArray(attributeArray); if (rowCount > 0) { for (int i = 0; i < rowCount; i++) { var labTestDetail = new LabTestDetail(); labTestDetail.CustomAttributes = _modelExtensionBuilder.BuildModelExtension <PatientLabTest>(); // Prepare first class labTestDetail.TestDate = Convert.ToDateTime(GetAttributeValueFromArrayRow(attributeArray, i, "testResultDate")); labTestDetail.LabTestSource = GetAttributeValueFromArrayRow(attributeArray, i, "labTest"); labTestDetail.TestResult = GetAttributeValueFromArrayRow(attributeArray, i, "testResultValue"); labTests.Add(labTestDetail); } } return(labTests); }