public static PQMViewModel[] GetObjectives(string constraintPath) { List <string[]> CSVSheet = new List <string[]>(); CSVSheet = parseCSV(constraintPath); //extract header and modify to indicate output values PQMViewModel[] objectives = new PQMViewModel[CSVSheet.Count()]; int i = 0; foreach (string[] line in CSVSheet) { if (line[0] == "") //A blank line is present { continue; } if (line[0] == "Structure IDs") { continue; } objectives[i] = new PQMViewModel(); // Structure ID objectives[i].TemplateId = line[0]; // Structure Code string codes = line[1]; objectives[i].TemplateCodes = (codes.Length > 0) ? ReplaceWhitespace(codes, @"\s+").Split('|') : new string[] { objectives[i].TemplateId }; // Aliases : extract individual aliases using "|" as separator. Ignore whitespaces. If blank, use the ID. string aliases = line[2]; objectives[i].TemplateAliases = (aliases.Length > 0) ? aliases.Split('|') : new string[] { objectives[i].TemplateId }; // DVH Objective objectives[i].DVHObjective = line[4]; // Evaluator objectives[i].Goal = line[5]; objectives[i].Variation = line[6]; objectives[i].Priority = line[7]; objectives[i].Achieved = ""; //find this later objectives[i].Met = ""; //find this later i++; } return(objectives); }
public string CalculateMetricDose(Patient patient, string courseId, string planId, string structureId, PQMViewModel objective) { var plan = Extensions.GetPlanningItem(patient, courseId, planId); var planVM = new PlanningItemViewModel(plan); var structure = Extensions.GetStructure(plan, structureId); DirectoryInfo constraintDir = new DirectoryInfo(Path.Combine(AssemblyHelper.GetAssemblyDirectory(), "ConstraintTemplates")); string firstFileName = constraintDir.GetFiles().FirstOrDefault().ToString(); string firstConstraintFilePath = Path.Combine(constraintDir.ToString(), firstFileName); // make sure the workbook template exists if (!System.IO.File.Exists(firstConstraintFilePath)) { System.Windows.MessageBox.Show(string.Format("The template file '{0}' chosen does not exist.", firstConstraintFilePath)); } var structureVM = new StructureViewModel(structure); string metric = ""; var goal = ""; string result = ""; string variation = ""; if (objective.TemplateId == structureId) { metric = objective.DVHObjective; goal = objective.Goal; variation = objective.Variation; result = _metricCalc.CalculateMetric(planVM.PlanningItemStructureSet, structureVM, planVM, metric); } else { result = ""; } return(result); }
public Task <string> CalculateMetricDoseAsync(string courseId, string planId, string structureId, string metric, PQMViewModel objective) => RunAsync(context => CalculateMetricDose(context.Patient, courseId, planId, structureId, objective));