コード例 #1
0
 /**
  * Fill other identifiers
  *
  * @param array       &$data Datas
  * @param array       $ufs   UF
  * @param CHL7v2Event $event Event
  *
  * @return null
  */
 function fillOtherSegments(&$data, $ufs = array(), CHL7v2Event $event)
 {
     // ZBE-8: Ward of care responsibility in the period starting with this movement (XON) (optional)
     $uf_type = $event->_receiver->_configs["build_ZBE_8"];
     /** @var CUniteFonctionnelle $uf_soins */
     $uf_soins = isset($ufs[$uf_type]) ? $ufs[$uf_type] : null;
     if (isset($uf_soins->_id)) {
         $data[] = array(array($uf_soins->libelle, null, null, null, null, $this->getAssigningAuthority("mediboard"), "UF", null, null, $uf_soins->code));
     } else {
         $data[] = null;
     }
     // ZBE-9: Nature of this movement (CWE)
     // S - Changement de responsabilité de soins uniquement
     // H - Changement de  responsabilité  d'hébergement  soins uniquement
     // M - Changement de responsabilité médicale uniquement
     // L - Changement de lit uniquement
     // D - Changement de prise en charge médico-administrative laissant les responsabilités et la localisation du patient inchangées
     //     (ex : changement de tarif du séjour en unité de soins)
     // SM - Changement de responsabilité soins + médicale
     // SH - Changement de responsabilité soins + hébergement
     // MH - Changement de responsabilité hébergement + médicale
     // LD - Changement de prise en charge médico-administrative et de lit, laissant les responsabilités inchangées
     // HMS - Changement conjoint des trois responsabilités.
     /* @todo Voir comment gérer ceci... */
     // Changement d'UF médicale
     if (CMbArray::in($event->code, "Z80 Z81 Z82 Z83")) {
         $data[] = "M";
     } elseif (CMbArray::in($event->code, "Z84 Z85 Z86 Z87")) {
         $data[] = "S";
     } else {
         $data[] = "HMS";
     }
 }
コード例 #2
0
ファイル: CMbArrayTest.php プロジェクト: fbone/mediboard4
 public function testIn()
 {
     $this->assertTrue($this->stub->in("val1", array("key1" => "val1", "key2" => "val2")));
     $this->assertFalse($this->stub->in("notAval", array("key1" => "val1", "key2" => "val2")));
     $this->assertTrue($this->stub->in("val2", array("key1" => "val1", "key2" => "val2"), true));
     $this->assertFalse($this->stub->in("2", array("key1" => 1, "key2" => 2), true));
     $this->assertTrue($this->stub->in("val2", "val1 val2 val3", true));
 }
コード例 #3
0
 /**
  * Mapping et enregistrement de l'affectation
  *
  * @param CSejour   $newVenue Admit
  * @param array     $data     Datas
  * @param CMovement $movement Movement
  *
  * @return CAffectation|string|null
  */
 function mapAndStoreAffectation(CSejour $newVenue, $data, CMovement $movement = null)
 {
     $sender = $this->_ref_sender;
     if ($newVenue->annule) {
         return null;
     }
     $PV1_3 = $this->queryNode("PV1.3", $data["PV1"]);
     $affectation = new CAffectation();
     $affectation->sejour_id = $newVenue->_id;
     $event_code = $this->_ref_exchange_hl7v2->code;
     // Récupération de la date de réalisation de l'évènement
     // Dans le cas spécifique de quelques évènements, on récupère le code sur le ZBE
     $datetime = $this->queryTextNode("EVN.6/TS.1", $data["EVN"]);
     if (array_key_exists("ZBE", $data) && $data["ZBE"] && CMbArray::in($event_code, array("A01", "A02", "A04", "A15", "Z80", "Z84"))) {
         $datetime = $this->queryTextNode("ZBE.2/TS.1", $data["ZBE"]);
     }
     switch ($event_code) {
         // Cas d'une suppression de mutation ou d'une permission d'absence
         case "A12":
         case "A52":
             // Quand on a un mouvement (provenant d'un ZBE)
             if (array_key_exists("ZBE", $data) && $data["ZBE"]) {
                 if (!$movement) {
                     return null;
                 }
                 $affectation->load($movement->affectation_id);
                 if (!$affectation->_id) {
                     return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard";
                 }
             } else {
                 $affectation->entree = $datetime;
                 $affectation->loadMatchingObject();
                 if (!$affectation->_id) {
                     return null;
                 }
             }
             // Pas de synchronisation
             $affectation->_no_synchro = true;
             if ($msgAffectation = $affectation->delete()) {
                 return $msgAffectation;
             }
             return null;
             // Annulation admission
         // Annulation admission
         case "A11":
             if (!$movement) {
                 return null;
             }
             $affectation = $newVenue->getCurrAffectation($datetime);
             // Si le mouvement n'a pas d'affectation associée, et que l'on a déjà une affectation dans MB
             if (!$movement->affectation_id && $affectation->_id) {
                 return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard";
             }
             // Si on a une affectation associée, alors on charge celle-ci
             if ($movement->affectation_id) {
                 $affectation = $movement->loadRefAffectation();
             }
             // Pas de synchronisation
             $affectation->_no_synchro = true;
             if ($msg = $affectation->delete()) {
                 return $msg;
             }
             return null;
             // Annuler le retour du patient
         // Annuler le retour du patient
         case "A53":
             if (!$movement) {
                 return null;
             }
             $affectation->load($movement->affectation_id);
             if (!$affectation->_id) {
                 return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard";
             }
             $affectation->effectue = 0;
             // Pas de synchronisation
             $affectation->_no_synchro = true;
             $affectation->_eai_sender_guid = $sender->_guid;
             if ($msg = $affectation->store()) {
                 return $msg;
             }
             return $affectation;
             // Cas d'un départ pour une permission d'absence
         // Cas d'un départ pour une permission d'absence
         case "A21":
             $affectation->entree = $datetime;
             $affectation->loadMatchingObject();
             // Si on ne retrouve pas une affectation
             // Création de l'affectation
             // et mettre à 'effectuee' la précédente si elle existe sinon création de celle-ci
             if (!$affectation->_id) {
                 $service_externe = CService::loadServiceExterne($sender->group_id);
                 if (!$service_externe->_id) {
                     return "CService-externe-none";
                 }
                 $affectation->service_id = $service_externe->_id;
                 $return_affectation = $newVenue->forceAffectation($affectation, true);
                 //$datetime, $affectation->lit_id, $affectation->service_id);
                 if (is_string($return_affectation)) {
                     return $return_affectation;
                 }
                 $affectation = $return_affectation;
             }
             return $affectation;
             // Cas d'un retour pour une permission d'absence
         // Cas d'un retour pour une permission d'absence
         case "A22":
             $service_externe = CService::loadServiceExterne($sender->group_id);
             if (!$service_externe->_id) {
                 return "CService-externe-none";
             }
             // Recherche de l'affectation correspondant à une permission d'absence
             $search = new CAffectation();
             $where = array();
             $where["sejour_id"] = "=  '{$newVenue->_id}'";
             $where["service_id"] = "=  '{$service_externe->_id}'";
             $where["effectue"] = "=  '0'";
             $where["entree"] = "<= '{$datetime}'";
             $where["sortie"] = ">= '{$datetime}'";
             $search->loadObject($where);
             // Si on ne la retrouve pas on prend la plus proche
             if (!$search->_id) {
                 $where = array();
                 $where["sejour_id"] = "=  '{$newVenue->_id}'";
                 $where["service_id"] = "=  '{$service_externe->_id}'";
                 $where["effectue"] = "=  '0'";
                 $search->loadObject($where);
             }
             $search->effectue = 1;
             $search->sortie = $datetime;
             $search->_eai_sender_guid = $sender->_guid;
             if ($msg = $search->store()) {
                 return $msg;
             }
             return $search;
             // Cas mutation
         // Cas mutation
         case "A02":
             $affectation->entree = $datetime;
             $affectation->loadMatchingObject();
             // Si on ne retrouve pas une affectation
             // Création de l'affectation
             // et mettre à 'effectuee' la précédente si elle existe sinon création de celle-ci
             if (!$affectation->_id) {
                 // Récupération du Lit et UFs
                 $this->getPL($PV1_3, $affectation, $newVenue);
                 $return_affectation = $newVenue->forceAffectation($affectation, true);
                 //$datetime, $affectation->lit_id, $affectation->service_id);
                 if (is_string($return_affectation)) {
                     return $return_affectation;
                 }
                 $affectation = $return_affectation;
             }
             break;
             // Cas modification
         // Cas modification
         case "Z99":
             if (!$movement) {
                 return null;
             }
             // Si on a une affectation associée, alors on charge celle-ci
             if ($movement->affectation_id) {
                 $affectation = $movement->loadRefAffectation();
             } else {
                 // On recherche l'affectation "courante"
                 // Si qu'une affectation sur le séjour
                 $newVenue->loadRefsAffectations();
                 if (count($newVenue->_ref_affectations) == 1) {
                     $affectation = reset($newVenue->_ref_affectations);
                 } else {
                     // On recherche l'affectation "courante"
                     $affectation = $newVenue->getCurrAffectation($datetime);
                 }
                 // Sinon on récupère et on met à jour la première affectation
                 if (!$affectation->_id) {
                     $affectation->sejour_id = $newVenue->_id;
                     $affectation->entree = $newVenue->entree;
                     $affectation->sortie = $newVenue->sortie;
                 }
             }
             break;
             // Tous les autres cas on récupère et on met à jour la première affectation
         // Tous les autres cas on récupère et on met à jour la première affectation
         default:
             $newVenue->loadRefsAffectations();
             $affectation = $newVenue->_ref_first_affectation;
             if (!$affectation->_id) {
                 $affectation->sejour_id = $newVenue->_id;
                 $affectation->entree = $newVenue->entree;
                 $affectation->sortie = $newVenue->sortie;
             }
     }
     // Si pas d'UF/service/chambre/lit on retourne une affectation vide
     if (!$PV1_3) {
         if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) {
             return $msgVenue;
         }
         return $affectation;
     }
     if ($this->queryTextNode("PL.1", $PV1_3) == $sender->_configs["handle_PV1_3_null"]) {
         if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) {
             return $msgVenue;
         }
         return $affectation;
     }
     // Si pas de lit on affecte le service sur le séjour
     if (!$this->queryTextNode("PL.3", $PV1_3)) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         // On essaye de récupérer le service dans ce cas depuis l'UF d'hébergement
         $date_deb = $affectation->_id ? CMbDT::date($affectation->sortie) : CMbDT::date($newVenue->sortie);
         $date_fin = $affectation->_id ? CMbDT::date($affectation->entree) : CMbDT::date($newVenue->entree);
         $uf = CUniteFonctionnelle::getUF($this->queryTextNode("PL.1", $PV1_3), "hebergement", $newVenue->group_id, $date_deb, $date_fin);
         if ($uf->code && $uf->_id) {
             $affectation_uf->uf_id = $uf->_id;
             $affectation_uf->object_class = "CService";
             $affectation_uf->loadMatchingObject();
         }
         // Dans le cas où l'on retrouve un service associé à l'UF d'hébergement
         if ($affectation_uf->_id) {
             $newVenue->service_id = $affectation_uf->object_id;
             $newVenue->uf_hebergement_id = $affectation_uf->uf_id;
         }
         $uf_med = $this->mappingUFMedicale($data, $newVenue, $affectation);
         $newVenue->uf_medicale_id = $uf_med ? $uf_med->_id : null;
         $uf_soins = $this->mappingUFSoins($data, $newVenue, $affectation);
         $newVenue->uf_soins_id = $uf_soins ? $uf_soins->_id : null;
         // On ne check pas la cohérence des dates des consults/intervs
         $newVenue->_skip_date_consistencies = true;
         $newVenue->_eai_sender_guid = $sender->_guid;
         if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) {
             return $msgVenue;
         }
         // Si on a pas d'UF on retourne une affectation vide
         if (!$uf->_id || !$affectation_uf->_id) {
             return $affectation;
         }
     }
     // Récupération du Lit et UFs
     $this->getPL($PV1_3, $affectation, $newVenue);
     $uf_med = $this->mappingUFMedicale($data, $newVenue, $affectation);
     $affectation->uf_medicale_id = $uf_med ? $uf_med->_id : null;
     $uf_soins = $this->mappingUFSoins($data, $newVenue, $affectation);
     $affectation->uf_soins_id = $uf_soins ? $uf_soins->_id : null;
     $affectation->_eai_sender_guid = $sender->_guid;
     if ($msg = $affectation->store()) {
         return $msg;
     }
     return $affectation;
 }
コード例 #4
0
 /**
  * Get event
  *
  * @param string $event_name Event name
  * @param string $encoding   Encoding
  *
  * @return CHL7v2MessageXML
  */
 static function getEventType($event_name = null, $encoding = "utf-8")
 {
     if (!$event_name) {
         return new CHL7v2MessageXML($encoding);
     }
     list($event_type, $event_code) = str_split($event_name, strlen("CHL7vXEventXXX"));
     $event_code = substr($event_code, 0, 3);
     if ($event_type == "CHL7v2EventADT") {
         // Création d'un nouveau patient - Mise à jour d'information du patient
         if (CMbArray::in($event_code, CHL7v2RecordPerson::$event_codes)) {
             return new CHL7v2RecordPerson($encoding);
         }
         // Fusion de deux patients
         if (CMbArray::in($event_code, CHL7v2MergePersons::$event_codes)) {
             return new CHL7v2MergePersons($encoding);
         }
         // Changement de la liste d'identifiants du patient
         if (CMbArray::in($event_code, CHL7v2ChangePatientIdentifierList::$event_codes)) {
             return new CHL7v2ChangePatientIdentifierList($encoding);
         }
         // Création d'une venue - Mise à jour d'information de la venue
         if (CMbArray::in($event_code, CHL7v2RecordAdmit::$event_codes)) {
             return new CHL7v2RecordAdmit($encoding);
         }
         // Changement du patient par un autre
         if (CMbArray::in($event_code, CHL7v2MoveAccountInformation::$event_codes)) {
             return new CHL7v2MoveAccountInformation($encoding);
         }
         // Association / Déssociation
         if (CMbArray::in($event_code, CHL7v2LinkUnlink::$event_codes)) {
             return new CHL7v2LinkUnlink($encoding);
         }
     }
     // Création des résultats d'observations
     if ($event_type == "CHL7v2EventORU") {
         return new CHL7v2RecordObservationResultSet($encoding);
     }
     // Création des consultations
     if ($event_type == "CHL7v2EventSIU") {
         return new CHL7v2RecordAppointment($encoding);
     }
     // Récupération des résultats du PDQ
     if ($event_type == "CHL7v2EventQBP") {
         // Analyse d'une réponse reçu après une requête
         if (CMbArray::in($event_code, CHL7v2ReceivePatientDemographicsResponse::$event_codes)) {
             return new CHL7v2ReceivePatientDemographicsResponse($encoding);
         }
         // Produire une réponse sur une requête
         if (CMbArray::in($event_code, CHL7v2GeneratePatientDemographicsResponse::$event_codes)) {
             return new CHL7v2GeneratePatientDemographicsResponse($encoding);
         }
     }
     // Récupération des résultats du QCN
     if ($event_type == "CHL7v2EventQCN") {
         // Suppression d'une requête
         if (CMbArray::in($event_code, CHL7v2CancelPatientDemographicsQuery::$event_codes)) {
             return new CHL7v2CancelPatientDemographicsQuery($encoding);
         }
     }
     if ($event_type == "CHL7v2EventORM") {
         // Analyse d'une réponse reçu après une requête
         if (CMbArray::in($event_code, CHL7v2ReceiveOrderMessage::$event_codes)) {
             return new CHL7v2ReceiveOrderMessage($encoding);
         }
     }
     return new CHL7v2MessageXML($encoding);
 }
コード例 #5
0
 /**
  * OBX Segment with reference pointer to external report
  *
  * @param DOMNode   $OBX    DOM node
  * @param CMbObject $object object
  * @param String    $name   name
  *
  * @return bool
  */
 function getReferencePointerToExternalReport(DOMNode $OBX, CMbObject $object, $name)
 {
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $sender = $exchange_hl7v2->_ref_sender;
     //Récupération de l'emplacement et du type du fichier (full path)
     $observation = $this->getObservationValue($OBX);
     $rp = explode("^", $observation);
     $pointer = CMbArray::get($rp, 0);
     $type = CMbArray::get($rp, 2);
     // Création d'un lien Hypertext sur l'objet
     if ($type == "HTML") {
         $hyperlink = new CHyperTextLink();
         $hyperlink->setObject($object);
         $hyperlink->name = $name;
         $hyperlink->link = $pointer;
         $hyperlink->loadMatchingObject();
         if ($msg = $hyperlink->store()) {
             $this->codes[] = "E343";
             return false;
         }
         return true;
     }
     // Chargement des objets associés à l'expéditeur
     /** @var CInteropSender $sender_link */
     $object_links = $sender->loadRefsObjectLinks();
     if (!$object_links) {
         $this->codes[] = "E340";
         return false;
     }
     $sender_link = new CInteropSender();
     $files_category = new CFilesCategory();
     // On récupère toujours une seule catégorie, et une seule source associée à l'expéditeur
     foreach ($object_links as $_object_link) {
         if ($_object_link->_ref_object instanceof CFilesCategory) {
             $files_category = $_object_link->_ref_object;
         }
         if ($_object_link->_ref_object instanceof CInteropSender) {
             $sender_link = $_object_link->_ref_object;
             continue 1;
         }
     }
     // Aucun expéditeur permettant de récupérer les fichiers
     if (!$sender_link->_id) {
         $this->codes[] = "E340";
         return false;
     }
     $authorized_sources = array("CSenderFileSystem", "CSenderFTP");
     // L'expéditeur n'est pas prise en charge pour la réception de fichiers
     if (!CMbArray::in($sender_link->_class, $authorized_sources)) {
         $this->codes[] = "E341";
         return false;
     }
     $sender_link->loadRefsExchangesSources();
     // Aucune source permettant de récupérer les fichiers
     if (!$sender_link->_id) {
         $this->codes[] = "E342";
         return false;
     }
     $source = $sender_link->getFirstExchangesSources();
     $path = str_replace("\\", "/", $pointer);
     $path = basename($path);
     if ($source instanceof CSourceFileSystem) {
         $path = $source->getFullPath() . "/{$path}";
     }
     // Exception déclenchée sur la lecture du fichier
     try {
         $content = $source->getData("{$path}");
     } catch (Exception $e) {
         $this->codes[] = "E345";
         return false;
     }
     if (!$type) {
         $type = CMbPath::getExtension($path);
     }
     $file_type = $this->getFileType($type);
     $file_name = $this->getObservationFilename($OBX);
     // Gestion du CFile
     $file = new CFile();
     $file->setObject($object);
     $file->file_name = $file_name ? $file_name : $name;
     $file->file_type = $file_type;
     $file->loadMatchingObject();
     if ($files_category->_id && $sender->_configs["associate_category_to_a_file"]) {
         $file->file_category_id = $files_category->_id;
     }
     $file->file_date = "now";
     $file->doc_size = strlen($content);
     $file->fillFields();
     $file->updateFormFields();
     $file->putContent($content);
     if ($msg = $file->store()) {
         $this->codes[] = "E343";
     }
     $this->codes[] = "I340";
     return true;
 }