Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MDCSPV1

MDCSPV1.m

Go to the documentation of this file.
  1. MDCSPV1 ;HINES OIFO/DP/BJ - Build Segment PV1 Routine;17 Aug 2007
  1. ;;1.0;CLINICAL PROCEDURES;**16,23**;Apr 01, 2004;Build 281
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ; - This sub-routine is the Segment Builder proper for the HL7 Patient
  1. ; Visit 1 (PV1) Segment.
  1. ; This routine uses the following IAs:
  1. ; #10039 - access ^DIC(42 Registration (supported)
  1. ;
  1. Q
  1. BUILD(VAFSTR,VAFNUM,PMOOV,PSEG,TRUBL) ;
  1. ;
  1. ; - INPUT
  1. ; VAFSTR = field selection string; field number in string, field into segment
  1. ; VAFNUM = segment number; pass "0001", else routine sets.
  1. ; PMOOV = CP_MOVEMENT_AUDIT file record !!Passed by reference!!
  1. ; PSEG = segment buffer. !!Passed by reference!!
  1. ; TRUBL = error return string. !! Passed by reference !!
  1. ;
  1. ;
  1. ; - PREDEFINED LOCALS
  1. ; HLECH = Subfield seperation character defined in MDCPV1
  1. ;
  1. ;
  1. ; - OUTPUT
  1. ; If no errors detected, PSEG contains the message segment. If the character count
  1. ; exceeds HLMAXLEN, SUBScripted extension segments are allocated, one for each time HLMAXLEN
  1. ; is exceeded. Below is a possible example.
  1. ; PSEG = up to HLMAXLEN characters of segment
  1. ; PSEG(1) = up to HLMAXLEN characters of segment
  1. ; PSEG(2) = remaining characters of segment
  1. ; If an error is detected, TRUBL contains an error message string. PSEG is killed.
  1. ;
  1. ; Fields are not broken across segment boundaries. If the number of characters in a field
  1. ; plus the separator character (HLFS) that precedes the field will push a segment's character
  1. ; count beyond HLMAXLEN, a new overflow segment is established. The field and its
  1. ; preceding separator are placed there.
  1. ;
  1. ;
  1. N PV1,FLD,RUMBE,PRAW,WRDLO
  1. ;
  1. ;
  1. ; - The segment is required. Right now, our data comes from just an entry in the
  1. ; 704.005 file. If it is absent or empty,
  1. ; exit now with no error. There is one required field. If any data present in PV1 node,
  1. ; the required field (in PV1) must be present. Otherwise error. Checked for below.
  1. I $TR($G(PMOOV(0)),U)="" Q
  1. S PV1=PMOOV(0)
  1. ;
  1. ;
  1. ; - segment number
  1. I VAFNUM="0001" S PRAW(1)=VAFNUM
  1. I VAFNUM'="0001" S PRAW(1)="0001"
  1. ;
  1. ;
  1. ; - patient class. I for Inpatient, O for Outpatient
  1. ; but all is Inpatient
  1. ;
  1. I (VAFSTR[",2,") S PRAW(2)="I"
  1. ;
  1. ; - Assigned Patient Location/Point of Care. There are 3 components: Point of Care,
  1. ; which is the Medical Center Division ID; the Room, which is the Ward Location
  1. ; ID; and Bed, which is the ROOM-BED ID. Since the Patient Location field is Required, its
  1. ; two Required components, Point of Care and Room, must both be present.
  1. S (FLD,WRDLO,RUMBE)=""
  1. I (VAFSTR[",3,") D
  1. .; - look for characters to escape
  1. .I ($TR(FLD,HL7RC)'=FLD) S FLD=$$ESC^MDCUTL(FLD)
  1. .; employ the pointer to the Ward Location file
  1. .I ($P(PV1,U,4)'="") S WRDLO=$P($G(^DIC(42,($P(PV1,U,4)),0)),U)
  1. .; - look for characters to escape
  1. .I ($TR(WRDLO,HL7RC)'=WRDLO) S WRDLO=$$ESC^MDCUTL(WRDLO)
  1. .; - employ the pointer to the ROOM-BED file
  1. .I ($P(PV1,U,5)'="") S MDF4054=405.4,RUMBE=$$GET1^DIQ(MDF4054,($P(PV1,U,5))_",","NAME") K MDF4054
  1. .; - there are 3 parts: Room ID, Bed ID, and (sometimes) Building ID
  1. .; - get room and bed IDs, dropping building ID if present
  1. .S RUMBE=$P(RUMBE,"-",1,2)
  1. .; - check for characters to escape
  1. .I ($TR(RUMBE,HL7RC)'=RUMBE) S RUMBE=$$ESC^MDCUTL(RUMBE)
  1. .; Room and bed are supposed to be in different fields.
  1. .; Note: According to our conformance profile, subfield separators are always '^'. Ideally, we'll
  1. .; want to change this to something out of the environment, but I'm not sure what the original
  1. .; developers did with the variable that was supposed to hold the subfield separator.
  1. .S RUMBE=$TR(RUMBE,"-","^")
  1. .; - assemble field from components; no separators for absent trailing components
  1. .; blj 17 Mar 2011: The wrong delimiter was being used below
  1. .;I RUMBE'="" S WRDLO=WRDLO_HLRP_RUMBE
  1. .I RUMBE'="" S WRDLO=WRDLO_HLCM_RUMBE
  1. .I WRDLO'="" S FLD=WRDLO
  1. ;
  1. S PRAW(3)=FLD
  1. ;
  1. ; - Attending Doc field. approximately XCN format. not required, but
  1. ; pointer should be good if present and can be checked for later.
  1. ;I ($P(PV1,U,19)'=""),(VAFSTR[",7,") S PRAW(7)=$$DOCINF^MDCPV1($P(PV1,U,19))
  1. ;
  1. D MAKESEG^MDCUTL(.PRAW,.PSEG,0,"PV1")
  1. Q
  1. ;