Exemplo n.º 1
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();
}
    if ($IPP->_id) {
        $_patient->patient_id = $IPP->object_id;
        $_patient->store();
        $echg_hprim->object_class = $IPP->object_class;
        $echg_hprim->object_id = $IPP->object_id;
        $echg_hprim->id_permanent = $IPP->id400;
        $echg_hprim->store();
        $anc++;
        continue;
    }
    // Sinon rattachement à un patient existant
    $patient = new CPatient();
    $patient->nom = $_patient->nom;
    $patient->prenom = $_patient->prenom;
    $patient->naissance = $_patient->naissance;
    $return = $patient->loadMatchingPatient();
    if ($return == 1) {
        $IPP->object_id = $patient->_id;
        $IPP->last_update = CMbDT::dateTime();
        $IPP->store();
        $_patient->patient_id = $patient->_id;
        $_patient->store();
        $echg_hprim->object_class = $IPP->object_class;
        $echg_hprim->object_id = $IPP->object_id;
        $echg_hprim->id_permanent = $IPP->id400;
        $echg_hprim->store();
        $nouv++;
    }
}
CAppUI::stepAjax("Patient utilisés : '{$total}'");
CAppUI::stepAjax("Patient anciennement rapprochés : '{$anc}'");
Exemplo n.º 3
0
//find a patient
$patient = new CPatient();
//IPP Case
if ($ipp) {
    $patient->_IPP = $ipp;
    $patient->loadFromIPP();
    if ($patient->_id) {
        $nbpatients = 1;
    }
}
//global case
if (!$nbpatients) {
    $patient->nom = $nom;
    $patient->prenom = $prenom;
    $patient->naissance = $date_naiss;
    $patient->loadMatchingPatient();
}
//-----------------------------------------------------------------
//Sejour
$sejour = new CSejour();
if ($mods_available[$view][2] == 'sejour') {
    if ($nda) {
        $sejour->loadFromNDA($nda);
    } elseif ($patient->_id) {
        if (!$date_sejour) {
            CAppUI::stepAjax("context-sejour-patientOK-date-required", UI_MSG_ERROR, $view);
        }
        $date_sejour = CMbDT::dateTime($date_sejour);
        $where = array();
        $where[] = "'{$date_sejour}' BETWEEN entree AND sortie";
        $where["patient_id"] = " = '{$patient->_id}'";
Exemplo n.º 4
0
 /**
  * return a patient following db data
  *
  * @return CPatient $patient
  */
 function loadPatientByData()
 {
     $patient = new CPatient();
     $patient->nom = $this->patient_lastname;
     $patient->prenom = $this->patient_firstname;
     $patient->naissance = $this->patient_birthdate;
     $patient->loadMatchingPatient();
     return $patient;
 }
 /**
  * get the patient
  *
  * @param String  $identifier identifier
  * @param DOMNode $node       node
  *
  * @return CPatient
  */
 function getPatient($identifier, $node)
 {
     $sender = $this->_ref_sender;
     $idex = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $identifier);
     $patient = new CPatient();
     if ($idex->_id) {
         return $patient->load($idex->object_id);
     }
     $person = $this->getNamePerson($node);
     $patient->nom = $person["name"];
     $patient->prenom = $person["firstname"];
     $patient->naissance = $this->getBirthdate($node);
     $patient->loadMatchingPatient();
     return $patient;
 }