public ServiceResult Get(string name) { if (string.IsNullOrWhiteSpace(name)) { return(ServiceResponse.Error("You must provide a name for the Symptom.")); } SymptomManager symptomManager = new SymptomManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); List <Symptom> s = symptomManager.Search(name); if (s == null || s.Count == 0) { return(ServiceResponse.Error("Symptom could not be located for the name " + name)); } return(ServiceResponse.OK("", s)); }
public ServiceResult AddSymptomLog(SymptomLog s) { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } if (string.IsNullOrWhiteSpace(s.AccountUUID) || s.AccountUUID == SystemFlag.Default.Account) { s.AccountUUID = CurrentUser.AccountUUID; } if (string.IsNullOrWhiteSpace(s.CreatedBy)) { s.CreatedBy = CurrentUser.UUID; } SymptomManager symptomManager = new SymptomManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); if (!string.IsNullOrWhiteSpace(s.UUParentID)) { SymptomLog parentLog = symptomManager.GetSymptomLogBy(s.UUParentID); if (parentLog == null) { return(ServiceResponse.Error("Invalid log parent id. The UUParentID must belong to a valid Symptom Log entry.")); } s.DoseUUID = parentLog.DoseUUID; if (string.IsNullOrWhiteSpace(s.UUParentIDType)) { s.UUParentIDType = parentLog.UUIDType; } } s.Active = true; if (string.IsNullOrWhiteSpace(s.UUIDType)) { s.UUIDType = "SymptomLog"; } //backlog go to dosehistory selsect a dose and in the symptomps list //click add . fill in the data and click //VERIFY the fields here. //rules for parent list symptom creation //Name <- may need to create //SymptomUUID <- may need to create if (string.IsNullOrWhiteSpace(s.Name) && string.IsNullOrWhiteSpace(s.SymptomUUID)) { return(ServiceResponse.Error("You must select a symptom.")); } else if (string.IsNullOrWhiteSpace(s.Name) && string.IsNullOrWhiteSpace(s.SymptomUUID) == false) { //get and assign the name var res = symptomManager.Get(s.SymptomUUID); if (res.Code != 200) { return(res); } Symptom symptom = (Symptom)res.Result; s.Name = symptom.Name; } else if (!string.IsNullOrWhiteSpace(s.Name) && string.IsNullOrWhiteSpace(s.SymptomUUID)) { //create the symptoms and assign it to the symptomuuid Symptom symptom = (Symptom)symptomManager.Search(s.Name)?.FirstOrDefault(); if (symptom != null) { s.SymptomUUID = symptom.UUID; } else { symptom = new Symptom() { Name = s.Name, AccountUUID = s.AccountUUID, Active = true, CreatedBy = CurrentUser.UUID, DateCreated = DateTime.UtcNow, Deleted = false, UUIDType = "Symptom", Category = "General" }; ServiceResult sr = symptomManager.Insert(symptom); if (sr.Code == 500) { return(ServiceResponse.Error(sr.Message)); } s.SymptomUUID = symptom.UUID; } } if (s.SymptomDate == null || s.SymptomDate == DateTime.MinValue) { s.SymptomDate = DateTime.UtcNow; } if (string.IsNullOrWhiteSpace(s.Status))//Status start middle end. Query StatusMessage table { return(ServiceResponse.Error("You must provide a status.")); } if (s.Severity > 5) { return(ServiceResponse.Error("Severity must not be greater than 5.")); } if (s.Efficacy > 5) { return(ServiceResponse.Error("Efficacy must not be greater than 5.")); } return(symptomManager.Insert(s)); }