001 package org.vmdb.hl7; 002 003 /** 004 * <p><Title:> Patient Visit (PV1) Segment. </p> 005 * <p>Description: HL7 Network Connectivity For VMDB. </p> 006 * <p>Copyright: Copyright (c) 2002-2003. </p> 007 * <p>Company: Veterinary Medical Database (VMDB). </p> 008 * <p>The use of the PV1 segment in VMDB reporting is to provide visit-specific 009 * information. This segment is required for all ORU messages and only one PV1 010 * segment may be included in a VMDB message. Only 6 elements in the segment 011 * are used for VMDB messages. See HL7 Standard Chapter 3 for details.</p> 012 * @author Michael K. Martin 013 * @version 1.0 014 */ 015 016 public class PV1Segment extends HL7Segment { 017 private String sNm = "PV1"; 018 private String sRl = 019 "DT SI IS[PL]IS[CX][PL]{XCN}[XCN][XCN][IS][PL][IS][IS][IS][IS]" + 020 "[IS][XCN][IS][CX][FC][IS][IS][IS][IS][DT][NM][NM][IS][IS]" + 021 "[DT][IS][NM][NM][IS][DT]IS[CM][CE][IS][IS][IS][PL]" + 022 "[PL][TS][TS][NM][NM][NM][NM][CX][IS][XCN]"; 023 024 /** 025 * Construct an empty patient visit segment. 026 */ 027 public PV1Segment() { 028 setName( sNm ); 029 setRule( sRl ); 030 } 031 032 /** 033 * Construct an empty patient visit segment, setting its containing message 034 * object. 035 * @param msgParent HL7SegmentContainer (normally a Group 3 loop) object that 036 * contains this segment. 037 */ 038 public PV1Segment( HL7SegmentContainer msgParent ) { 039 super( msgParent ); 040 setName( sNm ); 041 setRule( sRl ); 042 } 043 044 /** 045 * Set the Patient class. 046 * @param sStrain one character string [A,I,O, or R] for ambulatory, 047 * inpatient, outpatient, or recurring patient 048 */ 049 public void setPatientClass( String sPatClass ) { 050 try { 051 setField( sPatClass, 2 ); 052 } 053 catch( ArrayIndexOutOfBoundsException ae ) { 054 ae.printStackTrace(); 055 } 056 } 057 058 /** 059 * Get Patient class string. 060 * @return String (one character) with patient class code 061 */ 062 public String getPatientClass() { 063 HL7Element e = getField( 2 ); 064 if( e == null ) 065 return ""; 066 else 067 return e.getValue(); 068 } 069 070 /** 071 * Set the Admission type. 072 * @param sStrain one character string [C,K,E,Z,P,or R] for consult, recheck 073 * emergency, emergency referral, primary care, or referral 074 */ 075 public void setAdmissionType( String sAdmissionType ) { 076 try { 077 setField( sAdmissionType, 4 ); 078 } 079 catch( ArrayIndexOutOfBoundsException ae ) { 080 ae.printStackTrace(); 081 } 082 } 083 084 /** 085 * Get AdmissionType string. 086 * @return String (one character) with AdmissionType code 087 */ 088 public String getAdmissionType() { 089 HL7Element e = getField( 4 ); 090 if( e == null ) 091 return ""; 092 else 093 return e.getValue(); 094 } 095 096 /** 097 * Set full attending doctor name as XCN element defined as completely as you like. 098 * @param xcnName XCNElement with name defined 099 */ 100 public void setAttendingDoctorName( XCNElement xcnName ) { 101 try { 102 setField( xcnName, 7 ); 103 } 104 catch( ArrayIndexOutOfBoundsException ae ) { 105 ae.printStackTrace(); 106 } 107 catch( MalformedSegmentException mfe ) { 108 mfe.printStackTrace(); 109 } 110 } 111 112 /** 113 * Set attending doctor name identifier from ID and facility. 114 * @param sIdNumber String with id number 115 * @param sAssigningAuthority String with assigning facility namespace id 116 */ 117 public void setAttendingDoctorId( String sIdNumber, String sAssigningAuthority ) { 118 try { 119 XCNElement xcnName = (XCNElement)getField(7); 120 if( xcnName == null ) 121 xcnName = new XCNElement(); 122 xcnName.setIdNumber( sIdNumber ); 123 xcnName.setAssigningAuthority( sAssigningAuthority ); 124 setField( xcnName, 7 ); 125 } 126 catch( ClassCastException ce ) { 127 System.err.println( vFields.toString() ); 128 ce.printStackTrace(); 129 } 130 catch( ArrayIndexOutOfBoundsException ae ) { 131 ae.printStackTrace(); 132 } 133 catch( MalformedSegmentException mfe ) { 134 mfe.printStackTrace(); 135 } 136 } 137 138 /** 139 * Set attending doctor name identifier. 140 * @param sIdNumber String with id number 141 * 142 */ 143 public void setAttendingDoctorId( String sIdNumber ) { 144 XCNElement xcnName = (XCNElement)getField(7); 145 if( xcnName == null ) 146 xcnName = new XCNElement(); 147 xcnName.setName( "PV1.7" ); 148 xcnName.setIdNumber( sIdNumber ); 149 try { 150 setField( xcnName, 7 ); 151 } 152 catch( ArrayIndexOutOfBoundsException ae ) { 153 ae.printStackTrace(); 154 } 155 catch( MalformedSegmentException mfe ) { 156 mfe.printStackTrace(); 157 } 158 } 159 160 /** 161 * Set attending doctor assigning facility. 162 * @param sIdNumber String with assigning authority namespace id 163 */ 164 public void setAttendingDoctorAssigningAuthority( String sAssigningAuthority ) { 165 XCNElement xcnName = (XCNElement)getField(7); 166 if( xcnName == null ) 167 xcnName = new XCNElement(); 168 xcnName.setAssigningAuthority( sAssigningAuthority ); 169 try { 170 setField( xcnName, 7 ); 171 } 172 catch( ArrayIndexOutOfBoundsException ae ) { 173 ae.printStackTrace(); 174 } 175 catch( MalformedSegmentException mfe ) { 176 mfe.printStackTrace(); 177 } 178 } 179 180 /** 181 * Get just the attending doctor identifier 182 * @return String with identifier number 183 */ 184 public String getAttendingDoctorId() { 185 XCNElement xcnE = (XCNElement)getField(7); 186 if( xcnE != null ) 187 return xcnE.getIdNumber(); 188 else 189 return ""; 190 } 191 192 /** 193 * Get just the assigning authority namespace id 194 * @return String with identifier number 195 */ 196 public String getAttendingDoctorAssigningAuthority() { 197 XCNElement xcnE = (XCNElement)getField(7); 198 if( xcnE != null ) { 199 HDElement hdE = xcnE.getAssigningAuthority(); 200 if( hdE != null ) 201 return hdE.getNamespaceId(); 202 else 203 return ""; 204 } 205 else 206 return ""; 207 } 208 209 /** 210 * Get the full attending doctor as XCNElement 211 * @return XPNElement with fully defined name 212 * 213 */ 214 public XCNElement getAttendingDoctor() { 215 return (XCNElement)getField(7); 216 } 217 218 /** 219 * Set full Visit Number as CX element defined as completely as you like. 220 * @param cxVisitNumber CXElement with name defined 221 */ 222 public void setVisitNumber( CXElement cxVisitNumber ) { 223 cxVisitNumber.setName( "PV1.19" ); 224 try { 225 setField( cxVisitNumber, 19 ); 226 } 227 catch( ArrayIndexOutOfBoundsException ae ) { 228 ae.printStackTrace(); 229 } 230 catch( MalformedSegmentException mfe ) { 231 mfe.printStackTrace(); 232 } 233 } 234 235 /** 236 * Set Visit Number identifier and assigning facility. 237 * @param sIdNumber String with id number 238 * @param sAssigningAuthority String with assigning facility namespace id 239 */ 240 public void setVisitNumberId( String sIdNumber, String sAssigningAuthority ) { 241 try { 242 CXElement cxVisitNumber = (CXElement)getField(19); 243 if( cxVisitNumber == null ) 244 cxVisitNumber = new CXElement(); 245 cxVisitNumber.setName( "PV1.19" ); 246 cxVisitNumber.setIdentifier( sIdNumber ); 247 cxVisitNumber.setAssigningAuthorityName( sAssigningAuthority ); 248 setField( cxVisitNumber, 19 ); 249 } 250 catch( ClassCastException ce ) { 251 System.err.println( vFields.toString() ); 252 ce.printStackTrace(); 253 } 254 catch( ArrayIndexOutOfBoundsException ae ) { 255 ae.printStackTrace(); 256 } 257 catch( MalformedSegmentException mfe ) { 258 mfe.printStackTrace(); 259 } 260 } 261 262 /** 263 * Set Visit Number identifier. 264 * @param sIdNumber String with id number 265 */ 266 public void setVisitNumberId( String sIdNumber ) { 267 CXElement cxVisitNumber = (CXElement)getField(19); 268 if( cxVisitNumber == null ) 269 cxVisitNumber = new CXElement(); 270 cxVisitNumber.setName( "PV1.19" ); 271 cxVisitNumber.setIdentifier( sIdNumber ); 272 try { 273 setField( cxVisitNumber, 19 ); 274 } 275 catch( ArrayIndexOutOfBoundsException ae ) { 276 ae.printStackTrace(); 277 } 278 catch( MalformedSegmentException mfe ) { 279 mfe.printStackTrace(); 280 } 281 } 282 283 /** 284 * Set Visit Number assigning facility. 285 * @param sIdNumber String with assigning authority namespace id 286 */ 287 public void setVisitNumberAssigningAuthority( String sAssigningAuthority ) { 288 CXElement cxVisitNumber = (CXElement)getField(19); 289 if( cxVisitNumber == null ) 290 cxVisitNumber = new CXElement(); 291 cxVisitNumber.setAssigningAuthorityName( sAssigningAuthority ); 292 try { 293 setField( cxVisitNumber, 19 ); 294 } 295 catch( ArrayIndexOutOfBoundsException ae ) { 296 ae.printStackTrace(); 297 } 298 catch( MalformedSegmentException mfe ) { 299 mfe.printStackTrace(); 300 } 301 } 302 303 /** 304 * Get just the Visit Number identifier. 305 * @return String with identifier number 306 */ 307 public String getVisitNumberId() { 308 CXElement cxVisitNumber = (CXElement)getField(19); 309 if( cxVisitNumber != null ) 310 return cxVisitNumber.getIdentifier(); 311 else 312 return ""; 313 } 314 315 /** 316 * Get just the assigning authority namespace id. 317 * @return String with identifier number 318 */ 319 public String getVisitNumberAssigningAuthority() { 320 CXElement cxVisitNumber = (CXElement)getField(19); 321 if( cxVisitNumber != null ) { 322 HDElement hdE = cxVisitNumber.getAssigningAuthority(); 323 if( hdE != null ) 324 return hdE.getNamespaceId(); 325 else 326 return ""; 327 } 328 else 329 return ""; 330 } 331 332 /** 333 * Get the full Visit Number as CXElement. 334 * @return XPNElement with fully defined name 335 */ 336 public CXElement getVisitNumber() { 337 return (CXElement)getField(19); 338 } 339 340 /** 341 * Set the Discharge Disposition. 342 * @param sDisp one character string [0,1,2, or 3] for alive, 343 * dead, euthanized, or referred 344 */ 345 public void setDisposition( String sDisp ) { 346 try { 347 setField( sDisp, 36 ); 348 } 349 catch( ArrayIndexOutOfBoundsException ae ) { 350 ae.printStackTrace(); 351 } 352 } 353 354 /** 355 * Get Discharge Disposition. 356 * @return String (one character) with discharge disposition code 357 */ 358 public String getDisposition() { 359 HL7Element e = getField( 36 ); 360 if( e == null ) 361 return ""; 362 else 363 return e.getValue(); 364 } 365 366 /** 367 * Set the admit date/time of the message to string formatted date/time. 368 * @param sDateTime String with date/time in yyyyMMddHHmmss format 369 */ 370 public void setAdmitDateTime( String sDateTime ) { 371 TSElement tse = new TSElement(); 372 tse.setName( "PV1.44" ); 373 tse.setDateTime( sDateTime ); 374 try { 375 setField( tse, 44 ); 376 } 377 catch( ArrayIndexOutOfBoundsException ae ) { 378 ae.printStackTrace(); 379 } 380 catch( MalformedSegmentException mfe ) { 381 mfe.printStackTrace(); 382 } 383 } 384 385 /** 386 * Get the admit date/time as a string. 387 * @return String date/time 388 */ 389 public String getAdmitDateTime() { 390 TSElement tse = (TSElement)getField( 44 ); 391 if( tse != null ) 392 return tse.getDateTime(); 393 else 394 return ""; 395 } 396 397 /** 398 * Set the discharge date/time of the message to string formatted date/time. 399 * @param sDateTime String with date/time in yyyyMMddHHmmss format 400 * 401 */ 402 public void setDischargeDateTime( String sDateTime ) { 403 TSElement tse = new TSElement(); 404 tse.setName( "PV1.44" ); 405 tse.setDateTime( sDateTime ); 406 try { 407 setField( tse, 45 ); 408 } 409 catch( ArrayIndexOutOfBoundsException ae ) { 410 ae.printStackTrace(); 411 } 412 catch( MalformedSegmentException mfe ) { 413 mfe.printStackTrace(); 414 } 415 } 416 417 /** 418 * Get the discharge date/time as a string. 419 * @return String date/time 420 */ 421 public String getDischargeDateTime() { 422 TSElement tse = (TSElement)getField( 45 ); 423 if( tse != null ) 424 return tse.getDateTime(); 425 else 426 return ""; 427 } 428 429 } // End class PV1Segment 430