Ejemplo n.º 1
0
        public static void GeneratePlan(VMS.TPS.Common.Model.API.Application app,
                                        MLCDefinitions mlcs,
                                        ExternalBeamMachineParameters beamPars,
                                        IMRTGenerator.JSON.Patient patient,
                                        IEnumerable <IMRTGenerator.JSON.Beam> beams
                                        )
        {
            var pat  = app.OpenPatientById(patient.PatientId);
            var sSet = pat.StructureSets.Single(ss => ss.Id == patient.StructureSet);

            pat.BeginModifications();

            var cr = pat.Courses.SingleOrDefault(cr_ => cr_.Id == "DTPCOURSE");

            if (null == cr)
            {
                cr    = pat.AddCourse();
                cr.Id = "DTPCOURSE";
            }
            var plan = cr.AddExternalPlanSetup(sSet);
            //
            // Cannot use target structure
            //
            var targetStructure = sSet.Structures.Single(s => s.Id == plan.TargetVolumeID);
            var isoCenter       = targetStructure.CenterPoint;

            foreach (var bm in beams)
            {
                var beam = plan.AddMLCBeam(beamPars, null, default(VRect <double>), 0.0, bm.GantryAngleInDeg, bm.PatientSupportAngleInDeg, isoCenter);
                beam.FitMLCToStructure(new FitToStructureMargins(bm.MlcMarginInmm),
                                       targetStructure,
                                       true,
                                       JawFitting.FitToRecommended,
                                       OpenLeavesMeetingPoint.OpenLeavesMeetingPoint_Middle,
                                       ClosedLeavesMeetingPoint.ClosedLeavesMeetingPoint_Center);
                adjustJaws(beam, bm.BeamletSizeXInmm, mlcs.MLCs[beam.MLC.Id].LeafWidths());
            }
            if (null == calcModel)
            {
                calcModel = plan.GetModelsForCalculationType(CalculationType.PhotonInfluenceMatrix)?.OrderByDescending(cm => cm, new ModelNameComparer()).First();
                calcModel = calcModel == null ? "" : calcModel;
            }
            plan.SetCalculationModel(CalculationType.PhotonInfluenceMatrix, calcModel);
            app.SaveModifications();
        }
Ejemplo n.º 2
0
        /*public PlanSetup abrirPlan(Course curso, string nombrePlan)
         * {
         *  return curso.PlanSetups.Where(p => p.Id == nombrePlan).FirstOrDefault();
         * }*/

        public string salvarPaciente()
        {
            app.SaveModifications();
            return("Se ha guardado el plan");
        }