/**
  * Get bascule HL7 event code
  *
  * @param CSejour $from Admit from
  * @param CSejour $to   Admit to
  *
  * @return string
  */
 function getBasculeCode(CSejour $from, CSejour $to)
 {
     $matrix = array("comp/M" => array(null, "Z99", "Z99", "Z99", "Z99", "A07", "Z99", "A07"), "comp/C" => array("Z99", null, "Z99", "Z99", "Z99", "A07", "Z99", "A07"), "comp/O" => array("Z99", "Z99", null, "Z99", "Z99", "A07", "Z99", "A07"), "bebe/*" => array("A06", "A06", "A06", null, "A06", "A07", "A06", "A07"), "ambu/*" => array("Z99", "Z99", "Z99", "Z99", null, "A07", "Z99", "A07"), "urg/*" => array("A06", "A06", "A06", "A06", "A06", null, "A06", "Z99"), "seances/*" => array("Z99", "Z99", "Z99", "Z99", "Z99", "A07", null, "A07"), "exte/*" => array("A06", "A06", "A06", "A06", "A06", "Z99", "A06", null));
     $from->completeField("type", "type_pec");
     $type_from = $from->type;
     $type_pec_from = $from->type_pec;
     $to->completeField("type", "type_pec");
     $type_to = $to->type;
     $type_pec_to = $to->type_pec;
     // psy || ssr == seances
     if (in_array($type_from, array("psy", "ssr"))) {
         $type_from = "seances";
     }
     if (in_array($type_to, array("psy", "ssr"))) {
         $type_to = "seances";
     }
     /* // TODO prendre en compte les sejours de type nouveau né
        $naissances = $from->loadRefsNaissances();
        foreach ($naissances as $_naissance) {
          if ($naissances->sejour_bebe_id == $from->_id) {
            $type_from = "bebe";
            break;
          }
        }*/
     $row = CMbArray::first($matrix, array("{$type_from}/{$type_pec_from}", "{$type_from}/*"));
     if (!$row) {
         return $this->getModificationAdmitCode($from->_receiver);
     }
     $columns = array_flip(array_keys($matrix));
     $col_num = CMbArray::first($columns, array("{$type_to}/{$type_pec_to}", "{$type_to}/*"));
     if ($columns === null) {
         return $this->getModificationAdmitCode($from->_receiver);
     }
     if ($row[$col_num] == "Z99") {
         return $this->getModificationAdmitCode($from->_receiver);
     }
     return $row[$col_num];
 }
Example #2
0
 public function testFirst()
 {
     $this->assertEquals("val1", $this->stub->first(array("key1" => "val1", "key2" => "val2", "key3" => "val3"), array("key1", "key2")));
     $this->assertNull($this->stub->first(array("val"), array("notAkey")));
 }