Example #1
0
 /**
  * Usage:
  * <code>
  * $ack = new Net_HL7_Messages_ACK($request);
  * </code>
  *
  * Convenience module implementing an acknowledgement (ACK) message. This
  * can be used in HL7 servers to create an acknowledgement for an
  * incoming message.
  *
  * @version    0.10
  * @author     D.A.Dokter <*****@*****.**>
  * @access     public
  * @category   Networking
  * @package    Net_HL7
  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  */
 public function __construct($req = "", $reqMsh = null)
 {
     parent::__construct();
     if ($req) {
         $msh = $req->getSegmentByIndex(0);
         if ($msh) {
             $msh = new Segments\MSH($msh->getFields(1));
         } else {
             $msh = new Segments\MSH();
         }
     } else {
         $msh = new Segments\MSH();
     }
     $msa = new Segment("MSA");
     // Determine acknowledge mode: normal or enhanced
     //
     if ($req && ($msh->getField(15) || $msh->getField(16))) {
         $this->_ACK_TYPE = "E";
         $msa->setField(1, "CA");
     } else {
         $this->_ACK_TYPE = "N";
         $msa->setField(1, "AA");
     }
     $this->addSegment($msh);
     $this->addSegment($msa);
     $msh->setField(9, "ACK");
     // Construct an ACK based on the request
     if ($req && $reqMsh) {
         $msh->setField(3, $reqMsh->getField(5));
         $msh->setField(4, $reqMsh->getField(6));
         $msh->setField(5, $reqMsh->getField(3));
         $msh->setField(6, $reqMsh->getField(4));
         $msa->setField(2, $reqMsh->getField(10));
     }
 }
Example #2
0
 /**
  * Set the field specified by index to value.
  *
  * Indices start at 1, to stay with the HL7 standard. Trying to
  * set the value at index 0 has no effect. Setting the value on
  * index 1, will effectively change the value of FIELD_SEPARATOR
  * for the message containing this segment, if the value has
  * length 1; setting the field on index 2 will change the values
  * of COMPONENT_SEPARATOR, REPETITION_SEPARATOR, ESCAPE_CHARACTER
  * and SUBCOMPONENT_SEPARATOR for the message, if the string is of
  * length 4.
  *
  * @param int Index of field
  * @param mixed Value
  * @return boolean
  * @access public
  */
 function setField($index, $value = '')
 {
     if ($index == 1) {
         if (strlen($value) != 1) {
             return false;
         }
     }
     if ($index == 2) {
         if (strlen($value) != 4) {
             return false;
         }
     }
     return parent::setField($index, $value);
 }