function getName($place) { if ($place === 1) { $names = getFirstNames(); } else { $names = getLastNames(); } return $names[array_rand($names)]; }
$PID = $xml->queryNode("PID"); $PV1 = $xml->queryNode("PV1"); $PV2 = $xml->queryNode("PV2"); $ZBE = $xml->queryNode("ZBE"); $IPP = $NDA = null; $data = array(); $data["personIdentifiers"] = $xml->getPersonIdentifiers("PID.3", $PID, $actor); $data["admitIdentifiers"] = $xml->getAdmitIdentifiers($PV1, $actor); $names = array("nom" => "", "nom_jeune_fille" => ""); $prenom = null; $PID5 = $xml->query("PID.5", $PID); foreach ($PID5 as $_PID5) { // Nom(s) getNames($xml, $_PID5, $PID5, $names); // Prenom(s) $prenom = getFirstNames($xml, $_PID5); } $queries = array("Message" => array("control_id" => $xml->queryTextNode("MSH.10", $MSH), "datetime" => CMbDT::dateToLocale($xml->queryTextNode("MSH.7/TS.1", $MSH))), "EVN" => array("planned_event" => CMbDT::dateToLocale($xml->queryTextNode("EVN.2/TS.1", $EVN)), "event_occurred" => CMbDT::dateToLocale($xml->queryTextNode("EVN.6/TS.1", $EVN))), "CPatient" => array("nom" => $names["nom"], "nom_jeune_fille" => $names["nom_jeune_fille"], "prenom" => $prenom, "naissance" => CMbDT::dateToLocale($xml->queryTextNode("PID.7", $PID)), "_IPP" => CValue::read($data["personIdentifiers"], "PI")), "CSejour" => array("type" => $xml->queryTextNode("PV1.2", $PV1), "entree_prevue" => CMbDT::dateToLocale($xml->queryTextNode("PV2.8/TS.1", $PV2)), "entree_reelle" => CMbDT::dateToLocale($xml->queryTextNode("PV1.44/TS.1", $PV1)), "sortie_prevue" => CMbDT::dateToLocale($xml->queryTextNode("PV2.9/TS.1", $PV2)), "sortie_reelle" => CMbDT::dateToLocale($xml->queryTextNode("PV1.45/TS.1", $PV1)), "_NDA" => CValue::read($data["personIdentifiers"], "AN"))); if ($ZBE) { $movement_id = null; foreach ($xml->queryNodes("ZBE.1", $ZBE) as $ZBE_1) { $movement_id .= $xml->queryTextNode("EI.1", $ZBE_1) . "\n"; } $queries_ZBE = array("CMovement" => array("movement_id" => $movement_id, "start_of_movement" => CMbDT::dateToLocale($xml->queryTextNode("ZBE.2/TS.1", $ZBE)))); $queries = array_merge($queries, $queries_ZBE); } function getNames(CHL7v2MessageXML $xml, DOMNode $node, DOMNodeList $PID5, &$names = array()) { $fn1 = $xml->queryTextNode("XPN.1/FN.1", $node); switch ($xml->queryTextNode("XPN.7", $node)) { case "D":