// POST: api/LabOrderDetail public async Task <string> Post(LabOrderDetailViewModel detail) { //TODO:Complete service implementation bool result = await service.UpdateAmountCollected(detail); if (result) { return("successful"); } else { return("unsuccessful"); } }
public async Task <LabOrderDetailViewModel> GetLabOrderDetail(int lo) { var result = new LabOrderDetailViewModel(); var labOrder = db.LabOrders.Find(lo); //Build detail object from selected lab order result.Id = labOrder.Id; result.LabTestName = labOrder.LabTest.LabTestName; result.PatientName = labOrder.Patient.LastName + ", " + labOrder.Patient.FirstName; result.FacilityName = labOrder.Facility.FacilityName; result.OrderDateDisplay = labOrder.OrderDate.ToString("m/d/yy"); result.AmountCollected = labOrder.AmountCollected; return(await Task.FromResult(result)); }
private static LabOrderDetailViewModel getLabOrderDetailFromDataRow(DataRow row) { LabOrderDetailViewModel laborder = new LabOrderDetailViewModel { Id = row.Field <int>("Id"), OrderDate = row.Field <DateTime>("OrderDate"), OrderDateDisplay = row.Field <DateTime>("OrderDate").ToShortDateString(), LabTestName = row.Field <string>("LabTestName"), AmountCollected = row.Field <decimal>("AmountCollected"), PatientFirstName = row.Field <string>("Firstname"), PatientLastName = row.Field <string>("LastName"), FacilityName = row.Field <string>("FacilityName") }; return(laborder); }
public async Task <bool> UpdateAmountCollected(LabOrderDetailViewModel detail) { var labOrder = db.LabOrders.Find(detail.Id); labOrder.AmountCollected = detail.AmountCollected; try { await db.SaveChangesAsync(); return(true); } catch (Exception ex) { await Task.FromResult(ex.Message); return(false); } }
public async Task <LabOrderDetailViewModel> GetLabOrderDetail(int id) { LabOrderDetailViewModel result = new LabOrderDetailViewModel(); string con = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; string queryString = "SELECT LO.Id, LO.OrderDate, LO.AmountCollected, LT.LabTestName, P.FirstName, P.LastName, F.FacilityName FROM LabOrder as LO " + "LEFT JOIN LabTest as LT ON LO.LabTestId = LT.Id " + "LEFT JOIN Patient as P ON LO.PatientId = P.Id " + "LEFT JOIN Facility as F ON LO.FacilityId = F.Id " + "WHERE LO.Id = " + id; DataSet data; using (SqlConnection connection = new SqlConnection(con)) { connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(); SqlCommand command = new SqlCommand(queryString, connection); int rows = await command.ExecuteNonQueryAsync(); data = new DataSet(); adapter.SelectCommand = command; adapter.Fill(data); connection.Close(); } if (data.Tables[0].Rows.Count > 0) { result = getLabOrderDetailFromDataRow(data.Tables[0].Rows[0]); } return(result); }