Beispiel #1
0
 /**
  * Create an instance of the MSH segment.
  *
  * If an array argument is provided, all fields will be filled
  * from that array. Note that for composed fields and
  * subcomponents, the array may hold subarrays and
  * subsubarrays. If the reference is not given, the MSH segment
  * will be created with the MSH 1,2,7,10 and 12 fields filled in
  * for convenience.
  */
 function __construct($fields = NULL, $hl7Globals = NULL)
 {
     parent::__construct("MSH", $fields);
     // Only fill default fields if no fields array is given
     //
     if (!isset($fields)) {
         if (!is_array($hl7Globals)) {
             $this->setField(1, '|');
             $this->setField(2, '^~\\&');
             $this->setField(7, strftime("%Y%m%d%H%M%S"));
             // Set ID field
             //
             $this->setField(10, $this->getField(7) . rand(10000, 99999));
             $this->setField(12, '2.2');
         } else {
             $this->setField(1, $hl7Globals['FIELD_SEPARATOR']);
             $this->setField(2, $hl7Globals['COMPONENT_SEPARATOR'] . $hl7Globals['REPETITION_SEPARATOR'] . $hl7Globals['ESCAPE_CHARACTER'] . $hl7Globals['SUBCOMPONENT_SEPARATOR']);
             $this->setField(7, strftime("%Y%m%d%H%M%S"));
             // Set ID field
             //
             $this->setField(10, $this->getField(7) . rand(10000, 99999));
             $this->setField(12, $hl7Globals['HL7_VERSION']);
         }
     }
 }