コード例 #1
0
        private Regimen SuggestMedicine(string _Symptoms, string Age)
        {
            bool              treatmentFound = false;
            Regimen           retVal         = null;
            TreatmentRegimens model          = JsonConvert.DeserializeObject <TreatmentRegimens>(File.ReadAllText(@"./data.json").ToUpper());

            model.RegimenData.ForEach(r => {
                if ((!treatmentFound) && (r.Symptoms.Contains(_Symptoms.ToUpper())))
                {
                    treatmentFound = true;
                    retVal         = r;
                }
            });

            return(retVal);
        }
コード例 #2
0
        private string GetAdvice(string _Symptoms, string Age)
        {
            string  retVal = String.Empty;
            Regimen r      = SuggestMedicine(_Symptoms, Age);

            if (r != null)
            {
                retVal += String.Format("Please use {0}. ", r.MedicineNames[0]);
                if (String.IsNullOrEmpty(Age))
                {
                    retVal += String.Format("{0} for adult and {1} for a kid.", r.DosageAdult, r.DosageKid);
                }
                else
                {
                    switch (Age.ToUpper())
                    {
                    case "ADULT":
                        retVal += String.Format("{0} for adults. ", r.DosageAdult);
                        break;

                    case "KID":
                    case "CHILD":
                        retVal += String.Format("{0} for kids. ", r.DosageKid);
                        break;

                    case "INFANT":
                    case "BABY":
                    case "TODDLER":
                        retVal += " For infants please consult your doctor about safe dosage.";
                        break;

                    default:
                        break;
                    }
                }
                retVal += String.Format(" Alternate medicines are {0}.", r.AltMedicineNames[0]);
                retVal += String.Format(" Generic composition is {0}", r.MedicineComposition[0]);
            }
            else
            {
                retVal = "Sorry, I could not find a suggested treatment for your symptoms. Please consult a doctor.";
            }
            return(retVal);
        }