public string ManagePatientArvHistory(int id, int patientId, int patientMasterVisitId, dynamic artuseStrings, int userId) { try { //dynamic artuse = JsonConvert.DeserializeObject(artuseStrings); dynamic artuse = new JavaScriptSerializer().DeserializeObject(artuseStrings); var patientHivHistory = new PatientArvHistoryManager(); if (id < 1) { foreach (var item in artuse) { _result = patientHivHistory.AddPatientArtUseHistory(id, patientId, patientMasterVisitId, item.treatment.ToString(), item.purpose.ToString(), item.regimen.ToString(), Convert.ToDateTime(item.dateLastUsed), userId); } } else { foreach (var item in artuse) { _result = patientHivHistory.UpdatePatientArtUseHistory(id, patientId, patientMasterVisitId, item.treatment, item.purpose, item.regimen, item.dateLastUsed, userId); } } if (_result > 0) { _jsonMessage = "Patient ARV History Complete!"; } } catch (Exception e) { _jsonMessage = e.Message + ' ' + e.InnerException; } return(_jsonMessage); }
public string ManagePatientArvHistory(int id, int patientId, int patientMasterVisitId, dynamic artuseStrings, int userId) { try { //dynamic artuse = JsonConvert.DeserializeObject(artuseStrings); dynamic artuse = new JavaScriptSerializer().DeserializeObject(artuseStrings); var patientHivHistory = new PatientArvHistoryManager(); if (id < 1) { foreach (var item in artuse) { string treatment; string purpose; string regimen; DateTime dateLastUsed; if (item.ContainsKey("treatment") && item["treatment"] != null && !string.IsNullOrEmpty(item["treatment"].ToString()) ) { treatment = item["treatment"].ToString(); } else { treatment = String.Empty; } if (item.ContainsKey("purpose") && item["purpose"] != null && !string.IsNullOrEmpty(item["purpose"].ToString()) ) { purpose = item["purpose"].ToString(); } else { purpose = String.Empty; } if (item.ContainsKey("regimen") && item["regimen"] != null && !string.IsNullOrEmpty(item["regimen"].ToString()) ) { regimen = item["regimen"].ToString(); } else { regimen = String.Empty; } if (item.ContainsKey("dateLastUsed") && item["dateLastUsed"] != null ) { dateLastUsed = Convert.ToDateTime(item["dateLastUsed"]); } else { dateLastUsed = DateTime.MinValue; } _result = patientHivHistory.AddPatientArtUseHistory(id, patientId, patientMasterVisitId, treatment.ToString(), purpose.ToString(), regimen.ToString(), dateLastUsed, userId); } } else { foreach (var item in artuse) { string treatment; string purpose; string regimen; DateTime dateLastUsed; if (item.ContainsKey("treatment") && item["treatment"] != null && !string.IsNullOrEmpty(item["treatment"].ToString()) ) { treatment = item["treatment"].ToString(); } else { treatment = String.Empty; } if (item.ContainsKey("purpose") && item["purpose"] != null && !string.IsNullOrEmpty(item["purpose"].ToString()) ) { purpose = item["purpose"].ToString(); } else { purpose = String.Empty; } if (item.ContainsKey("regimen") && item["regimen"] != null && !string.IsNullOrEmpty(item["regimen"].ToString()) ) { regimen = item["regimen"].ToString(); } else { regimen = String.Empty; } if (item.ContainsKey("dateLastUsed") && item["dateLastUsed"] != null ) { dateLastUsed = Convert.ToDateTime(item["dateLastUsed"]); } else { dateLastUsed = DateTime.MinValue; } _result = patientHivHistory.UpdatePatientArtUseHistory(id, patientId, patientMasterVisitId, treatment.ToString(), purpose.ToString(), regimen.ToString(), dateLastUsed, userId); } } if (_result > 0) { _jsonMessage = "Patient ARV History Complete!"; } } catch (Exception e) { _jsonMessage = e.Message + ' ' + e.InnerException; } return(_jsonMessage); }