Exemplo n.º 1
0
 function getSchema($type, $name)
 {
     $extension = $this->extension;
     /*if (empty(self::$schemas)) {
         self::$schemas = SHM::get("hl7-v2-schemas");
       }*/
     $version = $this->getVersion();
     if (isset(self::$schemas[$version][$type][$name][$extension])) {
         return clone self::$schemas[$version][$type][$name][$extension];
     }
     if (!in_array($version, self::$versions)) {
         $this->error(CHL7v2Exception::VERSION_UNKNOWN, $version);
     }
     if ($extension && $extension !== "none" && preg_match("/([A-Z]{2})_(.*)/", $extension, $matches)) {
         $lang = strtolower($matches[1]);
         $v = "v" . str_replace(".", "_", $matches[2]);
         $version_dir = "extensions/{$lang}/{$v}";
     } else {
         $version_dir = "hl7v" . preg_replace("/[^0-9]/", "_", $version);
     }
     $name_dir = preg_replace("/[^A-Z0-9_]/", "", $name);
     $this->spec_filename = self::LIB_HL7 . "/{$version_dir}/{$type}{$name_dir}.xml";
     if (!file_exists($this->spec_filename)) {
         // on a déjà l'erreur sur le type de segment inconnu
         //$this->error(CHL7v2Exception::SPECS_FILE_MISSING, $this->spec_filename);
         return;
     }
     $schema = new CHL7v2DOMDocument();
     $schema->registerNodeClass('DOMElement', 'CHL7v2DOMElement');
     $schema->load($this->spec_filename);
     //$schema = @simplexml_load_file($this->spec_filename, "CHL7v2SimpleXMLElement");
     self::$schemas[$version][$type][$name][$extension] = $schema;
     //SHM::put("hl7-v2-schemas", self::$schemas);
     return $this->specs = $schema;
 }
Exemplo n.º 2
0
 /**
  * return the schema
  *
  * @param String $type type
  * @param String $name name
  *
  * @return CHL7v2DOMDocument
  */
 function getSchema($type, $name)
 {
     $version = $this->getVersion();
     if (isset(self::$schemas[$version][$type][$name][$this->type])) {
         return clone self::$schemas[$version][$type][$name][$this->type];
     }
     if (!in_array($version, self::$versions)) {
         $this->error(CHL7v2Exception::VERSION_UNKNOWN, $version);
     }
     // TODO $type_liaison
     $version = strtoupper($version);
     $version_dir = preg_replace("/[^H0-9]/", "_", $version);
     $name_dir = preg_replace("/[^A-Z0-9_]/", "", $name);
     $this->spec_filename = "modules/hprimsante/resources/{$version_dir}/{$type}{$name_dir}.xml";
     if (!file_exists($this->spec_filename)) {
         $this->error(CHL7v2Exception::SPECS_FILE_MISSING, $this->spec_filename);
         return null;
     }
     $schema = new CHL7v2DOMDocument();
     $schema->registerNodeClass('DOMElement', 'CHL7v2DOMElement');
     $schema->load($this->spec_filename);
     self::$schemas[$version][$type][$name][$this->type] = $schema;
     return $this->specs = $schema;
 }
Exemplo n.º 3
0
<?php

/* $Id $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision:$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkRead();
$test_suite = array("Date" => array("MB" => array("20110829" => "2011-08-29", "201108" => "2011-08-00", "2011" => "2011-00-00", "2011082" => null), "HL7" => array("2011-08-29" => "20110829", "2011-08-00" => "201108", "2011-00-00" => "2011")), "DateTime" => array("MB" => array("20110829140306.0052" => "2011-08-29 14:03:06", "20110829140306" => "2011-08-29 14:03:06", "201108291403" => "2011-08-29 14:03:00", "2011082914" => "2011-08-29 14:00:00", "20110829" => "2011-08-29", "201108" => "2011-08-00", "2011" => "2011-00-00", "20110829140360.0052" => null), "HL7" => array("2011-08-29 14:03:06" => "20110829140306", "2011-08-29T14:03:06" => "20110829140306", "2011-08-29 14:03:00" => "20110829140300")), "Time" => array("MB" => array("140306.0052" => "14:03:06", "140306" => "14:03:06", "1403" => "14:03:00", "14" => "14:00:00"), "HL7" => array("14:03:06" => "140306", "14:03:00" => "140300", "14:00:00" => "140000", "24:00:00" => null)), "Integer" => array("MB" => array("16512" => 16512, "16512.5" => null, "009" => 9, "foo" => null), "HL7" => array("16512" => 16512, "16512.5" => null, "009" => 9, "foo" => null)), "Double" => array("MB" => array("16512" => 16512.0, "16512.5" => 16512.5, "16512,5" => null, "009" => 9.0, "foo" => null), "HL7" => array("16512" => 16512.0, "16512.5" => 16512.5, "16512,5" => null, "009" => 9.0, "foo" => null)));
$dummy_doc = new CHL7v2DOMDocument();
$dummy_doc->registerNodeClass("DOMElement", "CHL7v2DOMElement");
$dummy_doc->loadXML('<?xml version="1.0" ?><root/>');
$dummy_element = $dummy_doc->documentElement;
$results = array();
$dummy_message = new CHL7v2Message();
$dummy_segment = new CHL7v2Segment($dummy_message);
$dummy_field = new CHL7v2Field($dummy_segment, $dummy_element);
foreach ($test_suite as $type => $systems) {
    echo "<h1>{$type}</h1>";
    $dt = CHL7v2DataType::load($dummy_message, $type, "2.5", "none");
    foreach ($systems as $system => $tests) {
        echo "<h2>vers {$system}</h2>";
        foreach ($tests as $from => $to) {
            $method = $system == "MB" ? "toMB" : "toHL7";
            $result = null;
            try {
                $result = $dt->{$method}($from, $dummy_field);
            } catch (Exception $e) {