/**
  * Handle link/unlink patients message
  *
  * @param CHL7Acknowledgment $ack     Acknowledgment
  * @param CPatient           $patient Person
  * @param array              $data    Data
  *
  * @return string|void
  */
 function handle(CHL7Acknowledgment $ack, CPatient $patient, $data)
 {
     $exchange_hl7v2 = $this->_ref_exchange_hl7v2;
     $sender = $exchange_hl7v2->_ref_sender;
     $sender->loadConfigValues();
     $this->_ref_sender = $sender;
     if (count($data["PID"]) != 2) {
         return $exchange_hl7v2->setAckAR($ack, "E500", null, $patient);
     }
     foreach ($data["PID"] as $_PID) {
         $patientPI = CValue::read($_PID['personIdentifiers'], "PI");
         // Acquittement d'erreur : identifiants PI non fournis
         if (!$patientPI) {
             return $exchange_hl7v2->setAckAR($ack, "E100", null, $patient);
         }
     }
     $patient_1_PI = CValue::read($data["PID"][0]['personIdentifiers'], "PI");
     $patient_2_PI = CValue::read($data["PID"][1]['personIdentifiers'], "PI");
     $patient_1 = new CPatient();
     $patient_1->_IPP = $patient_1_PI;
     $patient_1->loadFromIPP($sender->group_id);
     // PI non connu (non fourni ou non retrouvé)
     if (!$patient_1->_id) {
         return $exchange_hl7v2->setAckAR($ack, "E501", null, $patient_1);
     }
     $patient_2 = new CPatient();
     $patient_2->_IPP = $patient_2_PI;
     $patient_2->loadFromIPP($sender->group_id);
     // PI non connu (non fourni ou non retrouvé)
     if (!$patient_2->_id) {
         return $exchange_hl7v2->setAckAR($ack, "E501", null, $patient_2);
     }
     $function_handle = "handle{$exchange_hl7v2->code}";
     if (!method_exists($this, $function_handle)) {
         return $exchange_hl7v2->setAckAR($ack, "E006", null, $patient);
     }
     return $this->{$function_handle}($ack, $patient_1, $patient_2, $data);
 }
Ejemplo n.º 2
0
/**
 * import the patient file
 *
 * @param string   $file        path to the file
 * @param int      $start       start int
 * @param int      $count       number of iterations
 * @param resource $file_import file for report
 *
 * @return null
 */
function importFile($file, $start, $count, $file_import)
{
    $fp = fopen($file, 'r');
    $csv_file = new CCSVFile($fp);
    $csv_file->column_names = $csv_file->readLine();
    if ($start == 0) {
        $start++;
    } elseif ($start > 1) {
        $csv_file->jumpLine($start);
    }
    $group_id = CGroups::loadCurrent()->_id;
    $treated_line = 0;
    while ($treated_line < $count) {
        $treated_line++;
        $patient = new CPatient();
        $_patient = $csv_file->readLine(true);
        if (!$_patient) {
            CAppUI::stepAjax('Importation terminée', UI_MSG_OK);
            CApp::rip();
        }
        $patient->bind($_patient);
        $patient->loadFromIPP($group_id);
        if ($patient->_id) {
            $start++;
            continue;
        }
        $nom = $_patient['nom'] ? $_patient['nom'] : $_patient['nom_jeune_fille'];
        if (!$patient->nom) {
            if ($patient->nom_jeune_fille) {
                $patient->nom = $patient->nom_jeune_fille;
            } else {
                CMbDebug::log("Ligne #{$start} : Pas de nom");
                $start++;
                continue;
            }
        }
        $naissance = null;
        if ($patient->naissance) {
            $naissance = preg_replace('/(\\d{2})\\/(\\d{2})\\/(\\d{4})/', '\\3-\\2-\\1', $patient->naissance);
            $patient->naissance = $naissance;
        }
        $patient->repair();
        if (!$patient->naissance) {
            CMbDebug::log($_patient);
            CMbDebug::log("Ligne #{$start} : Date de naissance invalide ({$_patient['naissance']})");
            $start++;
            continue;
        }
        $patient->loadMatchingPatient();
        if (!$patient->_id) {
            $patient->bind($_patient);
            $patient->nom = $nom;
            $patient->naissance = $naissance;
            $patient->tel = preg_replace("/[^0-9]/", "", $patient->tel);
            $patient->tel_autre = preg_replace("/[^0-9]/", "", $patient->tel_autre);
            $patient->sexe = strtolower($patient->sexe);
            $patient->repair();
            if ($msg = $patient->store()) {
                CMbDebug::log($patient, null, true);
                CMbDebug::log("Ligne #{$start} :{$msg}");
                $start++;
                continue;
            }
        }
        $ipp = CIdSante400::getMatch($patient->_class, CPatient::getTagIPP($group_id), $patient->_IPP, $patient->_id);
        if ($ipp->_id && $ipp->id400 != $patient->_IPP) {
            CMbDebug::log("Ligne #{$start} : Ce patient possède déjà un IPP ({$ipp->id400})");
            $start++;
            continue;
        }
        if (!$ipp->_id) {
            if ($msg = $ipp->store()) {
                CMbDebug::log("Ligne #{$start} :{$msg}");
                $start++;
                continue;
            }
        }
        CAppUI::setMsg('CPatient-msg-create', UI_MSG_OK);
    }
    echo CAppUI::getMsg();
}
        $patient_prenom = $patVitale->prenom;
        CValue::setSession("nom", $patVitale->nom);
        CValue::setSession("prenom", $patVitale->prenom);
        $cv->loadFromIdVitale($patVitale);
    }
}
// Recherhche par IPP
if ($patient_ipp && !$useVitale && CModule::getInstalled("dPsante400")) {
    // Initialisation dans le cas d'une recherche par IPP
    $patients = array();
    $patientsSoundex = array();
    $patientsCount = 0;
    $patientsSoundexCount = 0;
    $patient = new CPatient();
    $patient->_IPP = $patient_ipp;
    $patient->loadFromIPP();
    if ($patient->_id) {
        CValue::setSession("patient_id", $patient->_id);
        $patients[$patient->_id] = $patient;
    }
} else {
    $where = array();
    $whereSoundex = array();
    $ljoin = array();
    $soundexObj = new soundex2();
    // Limitation du nombre de caractères
    $patient_nom_search = trim($patient_nom);
    $patient_prenom_search = trim($patient_prenom);
    if ($limit_char_search = CAppUI::conf("dPpatients CPatient limit_char_search")) {
        $patient_nom_search = substr($patient_nom_search, 0, $limit_char_search);
        $patient_prenom_search = substr($patient_prenom_search, 0, $limit_char_search);