GMVHDR ;HIOFO/FT-HEALTH DATA REPOSITORY API ;10/21/04 13:03
;;5.0;GEN. MED. REC. - VITALS;**2,17**;Oct 31, 2002
;11/30/2005 KAM/BAY Remedy Call 121661 changes for HL7 message
;
; This routine uses the following IAs:
; <None>
;
; This routine supports the following IAs:
; EN - #4583 (Private)
;
EN(GMVIEN) ; This function returns a string containing the values
; for the record number provided.
;
; Input: GMVIEN - FILE 120.5 Internal Entry Number (IEN)
; Output: A string of data where:
; piece 1 = (#.01) DATE/TIME VITALS TAKEN (internal)
; piece 2 = (#.02) PATIENT (internal)
; piece 3 = (#.03) VITAL TYPE (external)
; piece 4 = (#.04) DATE/TIME VITALS ENTERED (internal)
; piece 5 = (#.05) HOSPITAL LOCATION (internal)
; piece 6 = (#.06) ENTERED BY (internal)
; piece 7 = (#.03) VITAL TYPE (internal)
; piece 8 = (#1.2) RATE
; piece 9 = UNITS (value is computed by this routine)
; piece 10 = (#1.4) SUPPLEMENTAL O2 (internal)
; piece 11 = (#2) ENTERED IN ERROR (internal)
; piece 12 = (#3) ERROR ENTERED BY (internal)
; piece 13 = (#4) REASON ENTERED IN ERROR (multiple) (external)
; Values are separated by a tilde (~).
; piece 14 = (#5) QUALIFIER (multiple) (external)
; Values are separated by a tilde (~).
;
; Returns a null value if the entry does not exist.
;
I '$G(GMVIEN) Q ""
N GMVA,GMVLIST,GMVLOOP,GMVNODE,GMVNODE2,GMVQUALE,GMVQUALI,GMVUNIT,GMVVTE,GMVVTI,GMVX
S GMVNODE=$G(^GMR(120.5,+GMVIEN,0)) ; zero node of patient record
; check if record is complete
F GMVLOOP=1,2,3,4,5,6,8 I $P(GMVNODE,U,GMVLOOP)="" D
.H 1
.S GMVNODE=$G(^GMR(120.5,+GMVIEN,0)) ;get zero node again
.Q
I GMVNODE="" Q ""
I $P(GMVNODE,U,1)'>0 Q "" ;date/time vitals taken
I $P(GMVNODE,U,2)'>0 Q "" ;dfn
S GMVVTI=+$P(GMVNODE,U,3) ;vital type ien
S GMVVTE=$P($G(^GMRD(120.51,GMVVTI,0)),U,1) ;vital type name
I GMVVTE="" Q ""
I $$ACTIVE^GMVUID(120.51,"",GMVVTI_",","") Q "" ; not active vuid
S GMVA=$P($G(^GMRD(120.51,GMVVTI,0)),U,2) ;vital abbreviation
S $P(GMVNODE,U,3)=GMVVTE,$P(GMVNODE,U,7)=GMVVTI
S GMVUNIT=$S(GMVA="BP":"mmHg",GMVA="T":"F",GMVA="R":"/min",GMVA="P":"/min",GMVA="HT":"in",GMVA="WT":"lb",GMVA="CVP":"cmH2O",GMVA="CG":"in",GMVA="PO2":"%SpO2",1:"")
S $P(GMVNODE,U,9)=GMVUNIT
S:+$P(GMVNODE,U,5)'>0 $P(GMVNODE,U,5)="" ;hospital location
S:+$P(GMVNODE,U,6)'>0 $P(GMVNODE,U,6)="" ;entered by
S GMVNODE2=$G(^GMR(120.5,GMVIEN,2))
S $P(GMVNODE,U,11)=$S($P(GMVNODE2,U,1)=1:"YES",1:"")
S $P(GMVNODE,U,12)=$S($P(GMVNODE2,U,2)>0:$P(GMVNODE2,U,2),1:"")
; reason (multiple)
S GMVLOOP=0,GMVLIST=""
F S GMVLOOP=$O(^GMR(120.5,GMVIEN,2.1,GMVLOOP)) Q:'GMVLOOP D
.S GMVX=$P($G(^GMR(120.5,GMVIEN,2.1,GMVLOOP,0)),U,1)
.Q:GMVX=""
.S GMVX=GMVX_"-"_$S(GMVX=1:"INCORRECT DATE/TIME",GMVX=2:"INCORRECT READING",GMVX=3:"INCORRECT PATIENT",GMVX=4:"INVALID RECORD",1:"")
.S GMVLIST=GMVLIST_GMVX_"~"
.Q
I $E(GMVLIST,$L(GMVLIST))="~" S GMVLIST=$E(GMVLIST,1,($L(GMVLIST)-1))
S $P(GMVNODE,U,13)=GMVLIST
;qualifiers (multiple)
S GMVLOOP=0,GMVLIST=""
F S GMVLOOP=$O(^GMR(120.5,GMVIEN,5,GMVLOOP)) Q:'GMVLOOP D
.S GMVQUALI=$P($G(^GMR(120.5,GMVIEN,5,GMVLOOP,0)),U,1)
.S GMVQUALE=$P($G(^GMRD(120.52,+GMVQUALI,0)),U,1)
.Q:GMVQUALE=""
.S GMVLIST=GMVLIST_GMVQUALE_"~"
.Q
I $E(GMVLIST,$L(GMVLIST))="~" S GMVLIST=$E(GMVLIST,1,($L(GMVLIST)-1))
S $P(GMVNODE,U,14)=GMVLIST
Q GMVNODE
;
GMVHDR ;HIOFO/FT-HEALTH DATA REPOSITORY API ;10/21/04 13:03
+1 ;;5.0;GEN. MED. REC. - VITALS;**2,17**;Oct 31, 2002
+2 ;11/30/2005 KAM/BAY Remedy Call 121661 changes for HL7 message
+3 ;
+4 ; This routine uses the following IAs:
+5 ; <None>
+6 ;
+7 ; This routine supports the following IAs:
+8 ; EN - #4583 (Private)
+9 ;
EN(GMVIEN) ; This function returns a string containing the values
+1 ; for the record number provided.
+2 ;
+3 ; Input: GMVIEN - FILE 120.5 Internal Entry Number (IEN)
+4 ; Output: A string of data where:
+5 ; piece 1 = (#.01) DATE/TIME VITALS TAKEN (internal)
+6 ; piece 2 = (#.02) PATIENT (internal)
+7 ; piece 3 = (#.03) VITAL TYPE (external)
+8 ; piece 4 = (#.04) DATE/TIME VITALS ENTERED (internal)
+9 ; piece 5 = (#.05) HOSPITAL LOCATION (internal)
+10 ; piece 6 = (#.06) ENTERED BY (internal)
+11 ; piece 7 = (#.03) VITAL TYPE (internal)
+12 ; piece 8 = (#1.2) RATE
+13 ; piece 9 = UNITS (value is computed by this routine)
+14 ; piece 10 = (#1.4) SUPPLEMENTAL O2 (internal)
+15 ; piece 11 = (#2) ENTERED IN ERROR (internal)
+16 ; piece 12 = (#3) ERROR ENTERED BY (internal)
+17 ; piece 13 = (#4) REASON ENTERED IN ERROR (multiple) (external)
+18 ; Values are separated by a tilde (~).
+19 ; piece 14 = (#5) QUALIFIER (multiple) (external)
+20 ; Values are separated by a tilde (~).
+21 ;
+22 ; Returns a null value if the entry does not exist.
+23 ;
+24 IF '$GET(GMVIEN)
QUIT ""
+25 NEW GMVA,GMVLIST,GMVLOOP,GMVNODE,GMVNODE2,GMVQUALE,GMVQUALI,GMVUNIT,GMVVTE,GMVVTI,GMVX
+26 ; zero node of patient record
SET GMVNODE=$GET(^GMR(120.5,+GMVIEN,0))
+27 ; check if record is complete
+28 FOR GMVLOOP=1,2,3,4,5,6,8
IF $PIECE(GMVNODE,U,GMVLOOP)=""
Begin DoDot:1
+29 HANG 1
+30 ;get zero node again
SET GMVNODE=$GET(^GMR(120.5,+GMVIEN,0))
+31 QUIT
End DoDot:1
+32 IF GMVNODE=""
QUIT ""
+33 ;date/time vitals taken
IF $PIECE(GMVNODE,U,1)'>0
QUIT ""
+34 ;dfn
IF $PIECE(GMVNODE,U,2)'>0
QUIT ""
+35 ;vital type ien
SET GMVVTI=+$PIECE(GMVNODE,U,3)
+36 ;vital type name
SET GMVVTE=$PIECE($GET(^GMRD(120.51,GMVVTI,0)),U,1)
+37 IF GMVVTE=""
QUIT ""
+38 ; not active vuid
IF $$ACTIVE^GMVUID(120.51,"",GMVVTI_",","")
QUIT ""
+39 ;vital abbreviation
SET GMVA=$PIECE($GET(^GMRD(120.51,GMVVTI,0)),U,2)
+40 SET $PIECE(GMVNODE,U,3)=GMVVTE
SET $PIECE(GMVNODE,U,7)=GMVVTI
+41 SET GMVUNIT=$SELECT(GMVA="BP":"mmHg",GMVA="T":"F",GMVA="R":"/min",GMVA="P":"/min",GMVA="HT":"in",GMVA="WT":"lb",GMVA="CVP":"cmH2O",GMVA="CG":"in",GMVA="PO2":"%SpO2",1:"")
+42 SET $PIECE(GMVNODE,U,9)=GMVUNIT
+43 ;hospital location
IF +$PIECE(GMVNODE,U,5)'>0
SET $PIECE(GMVNODE,U,5)=""
+44 ;entered by
IF +$PIECE(GMVNODE,U,6)'>0
SET $PIECE(GMVNODE,U,6)=""
+45 SET GMVNODE2=$GET(^GMR(120.5,GMVIEN,2))
+46 SET $PIECE(GMVNODE,U,11)=$SELECT($PIECE(GMVNODE2,U,1)=1:"YES",1:"")
+47 SET $PIECE(GMVNODE,U,12)=$SELECT($PIECE(GMVNODE2,U,2)>0:$PIECE(GMVNODE2,U,2),1:"")
+48 ; reason (multiple)
+49 SET GMVLOOP=0
SET GMVLIST=""
+50 FOR
SET GMVLOOP=$ORDER(^GMR(120.5,GMVIEN,2.1,GMVLOOP))
IF 'GMVLOOP
QUIT
Begin DoDot:1
+51 SET GMVX=$PIECE($GET(^GMR(120.5,GMVIEN,2.1,GMVLOOP,0)),U,1)
+52 IF GMVX=""
QUIT
+53 SET GMVX=GMVX_"-"_$SELECT(GMVX=1:"INCORRECT DATE/TIME",GMVX=2:"INCORRECT READING",GMVX=3:"INCORRECT PATIENT",GMVX=4:"INVALID RECORD",1:"")
+54 SET GMVLIST=GMVLIST_GMVX_"~"
+55 QUIT
End DoDot:1
+56 IF $EXTRACT(GMVLIST,$LENGTH(GMVLIST))="~"
SET GMVLIST=$EXTRACT(GMVLIST,1,($LENGTH(GMVLIST)-1))
+57 SET $PIECE(GMVNODE,U,13)=GMVLIST
+58 ;qualifiers (multiple)
+59 SET GMVLOOP=0
SET GMVLIST=""
+60 FOR
SET GMVLOOP=$ORDER(^GMR(120.5,GMVIEN,5,GMVLOOP))
IF 'GMVLOOP
QUIT
Begin DoDot:1
+61 SET GMVQUALI=$PIECE($GET(^GMR(120.5,GMVIEN,5,GMVLOOP,0)),U,1)
+62 SET GMVQUALE=$PIECE($GET(^GMRD(120.52,+GMVQUALI,0)),U,1)
+63 IF GMVQUALE=""
QUIT
+64 SET GMVLIST=GMVLIST_GMVQUALE_"~"
+65 QUIT
End DoDot:1
+66 IF $EXTRACT(GMVLIST,$LENGTH(GMVLIST))="~"
SET GMVLIST=$EXTRACT(GMVLIST,1,($LENGTH(GMVLIST)-1))
+67 SET $PIECE(GMVNODE,U,14)=GMVLIST
+68 QUIT GMVNODE
+69 ;