001 package org.vmdb.hl7;
002
003 import java.util.*;
004
005 /**
006 * <p><Title:> PATIENT Loop. </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>The XML representation of HL7 2.x introduces the concepts of groups and lists
011 * that, while present in the construction rules of delimited HL7, are not explicitly
012 * named or labelled in the messages themselves. This class follows the XML
013 * version with explicitly constructed groups and lists
014 * which we've combined under the general term (borrowed from X12) of "loop."</p>
015 * <p>Most of the repetion and grouping facilitated by this "loop" logic is not
016 * used in the VMDB version of the ORU message but is maintained to retain full
017 * standard compliance and to allow extending this model without fear of losing
018 * interoperability.</p>
019 * <p>Loop and Segment Nesting: The outline below shows how the loops and minimum
020 * required segments nest. {OBX} indicates that any number of OBX segments may
021 * appear at this location.</p>
022 <pre>
023 MSH
024 PATIENT_RESULT
025 <b>PATIENT</b>
026 PID
027 PATIENT_VISIT
028 PV1
029 ORDER_OBSERVATION
030 [ORC]
031 OBR
032 OBSERVATION
033 OBX
034 </pre>
035 * @author Michael K. Martin
036 * @version 1.0
037 */
038
039 public class PATIENTLoop extends HL7Loop {
040 private String sNm = "PATIENT";
041 private String sRl = "PID[PD1][{NK1}][{NTE}][PATIENT_VISIT]";
042
043 public PATIENTLoop() {
044 super();
045 setName( sNm );
046 setRule( sRl );
047 }
048
049 /**
050 * Get the PATIENT_VISITLoop loop that should be nested within this loop. If
051 * it does not exist, take the necessary steps to create it in the appropriate
052 * nested loop structure.<br>
053 * @return PATIENT_VISITLoop object located at the appropriate place in the loop.
054 */
055 public PATIENT_VISITLoop getPATIENT_VISIT() {
056 PATIENT_VISITLoop loop = null;
057 if( vSegments == null ) vSegments = new Vector();
058 for( Iterator i = vSegments.iterator(); i.hasNext(); ) {
059 HL7Object o = (HL7Object)i.next();
060 if( o.getName().equals( "PATIENT_VISIT" ) ) {
061 loop = (PATIENT_VISITLoop)o;
062 break;
063 }
064 }
065 if( loop == null ) {
066 loop = new PATIENT_VISITLoop();
067 vSegments.add(loop);
068 }
069 return loop;
070 }
071
072 /**
073 * Get the PID segment that should be contained within this loop. If
074 * it does not exist, take the necessary steps to create it in the appropriate
075 * location.
076 * @return PIDSegment object located at the appropriate place in the loop.
077 */
078 public PIDSegment getPID() {
079 PIDSegment pid = (PIDSegment)findSegment( "PID" );
080 if( pid == null ) {
081 pid = new PIDSegment();
082 pid.initialize();
083 if( vSegments == null ) vSegments = new Vector();
084 vSegments.add(0,pid);
085 }
086 return pid;
087 }
088
089 }// End class PATIENTLoop