コード例 #1
0
 function delete($id = null)
 {
     if (!$id) {
         $this->Session->setFlash(__('Invalid id for Operatingsystem', true));
         $this->redirect(array('action' => 'index'));
     }
     if ($this->Operatingsystem->del($id)) {
         $combination = new Combination();
         $all_com = $combination->find('all', array('conditions' => array('Combination.operatingsystem_id' => $id)));
         foreach ($all_com as $key => $value) {
             $this->Operatingsystem->Combination->del($value['Combination']['id']);
         }
         $this->Session->setFlash(__('Operatingsystem deleted', true));
         $this->redirect(array('action' => 'index'));
     }
 }
コード例 #2
0
 /**
  * Get the value for a core parameter, i.e. one that is not associated
  * with a specific Simulation (including those associated with the
  * choice and type of needles, as this is also specific to a Simulation)
  *
  * @param string $id Combination for which we wish to find a core parameter
  * @param string $name Parameter name to be retrieved
  * @return string Textual representation of value
  */
 public function retrieveParameter($id, $name)
 {
     $combination = Combination::find($id);
     if (empty($combination)) {
         return ["error" => "Combination not found"];
     }
     $parameter = $combination->retrieveParameter($name);
     if ($parameter) {
         return $parameter->Value;
     }
     return null;
 }
コード例 #3
0
 public static function fromXml($xml)
 {
     $xpath = new DOMXpath($xml);
     $simulation = new static();
     $simulationNode = $xpath->query('//simulationDefinition/simulation')->item(0);
     $simulation->Id = strtoupper($simulationNode->getAttribute('id'));
     $simulationAttributes = ['Caption', 'SegmentationType', 'Progress', 'State', 'Color', 'Active'];
     foreach ($simulationAttributes as $simulationAttribute) {
         $simulation->{$simulationAttribute} = $simulationNode->getAttribute(strtolower($simulationAttribute));
     }
     //if (Simulation::find($simulation->Id))
     //  return [false, "Simulation with this ID already exists"];
     $simulationNeedle = [];
     $combination = Combination::find($xpath->query('//simulationDefinition/combination/@id')->item(0)->value);
     if (!$combination) {
         throw new Exception("Cannot find combination (you may be able to work around this manually from the XML)");
     }
     $patient = DB::table('ItemSet_Patient')->where('Id', '=', $xpath->query('//simulationDefinition/simulation/patient/@id')->item(0)->value)->get();
     if (empty($patient)) {
         throw new Exception("Patient no longer exists");
     }
     $patient = $patient[0];
     $simulation->Combination_Id = $combination->Combination_Id;
     $simulation->Patient_Id = $patient->Id;
     $simulation->Id = null;
     $simulation->save();
     $parameterNodes = $xpath->query('//simulationDefinition/parameters/parameter');
     $parameters = [];
     foreach ($parameterNodes as $parameterNode) {
         $parameter = Parameter::whereName($parameterNode->getAttribute("name"))->first();
         $simulation->Parameters()->attach($parameter, ["ValueSet" => $parameterNode->getAttribute("value")]);
     }
     $needleNodes = $xpath->query('//simulationDefinition/numericalModel/needles/needle');
     foreach ($needleNodes as $needleNode) {
         $needle = Needle::find($needleNode->getAttribute("id"));
         if (!$needle) {
             throw new Exception("Needle not found");
         }
         $simulationNeedle = new SimulationNeedle();
         $simulationNeedle->Needle_Id = $needle->Id;
         $simulationNeedle->Simulation_Id = $simulation->Id;
         $simulationNeedle->save();
         $parameterNodes = $xpath->query('//simulationDefinition/numericalModel/needles/needle/parameters/parameter');
         $parameters = [];
         foreach ($parameterNodes as $parameterNode) {
             $parameter = Parameter::whereName($parameterNode->getAttribute("name"))->first();
             switch ($parameter->Name) {
                 case "NEEDLE_TIP_LOCATION":
                     $target = PointSet::fromArray(json_decode($parameterNode->getAttribute("value")));
                     $target->save();
                     $simulationNeedle->Target_Id = $target->Id;
                     break;
                 case "NEEDLE_ENTRY_LOCATION":
                     $entry = PointSet::fromArray(json_decode($parameterNode->getAttribute("value")));
                     $entry->save();
                     $simulationNeedle->Entry_Id = $entry->Id;
                     break;
                 default:
                     $simulationNeedle->Parameters()->attach($parameter, ["ValueSet" => $parameterNode->getAttribute("value")]);
             }
         }
         $simulationNeedle->save();
     }
     //foreach ($parameters as $sP)
     //{
     //  $sP->Simulation_Id = $simulation->Id;
     //  $sP->save();
     //}
     $simulation->save();
     return $simulation;
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $combination = Combination::find(Input::get('Combination_Id'));
     if (Config::get('gosmart.integrated_patient_database')) {
         $patient = DB::table('ItemSet_Patient')->whereId(Input::get('Patient_Id'))->first();
     }
     $caption = Input::get('caption');
     $incompatibilities = [];
     $userRequiredParameters = [];
     list($parameters, $needleParameters) = $combination->compileParameters(new Collection(), [], new Collection(), $incompatibilities, $userRequiredParameters);
     $simulation = new Simulation();
     $simulation->Combination_Id = $combination->Combination_Id;
     $simulation->Patient_Id = $patient->Id;
     $simulation->Caption = 'N: ' . $caption;
     $simulation->SegmentationType = 0;
     $simulation->Progress = '0';
     $simulation->State = 0;
     $simulation->Color = 0;
     $simulation->Active = 0;
     $simulation->save();
     foreach ($parameters as $parameter) {
         $simulation->parameters()->attach($parameter, ['ValueSet' => $parameter->Value]);
     }
     return Redirect::route('simulation.edit', $simulation->Id);
 }