public IActionResult GetDoctorsNotes(int visitId) { // Begin Lab test GET EntityConnection connection = new EntityConnection("tbl_labtest_request"); Dictionary <string, string> rec = new Dictionary <string, string>(); rec.Add("visitId", visitId + ""); List <Dictionary <string, object> > labTests = new List <Dictionary <string, object> >(); Dictionary <string, object> xray = new Dictionary <string, object>(); Dictionary <string, object> referrals = new Dictionary <string, object>(); Dictionary <string, object> result = connection.GetLabRequestByVisit(visitId); if (result.Count > 0) { obj = result["labTestId"]; notes = result["testNote"]; string labTestIds = obj.ToString(); string labNotes = notes.ToString(); result.Remove("labTestId"); result.Remove("testNote"); List <string> testIds = new List <string>(); List <string> testNames = new List <string>(); List <string> testNotes = new List <string>(); // Check if labtestId has values and not ab anempty array if (labTestIds.Trim() != "") { var ids = labTestIds.Split(','); foreach (var id in ids) { testIds.Add(id); } string[] orQueries = testIds.Select(labtestid => "itbId =" + labtestid).ToArray(); if (orQueries != null) { var testObjs = connection.LabTestNames(orQueries); foreach (var obj in testObjs) { testNames.Add(obj["labTestName"].ToString()); } } } // Check if lab notes is empty if (labNotes.Trim() != "") { var notes = labNotes.Split('|'); foreach (var note in notes) { testNotes.Add(note); } } for (int i = 0; i < testIds.ToArray().Length; i++) { var labTest = new Dictionary <string, object>(); labTest["id"] = testIds[i]; labTest["testName"] = testNames[i]; labTest["testNote"] = testNotes[i]; labTests.Add(labTest); } } // End Lab test GET // Begin xray GET EntityConnection konnect = new EntityConnection("tbl_xray_request"); Dictionary <string, string> record = new Dictionary <string, string>(); record.Add("visitId", visitId + ""); Dictionary <string, object> res = konnect.GetXrayRequestByVisit(visitId); if (res.Count > 0) { xray = res; } else { xray = null; } // End X-ray request GET // Begin referrals GET EntityConnection conns = new EntityConnection("tbl_referral"); Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("visitId", visitId + ""); Dictionary <string, object> tempres = conns.GetReferralByVisit(visitId); if (tempres.Count > 0) { referrals = tempres; } else { referrals = null; } // End Referrals GET // Insert all result of the above operations independently into seperate dictionaries // Dictionary<string, object> Dic1 = new Dictionary<string, object>(); // Dic1. // if (true) // { // } notes = new { data = new { labTests, xray, referrals } }; return(Ok(notes)); }