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

Source for file HL7.php

Documentation is available at HL7.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: HL7.php,v 1.7 2004/08/06 07:38:54 wyldebeast Exp $
  20.  
  21. /**
  22.  * The Net_HL7 class is a factory class for HL7 messages.
  23.  *
  24.  * The factory class provides the convenience of changing several
  25.  * defaults for HL7 messaging globally, like separators, etc. Note
  26.  * that some default settings use characters that have special meaning
  27.  * in PHP, like the HL7 escape character. To be able to set these
  28.  * values, escape the special characters.
  29.  *
  30.  * @version    0.1.0
  31.  * @author     D.A.Dokter <dokter@w20e.com>
  32.  * @access     public
  33.  * @category   Networking
  34.  * @package    Net_HL7
  35.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  36.  */
  37. class Net_HL7 {
  38.  
  39.     /**
  40.      * Holds all global HL7 settings.
  41.      */
  42.     var $_hl7Globals = array();
  43.  
  44.  
  45.     /**
  46.      * Create a new instance of the HL7 factory, and set global
  47.      * defaults.
  48.      */
  49.     function Net_HL7({
  50.  
  51.         $this->_hl7Globals['SEGMENT_SEPARATOR''\015';
  52.         $this->_hl7Globals['FIELD_SEPARATOR''|';
  53.         $this->_hl7Globals['NULL''""';
  54.         $this->_hl7Globals['COMPONENT_SEPARATOR''^';
  55.         $this->_hl7Globals['REPETITION_SEPARATOR''~';
  56.         $this->_hl7Globals['ESCAPE_CHARACTER''\\';
  57.         $this->_hl7Globals['SUBCOMPONENT_SEPARATOR''&';
  58.         $this->_hl7Globals['HL7_VERSION''2.2';
  59.     }
  60.     
  61.  
  62.     /**
  63.      * Create a new Net_HL7_Message, using the global HL7 variables as
  64.      * defaults.
  65.      * 
  66.      * @param string Text representation of an HL7 message
  67.      * @return object Net_HL7_Message 
  68.      * @access public
  69.      */
  70.     function &createMessage($msgStr "")
  71.     {
  72.         $msg =new Net_HL7_Message($msgStr$this->_hl7Globals);
  73.         
  74.         return $msg;
  75.     }
  76.  
  77.  
  78.     /**
  79.      * Create a new Net_HL7_Segments_MSH segment, using the global HL7
  80.      * variables as defaults.
  81.      * 
  82.      * @return object Net_HL7_Segments_MSH 
  83.      * @access public
  84.      */
  85.     function &createMSH()
  86.     {
  87.         $msh =new Net_HL7_Segments_MSH($this->_hl7Globals);
  88.         
  89.         return $msh;
  90.     }
  91.  
  92.  
  93.     /**
  94.      * Set the component separator to be used by the factory. Should
  95.      * be a single character. Default ^
  96.      *
  97.      * @param string Component separator char.
  98.      * @return boolean true if value has been set.
  99.      * @access public
  100.      */
  101.     function setComponentSeparator($value)
  102.     {
  103.         if (strlen($value!= 1return false;
  104.  
  105.         return $this->_setGlobal('COMPONENT_SEPARATOR'$value);
  106.     }
  107.  
  108.  
  109.     /**
  110.      * Set the subcomponent separator to be used by the factory. Should
  111.      * be a single character. Default: &
  112.      *
  113.      * @param string Subcomponent separator char.
  114.      * @return boolean true if value has been set.
  115.      * @access public
  116.      */
  117.     function setSubcomponentSeparator($value)
  118.     {
  119.         if (strlen($value!= 1return false;
  120.  
  121.         return $this->_setGlobal('SUBCOMPONENT_SEPARATOR'$value);
  122.     }
  123.  
  124.  
  125.     /**
  126.      * Set the repetition separator to be used by the factory. Should
  127.      * be a single character. Default: ~
  128.      *
  129.      * @param string Repetition separator char.
  130.      * @return boolean true if value has been set.
  131.      * @access public
  132.      */
  133.     function setRepetitionSeparator($value)
  134.     {
  135.         if (strlen($value!= 1return false;
  136.  
  137.         return $this->_setGlobal('REPETITION_SEPARATOR'$value);
  138.     }
  139.  
  140.  
  141.     /**
  142.      * Set the field separator to be used by the factory. Should
  143.      * be a single character. Default: |
  144.      *
  145.      * @param string Field separator char.
  146.      * @return boolean true if value has been set.
  147.      * @access public
  148.      */
  149.     function setFieldSeparator($value)
  150.     {
  151.         if (strlen($value!= 1return false;
  152.  
  153.         return $this->_setGlobal('FIELD_SEPARATOR'$value);
  154.     }
  155.  
  156.  
  157.     /**
  158.      * Set the segment separator to be used by the factory. Should
  159.      * be a single character. Default: \015
  160.      *
  161.      * @param string Segment separator char.
  162.      * @return boolean true if value has been set.
  163.      * @access public
  164.      */
  165.     function setSegmentSeparator($value)
  166.     {
  167.         if (strlen($value!= 1return false;
  168.  
  169.         return $this->_setGlobal('SEGMENT_SEPARATOR'$value);
  170.     }
  171.  
  172.  
  173.     /**
  174.      * Set the escape character to be used by the factory. Should
  175.      * be a single character. Default: \
  176.      *
  177.      * @param string Escape character.
  178.      * @return boolean true if value has been set.
  179.      * @access public
  180.      */
  181.     function setEscapeCharacter($value)
  182.     {
  183.         if (strlen($value!= 1return false;
  184.         
  185.         return $this->_setGlobal('ESCAPE_CHARACTER'$value);
  186.     }
  187.  
  188.  
  189.     /**
  190.      * Set the HL7 version to be used by the factory.
  191.      *
  192.      * @param string HL7 version character.
  193.      * @return boolean true if value has been set.
  194.      * @access public
  195.      */
  196.     function setHL7Version($value)
  197.     {
  198.         return $this->_setGlobal('HL7_VERSION'$value);
  199.     }
  200.  
  201.  
  202.     /**
  203.      * Set the NULL string to be used by the factory.
  204.      *
  205.      * @param string NULL string.
  206.      * @return boolean true if value has been set.
  207.      * @access public
  208.      */
  209.     function setNull($value)
  210.     {
  211.         return $this->_setGlobal('NULL'$value);
  212.     }
  213.  
  214.  
  215.     /**
  216.      * Convenience method for obtaining the special NULL value.
  217.      *
  218.      * @return string null value
  219.      * @access public
  220.      */
  221.     function getNull({
  222.  
  223.         return $this->_hl7Globals['NULL'];
  224.     }
  225.  
  226.  
  227.     /**
  228.      * Set the HL7 global variable
  229.      *
  230.      * @access private
  231.      * @param string name
  232.      * @param string value
  233.      * @return boolean True when value has been set, false otherwise.
  234.      */
  235.     function _setGlobal($name$value)
  236.     {
  237.         $this->_hl7Globals[$name$value;
  238.  
  239.         return true;
  240.     }
  241.     
  242. }
  243. ?>

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