Net_HL7
[ class tree: Net_HL7 ] [ index: Net_HL7 ] [ all elements ]

Source for file ACK.php

Documentation is available at ACK.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2004 D.A.Dokter                                        |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: D.A.Dokter <dokter@w20e.com>                                |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: ACK.php,v 1.5 2004/07/05 08:57:28 wyldebeast Exp $
  20.  
  21.  
  22.     var $_ACK_TYPE;
  23.   
  24.     /**
  25.      * Usage:
  26.      * <code>
  27.      * $ack = new Net_HL7_Messages_ACK($request);
  28.      * </code>
  29.      *
  30.      * Convenience module implementing an acknowledgement (ACK) message. This
  31.      * can be used in HL7 servers to create an acknowledgement for an
  32.      * incoming message.
  33.      *
  34.      * @version    0.10
  35.      * @author     D.A.Dokter <dokter@w20e.com>
  36.      * @access     public
  37.      * @category   Networking
  38.      * @package    Net_HL7
  39.      * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  40.      */
  41.     function Net_HL7_Messages_ACK($req ""
  42.     {
  43.         parent::Net_HL7_Message();
  44.     
  45.         if ($req{
  46.             $msh =$req->getSegmentByIndex(0);
  47.  
  48.             if ($msh{
  49.                 $msh =new Net_HL7_Segments_MSH($msh->getFields(1));
  50.             }
  51.             else {
  52.                 $msh =new Net_HL7_Segments_MSH();
  53.             }
  54.         }
  55.         else {
  56.             $msh =new Net_HL7_Segments_MSH();
  57.         }
  58.  
  59.         $msa =new Net_HL7_Segment("MSA");
  60.     
  61.         // Determine acknowledge mode: normal or enhanced
  62.         //
  63.         if ($req && ($msh->getField(15|| $msh->getField(16))) {
  64.             $this->_ACK_TYPE "E";
  65.             $msa->setField(1"CA");
  66.         }
  67.         else {
  68.             $this->_ACK_TYPE "N";
  69.             $msa->setField(1"AA");
  70.         }
  71.  
  72.         $this->addSegment($msh);
  73.         $this->addSegment($msa);
  74.     
  75.         $msh->setField(9"ACK");
  76.  
  77.         // Construct an ACK based on the request
  78.         if ($req && $reqMsh{
  79.       
  80.             $msh->setField(3$reqMsh->getField(5));
  81.             $msh->setField(4$reqMsh->getField(6));
  82.             $msh->setField(5$reqMsh->getField(3));
  83.             $msh->setField(6$reqMsh->getField(4));
  84.             $msa->setField(2$reqMsh->getField(10));
  85.         }
  86.     }
  87.  
  88.  
  89.     /**
  90.      * Set the acknowledgement code for the acknowledgement. Code should be
  91.      * one of: A, E, R. Codes can be prepended with C or A, denoting enhanced
  92.      * or normal acknowledge mode. This denotes: accept, general error and
  93.      * reject respectively. The ACK module will determine the right answer
  94.      *  mode (normal or enhanced) based upon the request, if not provided.
  95.      * The message provided in $msg will be set in MSA 3.
  96.      *
  97.      * @param mixed Code to use in acknowledgement
  98.      * @param mixed Acknowledgement message
  99.      * @return boolean 
  100.      * @access public
  101.      */
  102.     function setAckCode($code$msg ""
  103.     {
  104.         $mode "A";
  105.  
  106.         // Determine acknowledge mode: normal or enhanced
  107.         //
  108.         if ($this->_ACK_TYPE == "E"{
  109.             $mode "C";
  110.         }
  111.     
  112.         if (strlen($code== 1{
  113.             $code = "$mode$code";
  114.         }
  115.  
  116.         $seg1 =$this->getSegmentByIndex(1);
  117.         $seg1->setField(1$code);
  118.         if ($msg$seg1->setField(3$msg);
  119.  
  120.         return true;
  121.     }
  122.  
  123.  
  124.     /**
  125.      * Set the error message for the acknowledgement. This will also set the
  126.      * error code to either AE or CE, depending on the mode of the incoming
  127.      * message.
  128.      * 
  129.      * @param mixed Error message
  130.      * @return boolean 
  131.      * @access public
  132.      */
  133.     function setErrorMessage($msg
  134.     {
  135.         $this->setAckCode("E"$msg);
  136.         return true;
  137.     }
  138. }
  139.  
  140. ?>

Documentation generated on Mon, 11 Mar 2019 15:32:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.