private static SuggestedDose ProcessIndicationAndDoseGroup(IndicationAndDoseGroups indicationGroup)
        {
            SuggestedDose dose = new SuggestedDose();

            dose.Indications = indicationGroup.TherapeuticIndications.Select(x => x.Indication).ToList();
            string[]           routes             = indicationGroup.RoutesAndPatientGroups.Select(x => x.RoutesOfAdministration.Select(y => y.Route).FirstOrDefault()).FirstOrDefault().Split(" ");
            string             route              = CapitalizeWord(routes[1]);
            string             method             = (routes.Length > 2) ? CapitalizeWord(routes[2]) : string.Empty;
            DoseAdministration doseAdministration = new DoseAdministration {
                Route = CapitalizeWord(routes[1]), Method = method
            };
            RoutesAndPatientGroups routesAndPatientGroups = indicationGroup.RoutesAndPatientGroups.FirstOrDefault();

            if (routesAndPatientGroups != null)
            {
                foreach (PatientGroup patientGroup in routesAndPatientGroups.PatientGroups)
                {
                    DoseOutput output = new DoseOutput();
                    output.AgeBand = new AgeBand
                    {
                        AgeLow = new ValueObject
                        {
                            Value = patientGroup.Age.From,
                            Unit  = CheckYearFormat(patientGroup.Age.FromUnit)
                        },
                        AgeHigh = new ValueObject
                        {
                            Value = patientGroup.Age.To,
                            Unit  = CheckYearFormat(patientGroup.Age.ToUnit)
                        }
                    };
                    output.Flags = new Flag {
                        Frequency = CalculateFrequency(patientGroup.DoseStatement.DoseInstruction.FirstOrDefault())
                    };
                    output.Quantity = CalculateQuantity(patientGroup.DoseStatement.DoseInstruction.FirstOrDefault());
                    doseAdministration.Doses.Add(output);
                }
            }
            dose.DoseAdministrations = new List <DoseAdministration> {
                doseAdministration
            };
            return(dose);
        }
Example #2
0
        /// <summary>
        /// Create new test drug.
        /// </summary>
        /// <param name="testName">Name of the drug</param>
        /// <param name="testIndication">Indication for use.</param>
        /// <param name="testRoute">Route of using.</param>
        /// <returns>A new drug test object.</returns>
        public static Drug GetDrug(string testName, string testIndication, string testRoute)

        {
            IList <DoseInstruction> doseInstructions = new List <DoseInstruction>
            {
                new DoseInstruction
                {
                    DoseQuantity = new DoseQuantity {
                        Value = 2, Unit = JsonTask.Shared.UnitType.Grams
                    },
                    Frequency = new DoseQuantity {
                        FrequencyType = FrequencyType.None
                    },
                    DoseType  = DoseType.Standard,
                    Emergency = true
                }
            };
            RouteOfAdministration routeOfAdministration = new RouteOfAdministration {
                Route = "By " + testRoute
            };
            RoutesAndPatientGroups routesAndPatientGroup = new RoutesAndPatientGroups
            {
                RoutesOfAdministration = new List <RouteOfAdministration> {
                    routeOfAdministration
                },
                PatientGroups = new List <PatientGroup>()
                {
                    new PatientGroup
                    {
                        Age = new Age {
                            From = 2, FromUnit = JsonTask.Shared.UnitType.Years
                        },
                        DoseStatement = new DoseStatement {
                            DoseInstruction = doseInstructions
                        }
                    }
                }
            };
            IList <RoutesAndPatientGroups> routesAndPatientGroups = new List <RoutesAndPatientGroups> {
                routesAndPatientGroup
            };
            IList <TherapeuticIndications> therapeuticIndications = new List <TherapeuticIndications>
            {
                new TherapeuticIndications {
                    Indication = testIndication
                }
            };
            IList <IndicationAndDoseGroups> indicationAndDoseGroups = new List <IndicationAndDoseGroups>
            {
                new IndicationAndDoseGroups {
                    RoutesAndPatientGroups = routesAndPatientGroups, TherapeuticIndications = therapeuticIndications
                }
            };
            Drug drug = new Drug {
                Name = testName, IndicationsDose = new IndicationsAndDose {
                    IndicationAndDoseGroups = indicationAndDoseGroups
                }
            };

            return(drug);
        }