001    package org.vmdb.hl7;
002    
003    import java.util.*;
004    
005    /**
006     * <p><Title:> Abstract Base Class for HL7 Loop Structures. </p>
007     * <p>Description: HL7 Network Connectivity For VMDB. </p>
008     * <p>Copyright: Copyright (c) 2002-2003. </p>
009     * <p>Company: Veterinary Medical Database (VMDB). </p>
010     * <p>A "Loop" is not really part of the HL7 specification, but it is
011     * a very useful concept from X12 and is necessary to properly implement repeatable
012     * groups of segments in XML.  The Loop does not appear in the HL7 2.4 representation
013     * except as {...} groupings in the specification.  It appears in the XML
014     * representation as <PATIENT_RESULT>...</PATIENT_RESULT> type tag pairs with segment
015     * tag pairs embedded within.</p>
016     * <p>For "formal" description of any given "loop" see HL7 v2.xml documentation
017     * that has recently become an official ANSI standard.</p>
018     * @author Michael K. Martin
019     * @version 1.0
020     */
021    
022    public abstract class HL7Loop extends HL7SegmentContainer{
023       private static Hashtable hLoopTypes;
024    
025       static {
026          try {
027             hLoopTypes = new Hashtable();
028             hLoopTypes.put( "PATIENT_RESULT", Class.forName("org.vmdb.hl7.PATIENT_RESULTLoop") );
029             hLoopTypes.put( "PATIENT", Class.forName("org.vmdb.hl7.PATIENTLoop") );
030             hLoopTypes.put( "PATIENT_VISIT", Class.forName("org.vmdb.hl7.PATIENT_VISITLoop") );
031             hLoopTypes.put( "ORDER_OBSERVATION", Class.forName("org.vmdb.hl7.ORDER_OBSERVATIONLoop") );
032             hLoopTypes.put( "OBSERVATION", Class.forName("org.vmdb.hl7.OBSERVATIONLoop") );
033          } catch( Exception e ) {
034             e.printStackTrace();
035          }
036       }
037    
038       /** Temporary fix.  Really needs to insert the Message Structure, whatever
039        *  that is.
040        *  @return String with Message Structure plus loop name to match schema
041        */
042       public String getName() {
043          return "ORU_R01." + super.getName();
044       }
045    
046       // Lie to the program since I don't expect to run out of message.
047       public boolean messageComplete() {
048          return true;
049       }
050    
051       public static boolean isLoop( String sRule ) {
052          return hLoopTypes.containsKey( sRule );
053       }
054    
055       public static Class getLoopClass( String sRule ) {
056          Class cLoop = null;
057          Object o = hLoopTypes.get( sRule );
058          if( o != null ) {
059             cLoop = (Class)o;
060          }
061          return cLoop;
062       }
063    
064    } // End class HL7LOOP