GMVDCEXT ;HOIFO/DAD,FT-VITALS COMPONENT: EXTRACT PATIENT DATA ;6/13/07
;;5.0;GEN. MED. REC. - VITALS;**23**;Oct 31, 2002;Build 25
;
; This routine uses the following IAs:
; #4290 - ^PXRMINDX global (controlled)
; #10035 - FILE 2 references (supported)
; #10104 - ^XLFSTR calls (supported)
;
; This routine supports the following IAs:
; #4251 - EN1 entry point (private)
;
EN1(RESULT,GMVDFN,GMVFMT,GMVABR,GMVALL,GMVBEG,GMVEND,GMVMSYS,GMVEER) ;
; Return patient vitals
;
; Input:
; RESULT = Where data is returned (closed array reference) (Required)
; GMVDFN = A pointer to the Patient file (#2) (Required)
; GMVFMT = Format of returned data (Optional)
; 1 - IENs (default), 2 - Abbreviations, 3 - Full Names
; GMVABR = Abbreviations of vital types to return (Optional)
; "^T^P^R^PO2^BP^HT^WT^CVP^CG^PN^" (Default GMVALL = 0)
; "~ALL~" to return all vital types (Default GMVALL = 1)
; GMVALL = Controls what data is returned (Optional)
; 0 - Most recent (default), 1 - All in date range
; GMVBEG = Beginning date for all vitals (Not used for GMVALL = 0)
; GMVEND = Ending date for all vitals (Not used for GMVALL = 0)
; GMVMSYS = Measurement system (Optional)
; M = Metric, C - US Customary (Default)
; GMVEER = Include entered in error records (Optional)
; (0 - No (Default), 1 - Yes)
;
; Output:
; RESULT() = VitalMeasurementIEN ^ DateTimeTaken ^ PatientDFN ^
; VitalType ^ DateTimeEntered ^ HospitalLocation ^
; EnteredBy ^ Measurement ^ EnteredInError ^
; EnteredInErrorBy ^
; Qualifier1 ; Qualifier2 ; ... ^
; EnteredInErrorReason1 ; EnteredInErrorReason2 ; ... ^
;
N GMV,GMVABBR,GMVALUE,GMVCAT,GMVCD0,GMVCD1,GMVD0,GMVD1,GMVDATA
N GMVDATA2,GMVER,GMVFOUND,GMVIDATE,GMVOK,GMVPOR,GMVPULSE,GMVQD0
N GMVQD1,GMVQUA,GMVQL
N GMVRATE,GMVRET
K @RESULT
S @RESULT@(0)="OK"
S GMVALL=$S("^0^1^"[(U_$G(GMVALL)_U):GMVALL,1:0)
S GMVFMT=$S("^1^2^3^"[(U_$G(GMVFMT)_U):GMVFMT,1:1)
S GMVEER=$S(GMVALL=0:0,"^0^1^"[(U_$G(GMVEER)_U):GMVEER,1:0)
I $$FIND1^DIC(2,"","","`"_GMVDFN)'=GMVDFN D
. S @RESULT@(0)="ERROR"
. S @RESULT@(1)="ERROR: Missing or invalid Patient parameter"
. Q
S GMVMSYS=$$MEASYS^GMVDCUTL($G(GMVMSYS))
K GMVRET
D DT^DILF("ST",$G(GMVEND),.GMVRET,"-NOW")
S GMVEND=$G(GMVRET)
K GMVRET
D DT^DILF("ST",$G(GMVBEG),.GMVRET,-GMVEND)
S GMVBEG=$G(GMVRET) S:GMVBEG>0 GMVBEG=GMVBEG-.000001
I GMVALL&((GMVBEG'>0)!(GMVEND'>0)) D
. S @RESULT@(0)="ERROR"
. S @RESULT@(2)="ERROR: Missing or invalid Date Range parameters"
. Q
I $G(@RESULT@(0))="ERROR" Q
S GMVABBR=$S($G(GMVABR)]"":GMVABR,GMVALL=1:"~ALL~",1:"^T^P^R^PO2^BP^HT^WT^CVP^CG^PN^")
I GMVABBR="~ALL~" D
. S GMVD0=0,GMVABBR=U
. F S GMVD0=$O(^GMRD(120.51,GMVD0)) Q:GMVD0'>0 D
.. S GMVABBR(0)=$P($G(^GMRD(120.51,GMVD0,0)),U,2)
.. I GMVABBR(0)]"" S GMVABBR=GMVABBR_GMVABBR(0)_U
.. Q
. Q
S GMVABBR=$S($E(GMVABBR)'=U:U,1:"")_GMVABBR_$S($E(GMVABBR,$L(GMVABBR))'=U:U,1:"")
F GMV=2:1:$L(GMVABBR,U)-1 S GMVABBR(0)=$P(GMVABBR,U,GMV) D
. I $S(GMVABBR(0)="":1,$O(^GMRD(120.51,"C",GMVABBR(0),0))>0:1,1:0) Q
. I GMVABBR(0)'=+GMVABBR(0) S GMVABBR(0)=+$O(^GMRD(120.51,"B",GMVABBR(0),0))
. S GMVABBR(0)=$P($G(^GMRD(120.51,GMVABBR(0),0)),U,2)
. S $P(GMVABBR,U,GMV)=GMVABBR(0)
. Q
F GMV=1:1 S GMVPULSE=$P($T(PULSE+GMV),";;",2) Q:GMVPULSE="" D
. S GMVD0=0
. F S GMVD0=$O(^GMRD(120.52,"B",GMVPULSE,GMVD0)) Q:GMVD0'>0 D
.. I $P($G(^GMRD(120.52,GMVD0,0)),U)=GMVPULSE S GMVPULSE(GMVD0)=GMVPULSE,GMVPULSE(GMVPULSE)=GMVD0
.. Q
. Q
S GMVD0=0
F S GMVD0=$O(^GMRD(120.51,GMVD0)) Q:GMVD0'>0 D
. S GMVABBR(0)=$G(^GMRD(120.51,GMVD0,0))
. I GMVABBR[(U_$P(GMVABBR(0),U,2)_U) S GMVABBR($P(GMVABBR(0),U,2))=GMVD0_U_$P(GMVABBR(0),U,2)_U_$P(GMVABBR(0),U)
. Q
S GMVABBR=""
F S GMVABBR=$O(GMVABBR(GMVABBR)) Q:GMVABBR="" I GMVABBR(GMVABBR)>0 D
. S GMVFOUND=0
. S GMVIDATE=$S(GMVALL:GMVBEG,1:0)
. I GMVALL=1 F S GMVIDATE=$O(^PXRMINDX(120.5,"PI",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE)) Q:GMVIDATE'>0!$S(GMVALL:GMVIDATE>GMVEND,1:0)!GMVFOUND D SETDATAR
. I GMVALL=0 S GMVIDATE=GMVEND+.000001 F S GMVIDATE=$O(^PXRMINDX(120.5,"PI",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE),-1) Q:GMVIDATE'>0!(GMVFOUND)!(GMVIDATE<GMVBEG) D SETDATAR
. Q:GMVEER=0
. S GMVIDATE=$S(GMVALL:9999999-GMVEND,1:0)
. F S GMVIDATE=$O(^GMR(120.5,"AA",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE)) Q:GMVIDATE'>0!$S(GMVALL:(9999999-GMVIDATE)<GMVBEG,1:0)!GMVFOUND D SETDATA1
. Q
Q
;
SETDATAR ;
N GMVCLIO
S GMVD0=0
F S GMVD0=$O(^PXRMINDX(120.5,"PI",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE,GMVD0)) Q:$L(GMVD0)'>0!GMVFOUND D
.I GMVD0=+GMVD0 D
..D F1205^GMVUTL(.GMVCLIO,GMVD0)
.I GMVD0'=+GMVD0 D
..D CLIO^GMVUTL(.GMVCLIO,GMVD0)
.S GMVCLIO(0)=$G(GMVCLIO(0)),GMVCLIO(2)=$G(GMVCLIO(2)),GMVCLIO(5)=$G(GMVCLIO(5))
.I GMVCLIO(0)=""!($P(GMVCLIO(0),U,8)="") Q
.D SETNODE
.Q
Q
;
SETDATA1 ;
N GMVCLIO
S GMVD0=0
F S GMVD0=$O(^GMR(120.5,"AA",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE,GMVD0)) Q:$L(GMVD0)'>0!GMVFOUND D
.I GMVD0=+GMVD0 D
.I $P($G(^GMR(120.5,GMVD0,2)),U,1)'=1 Q ;not an error
.D F1205^GMVUTL(.GMVCLIO,GMVD0,1)
.S GMVCLIO(0)=$G(GMVCLIO(0)),GMVCLIO(2)=$G(GMVCLIO(2)),GMVCLIO(5)=$G(GMVCLIO(5))
.I GMVCLIO(0)=""!($P(GMVCLIO(0),U,8)="") Q
.D SETNODE
.Q
Q
SETNODE ;
S GMVDATA=GMVCLIO(0)
S GMVDATA2=GMVCLIO(2)
S GMVRATE=$P(GMVDATA,U,8)
I GMVALL=0,"^REFUSED^PASS^UNAVAILABLE^"[(U_$$UP^XLFSTR(GMVRATE)_U) Q
I GMVEER=0,(($P(GMVDATA2,U)>0)!($P(GMVDATA2,U,2)>0)) Q
I GMVABBR="PO2",$P(GMVDATA,U,10)]"" D
. ; *** Decode Supplemental O2 field (#1.4) ***
. N GMVFRATE,GMVPCENT,GMVSUPO2
. S GMVSUPO2=$$LOW^XLFSTR($TR($P(GMVDATA,U,10)," "))
. S GMVFRATE=$S(GMVSUPO2["l/min":$P(GMVSUPO2,"l/min"),1:"")
. S GMVFRATE=$TR(GMVFRATE,$TR(GMVFRATE,".0123456789"))
. S GMVPCENT=$S(GMVSUPO2["%":$P(GMVSUPO2,"%"),1:"")
. S GMVPCENT=$S(GMVPCENT["l/min":$P(GMVPCENT,"l/min",2),GMVPCENT=+GMVPCENT:GMVPCENT,1:"")
. S GMVPCENT=$TR(GMVPCENT,$TR(GMVPCENT,".0123456789"))
. S GMVRATE=GMVRATE_";"_GMVFRATE_";"_GMVPCENT
. Q
I 'GMVALL,GMVABBR="P" D I 'GMVOK Q
. ; *** Include selected pulse types (latest vitals only) ***
. S GMVOK=0
. F GMVPULSE=1:1 Q:$P(GMVCLIO(5),U,GMVPULSE)="" D Q:GMVOK
.. I $D(GMVPULSE(+$P(GMVCLIO(5),U,GMVPULSE))) S GMVOK=1
.. Q
. Q
I 'GMVALL S GMVFOUND=1
S GMVALUE=$$CNV^GMVDCCNV(GMVRATE,GMVMSYS,"G",$P(GMVABBR(GMVABBR),U,2))
S @RESULT@(GMVD0)=GMVD0_U_$P(GMVDATA,U)_U_$P(GMVDATA,U,2)_U_$P(GMVABBR(GMVABBR),U,GMVFMT)_U_$P(GMVDATA,U,4)_U_$P(GMVDATA,U,5)_U_$P(GMVDATA,U,6)_U_GMVALUE_U_$P(GMVDATA2,U)_U_$P(GMVDATA2,U,2)_U
K GMVQL
F GMVD1=1:1 Q:$P(GMVCLIO(5),U,GMVD1)="" D
. S GMVQD0=$P(GMVCLIO(5),U,GMVD1)
. S GMVQD1=+$O(^GMRD(120.52,GMVQD0,1,"B",GMVABBR(GMVABBR),0))
. S GMVCD0=+$P($G(^GMRD(120.52,GMVQD0,1,GMVQD1,0)),U,2)
. S GMVCAT=$P($G(^GMRD(120.53,GMVCD0,0)),U)
. S GMVCAT=$S(GMVCAT]"":GMVCAT,1:" ")
. S GMVQUA=$G(^GMRD(120.52,GMVQD0,0))
. S GMVQUA(1)=GMVQD0,GMVQUA(2)=$P(GMVQUA,U,2),GMVQUA(3)=$P(GMVQUA,U)
. S GMVCD1=+$O(^GMRD(120.53,"AA",+GMVABBR(GMVABBR),GMVCAT,GMVCD0,0))
. S GMVPOR=1+$P($G(^GMRD(120.53,GMVCD0,1,GMVCD1,0)),U,5)
. I $G(GMVQUA(GMVFMT))]"" D
.. S GMVQL(GMVPOR,GMVCAT)=$G(GMVQL(GMVPOR,GMVCAT))_GMVQUA(GMVFMT)_";"
.. Q
. Q
S GMVPOR=0
F S GMVPOR=$O(GMVQL(GMVPOR)) Q:GMVPOR'>0 D
. S GMVCAT=""
. F S GMVCAT=$O(GMVQL(GMVPOR,GMVCAT)) Q:GMVCAT="" D
.. S @RESULT@(GMVD0)=@RESULT@(GMVD0)_GMVQL(GMVPOR,GMVCAT)
.. Q
. Q
S @RESULT@(GMVD0)=$$FIXUP(@RESULT@(GMVD0))
S GMVER(0)=";"_$$GET1^DID(120.506,.01,"","POINTER")
F GMVD1=1:1 Q:$P($P(GMVCLIO(2),U,3),"~",GMVD1)="" D
. S GMVER=$P($P(GMVCLIO(2),U,3),"~",GMVD1)
. I GMVER(0)[(";"_GMVER_":") D
.. I GMVFMT<3 S @RESULT@(GMVD0)=@RESULT@(GMVD0)_GMVER_";"
.. E S @RESULT@(GMVD0)=@RESULT@(GMVD0)_$P($P(GMVER(0),";"_GMVER_":",2),";")_";"
.. Q
. Q
S @RESULT@(GMVD0)=$$FIXUP(@RESULT@(GMVD0))
Q
;
FIXUP(X) ;
Q $S($E(X,$L(X))=";":$E(X,1,$L(X)-1),1:X)_U
;
PULSE ;;Pulse types to include in the latest vitals extract
;;APICAL
;;BRACHIAL
;;RADIAL
;;
GMVDCEXT ;HOIFO/DAD,FT-VITALS COMPONENT: EXTRACT PATIENT DATA ;6/13/07
+1 ;;5.0;GEN. MED. REC. - VITALS;**23**;Oct 31, 2002;Build 25
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #4290 - ^PXRMINDX global (controlled)
+5 ; #10035 - FILE 2 references (supported)
+6 ; #10104 - ^XLFSTR calls (supported)
+7 ;
+8 ; This routine supports the following IAs:
+9 ; #4251 - EN1 entry point (private)
+10 ;
EN1(RESULT,GMVDFN,GMVFMT,GMVABR,GMVALL,GMVBEG,GMVEND,GMVMSYS,GMVEER) ;
+1 ; Return patient vitals
+2 ;
+3 ; Input:
+4 ; RESULT = Where data is returned (closed array reference) (Required)
+5 ; GMVDFN = A pointer to the Patient file (#2) (Required)
+6 ; GMVFMT = Format of returned data (Optional)
+7 ; 1 - IENs (default), 2 - Abbreviations, 3 - Full Names
+8 ; GMVABR = Abbreviations of vital types to return (Optional)
+9 ; "^T^P^R^PO2^BP^HT^WT^CVP^CG^PN^" (Default GMVALL = 0)
+10 ; "~ALL~" to return all vital types (Default GMVALL = 1)
+11 ; GMVALL = Controls what data is returned (Optional)
+12 ; 0 - Most recent (default), 1 - All in date range
+13 ; GMVBEG = Beginning date for all vitals (Not used for GMVALL = 0)
+14 ; GMVEND = Ending date for all vitals (Not used for GMVALL = 0)
+15 ; GMVMSYS = Measurement system (Optional)
+16 ; M = Metric, C - US Customary (Default)
+17 ; GMVEER = Include entered in error records (Optional)
+18 ; (0 - No (Default), 1 - Yes)
+19 ;
+20 ; Output:
+21 ; RESULT() = VitalMeasurementIEN ^ DateTimeTaken ^ PatientDFN ^
+22 ; VitalType ^ DateTimeEntered ^ HospitalLocation ^
+23 ; EnteredBy ^ Measurement ^ EnteredInError ^
+24 ; EnteredInErrorBy ^
+25 ; Qualifier1 ; Qualifier2 ; ... ^
+26 ; EnteredInErrorReason1 ; EnteredInErrorReason2 ; ... ^
+27 ;
+28 NEW GMV,GMVABBR,GMVALUE,GMVCAT,GMVCD0,GMVCD1,GMVD0,GMVD1,GMVDATA
+29 NEW GMVDATA2,GMVER,GMVFOUND,GMVIDATE,GMVOK,GMVPOR,GMVPULSE,GMVQD0
+30 NEW GMVQD1,GMVQUA,GMVQL
+31 NEW GMVRATE,GMVRET
+32 KILL @RESULT
+33 SET @RESULT@(0)="OK"
+34 SET GMVALL=$SELECT("^0^1^"[(U_$GET(GMVALL)_U):GMVALL,1:0)
+35 SET GMVFMT=$SELECT("^1^2^3^"[(U_$GET(GMVFMT)_U):GMVFMT,1:1)
+36 SET GMVEER=$SELECT(GMVALL=0:0,"^0^1^"[(U_$GET(GMVEER)_U):GMVEER,1:0)
+37 IF $$FIND1^DIC(2,"","","`"_GMVDFN)'=GMVDFN
Begin DoDot:1
+38 SET @RESULT@(0)="ERROR"
+39 SET @RESULT@(1)="ERROR: Missing or invalid Patient parameter"
+40 QUIT
End DoDot:1
+41 SET GMVMSYS=$$MEASYS^GMVDCUTL($GET(GMVMSYS))
+42 KILL GMVRET
+43 DO DT^DILF("ST",$GET(GMVEND),.GMVRET,"-NOW")
+44 SET GMVEND=$GET(GMVRET)
+45 KILL GMVRET
+46 DO DT^DILF("ST",$GET(GMVBEG),.GMVRET,-GMVEND)
+47 SET GMVBEG=$GET(GMVRET)
IF GMVBEG>0
SET GMVBEG=GMVBEG-.000001
+48 IF GMVALL&((GMVBEG'>0)!(GMVEND'>0))
Begin DoDot:1
+49 SET @RESULT@(0)="ERROR"
+50 SET @RESULT@(2)="ERROR: Missing or invalid Date Range parameters"
+51 QUIT
End DoDot:1
+52 IF $GET(@RESULT@(0))="ERROR"
QUIT
+53 SET GMVABBR=$SELECT($GET(GMVABR)]"":GMVABR,GMVALL=1:"~ALL~",1:"^T^P^R^PO2^BP^HT^WT^CVP^CG^PN^")
+54 IF GMVABBR="~ALL~"
Begin DoDot:1
+55 SET GMVD0=0
SET GMVABBR=U
+56 FOR
SET GMVD0=$ORDER(^GMRD(120.51,GMVD0))
IF GMVD0'>0
QUIT
Begin DoDot:2
+57 SET GMVABBR(0)=$PIECE($GET(^GMRD(120.51,GMVD0,0)),U,2)
+58 IF GMVABBR(0)]""
SET GMVABBR=GMVABBR_GMVABBR(0)_U
+59 QUIT
End DoDot:2
+60 QUIT
End DoDot:1
+61 SET GMVABBR=$SELECT($EXTRACT(GMVABBR)'=U:U,1:"")_GMVABBR_$SELECT($EXTRACT(GMVABBR,$LENGTH(GMVABBR))'=U:U,1:"")
+62 FOR GMV=2:1:$LENGTH(GMVABBR,U)-1
SET GMVABBR(0)=$PIECE(GMVABBR,U,GMV)
Begin DoDot:1
+63 IF $SELECT(GMVABBR(0)="":1,$ORDER(^GMRD(120.51,"C",GMVABBR(0),0))>0:1,1:0)
QUIT
+64 IF GMVABBR(0)'=+GMVABBR(0)
SET GMVABBR(0)=+$ORDER(^GMRD(120.51,"B",GMVABBR(0),0))
+65 SET GMVABBR(0)=$PIECE($GET(^GMRD(120.51,GMVABBR(0),0)),U,2)
+66 SET $PIECE(GMVABBR,U,GMV)=GMVABBR(0)
+67 QUIT
End DoDot:1
+68 FOR GMV=1:1
SET GMVPULSE=$PIECE($TEXT(PULSE+GMV),";;",2)
IF GMVPULSE=""
QUIT
Begin DoDot:1
+69 SET GMVD0=0
+70 FOR
SET GMVD0=$ORDER(^GMRD(120.52,"B",GMVPULSE,GMVD0))
IF GMVD0'>0
QUIT
Begin DoDot:2
+71 IF $PIECE($GET(^GMRD(120.52,GMVD0,0)),U)=GMVPULSE
SET GMVPULSE(GMVD0)=GMVPULSE
SET GMVPULSE(GMVPULSE)=GMVD0
+72 QUIT
End DoDot:2
+73 QUIT
End DoDot:1
+74 SET GMVD0=0
+75 FOR
SET GMVD0=$ORDER(^GMRD(120.51,GMVD0))
IF GMVD0'>0
QUIT
Begin DoDot:1
+76 SET GMVABBR(0)=$GET(^GMRD(120.51,GMVD0,0))
+77 IF GMVABBR[(U_$PIECE(GMVABBR(0),U,2)_U)
SET GMVABBR($PIECE(GMVABBR(0),U,2))=GMVD0_U_$PIECE(GMVABBR(0),U,2)_U_$PIECE(GMVABBR(0),U)
+78 QUIT
End DoDot:1
+79 SET GMVABBR=""
+80 FOR
SET GMVABBR=$ORDER(GMVABBR(GMVABBR))
IF GMVABBR=""
QUIT
IF GMVABBR(GMVABBR)>0
Begin DoDot:1
+81 SET GMVFOUND=0
+82 SET GMVIDATE=$SELECT(GMVALL:GMVBEG,1:0)
+83 IF GMVALL=1
FOR
SET GMVIDATE=$ORDER(^PXRMINDX(120.5,"PI",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE))
IF GMVIDATE'>0!$SELECT(GMVALL
QUIT
DO SETDATAR
+84 IF GMVALL=0
SET GMVIDATE=GMVEND+.000001
FOR
SET GMVIDATE=$ORDER(^PXRMINDX(120.5,"PI",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE),-1)
IF GMVIDATE'>0!(GMVFOUND)!(GMVIDATE<GMVBEG)
QUIT
DO SETDATAR
+85 IF GMVEER=0
QUIT
+86 SET GMVIDATE=$SELECT(GMVALL:9999999-GMVEND,1:0)
+87 FOR
SET GMVIDATE=$ORDER(^GMR(120.5,"AA",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE))
IF GMVIDATE'>0!$SELECT(GMVALL
QUIT
DO SETDATA1
+88 QUIT
End DoDot:1
+89 QUIT
+90 ;
SETDATAR ;
+1 NEW GMVCLIO
+2 SET GMVD0=0
+3 FOR
SET GMVD0=$ORDER(^PXRMINDX(120.5,"PI",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE,GMVD0))
IF $LENGTH(GMVD0)'>0!GMVFOUND
QUIT
Begin DoDot:1
+4 IF GMVD0=+GMVD0
Begin DoDot:2
+5 DO F1205^GMVUTL(.GMVCLIO,GMVD0)
End DoDot:2
+6 IF GMVD0'=+GMVD0
Begin DoDot:2
+7 DO CLIO^GMVUTL(.GMVCLIO,GMVD0)
End DoDot:2
+8 SET GMVCLIO(0)=$GET(GMVCLIO(0))
SET GMVCLIO(2)=$GET(GMVCLIO(2))
SET GMVCLIO(5)=$GET(GMVCLIO(5))
+9 IF GMVCLIO(0)=""!($PIECE(GMVCLIO(0),U,8)="")
QUIT
+10 DO SETNODE
+11 QUIT
End DoDot:1
+12 QUIT
+13 ;
SETDATA1 ;
+1 NEW GMVCLIO
+2 SET GMVD0=0
+3 FOR
SET GMVD0=$ORDER(^GMR(120.5,"AA",GMVDFN,+GMVABBR(GMVABBR),GMVIDATE,GMVD0))
IF $LENGTH(GMVD0)'>0!GMVFOUND
QUIT
Begin DoDot:1
+4 IF GMVD0=+GMVD0
Begin DoDot:2
End DoDot:2
+5 ;not an error
IF $PIECE($GET(^GMR(120.5,GMVD0,2)),U,1)'=1
QUIT
+6 DO F1205^GMVUTL(.GMVCLIO,GMVD0,1)
+7 SET GMVCLIO(0)=$GET(GMVCLIO(0))
SET GMVCLIO(2)=$GET(GMVCLIO(2))
SET GMVCLIO(5)=$GET(GMVCLIO(5))
+8 IF GMVCLIO(0)=""!($PIECE(GMVCLIO(0),U,8)="")
QUIT
+9 DO SETNODE
+10 QUIT
End DoDot:1
+11 QUIT
SETNODE ;
+1 SET GMVDATA=GMVCLIO(0)
+2 SET GMVDATA2=GMVCLIO(2)
+3 SET GMVRATE=$PIECE(GMVDATA,U,8)
+4 IF GMVALL=0
IF "^REFUSED^PASS^UNAVAILABLE^"[(U_$$UP^XLFSTR(GMVRATE)_U)
QUIT
+5 IF GMVEER=0
IF (($PIECE(GMVDATA2,U)>0)!($PIECE(GMVDATA2,U,2)>0))
QUIT
+6 IF GMVABBR="PO2"
IF $PIECE(GMVDATA,U,10)]""
Begin DoDot:1
+7 ; *** Decode Supplemental O2 field (#1.4) ***
+8 NEW GMVFRATE,GMVPCENT,GMVSUPO2
+9 SET GMVSUPO2=$$LOW^XLFSTR($TRANSLATE($PIECE(GMVDATA,U,10)," "))
+10 SET GMVFRATE=$SELECT(GMVSUPO2["l/min":$PIECE(GMVSUPO2,"l/min"),1:"")
+11 SET GMVFRATE=$TRANSLATE(GMVFRATE,$TRANSLATE(GMVFRATE,".0123456789"))
+12 SET GMVPCENT=$SELECT(GMVSUPO2["%":$PIECE(GMVSUPO2,"%"),1:"")
+13 SET GMVPCENT=$SELECT(GMVPCENT["l/min":$PIECE(GMVPCENT,"l/min",2),GMVPCENT=+GMVPCENT:GMVPCENT,1:"")
+14 SET GMVPCENT=$TRANSLATE(GMVPCENT,$TRANSLATE(GMVPCENT,".0123456789"))
+15 SET GMVRATE=GMVRATE_";"_GMVFRATE_";"_GMVPCENT
+16 QUIT
End DoDot:1
+17 IF 'GMVALL
IF GMVABBR="P"
Begin DoDot:1
+18 ; *** Include selected pulse types (latest vitals only) ***
+19 SET GMVOK=0
+20 FOR GMVPULSE=1:1
IF $PIECE(GMVCLIO(5),U,GMVPULSE)=""
QUIT
Begin DoDot:2
+21 IF $DATA(GMVPULSE(+$PIECE(GMVCLIO(5),U,GMVPULSE)))
SET GMVOK=1
+22 QUIT
End DoDot:2
IF GMVOK
QUIT
+23 QUIT
End DoDot:1
IF 'GMVOK
QUIT
+24 IF 'GMVALL
SET GMVFOUND=1
+25 SET GMVALUE=$$CNV^GMVDCCNV(GMVRATE,GMVMSYS,"G",$PIECE(GMVABBR(GMVABBR),U,2))
+26 SET @RESULT@(GMVD0)=GMVD0_U_$PIECE(GMVDATA,U)_U_$PIECE(GMVDATA,U,2)_U_$PIECE(GMVABBR(GMVABBR),U,GMVFMT)_U_$PIECE(GMVDATA,U,4)_U_$PIECE(GMVDATA,U,5)_U_$PIECE(GMVDATA,U,6)_U_GMVALUE_U_$PIECE(GMVDATA2,U)_U_$PIECE(GMVDATA2,U,2)_U
+27 KILL GMVQL
+28 FOR GMVD1=1:1
IF $PIECE(GMVCLIO(5),U,GMVD1)=""
QUIT
Begin DoDot:1
+29 SET GMVQD0=$PIECE(GMVCLIO(5),U,GMVD1)
+30 SET GMVQD1=+$ORDER(^GMRD(120.52,GMVQD0,1,"B",GMVABBR(GMVABBR),0))
+31 SET GMVCD0=+$PIECE($GET(^GMRD(120.52,GMVQD0,1,GMVQD1,0)),U,2)
+32 SET GMVCAT=$PIECE($GET(^GMRD(120.53,GMVCD0,0)),U)
+33 SET GMVCAT=$SELECT(GMVCAT]"":GMVCAT,1:" ")
+34 SET GMVQUA=$GET(^GMRD(120.52,GMVQD0,0))
+35 SET GMVQUA(1)=GMVQD0
SET GMVQUA(2)=$PIECE(GMVQUA,U,2)
SET GMVQUA(3)=$PIECE(GMVQUA,U)
+36 SET GMVCD1=+$ORDER(^GMRD(120.53,"AA",+GMVABBR(GMVABBR),GMVCAT,GMVCD0,0))
+37 SET GMVPOR=1+$PIECE($GET(^GMRD(120.53,GMVCD0,1,GMVCD1,0)),U,5)
+38 IF $GET(GMVQUA(GMVFMT))]""
Begin DoDot:2
+39 SET GMVQL(GMVPOR,GMVCAT)=$GET(GMVQL(GMVPOR,GMVCAT))_GMVQUA(GMVFMT)_";"
+40 QUIT
End DoDot:2
+41 QUIT
End DoDot:1
+42 SET GMVPOR=0
+43 FOR
SET GMVPOR=$ORDER(GMVQL(GMVPOR))
IF GMVPOR'>0
QUIT
Begin DoDot:1
+44 SET GMVCAT=""
+45 FOR
SET GMVCAT=$ORDER(GMVQL(GMVPOR,GMVCAT))
IF GMVCAT=""
QUIT
Begin DoDot:2
+46 SET @RESULT@(GMVD0)=@RESULT@(GMVD0)_GMVQL(GMVPOR,GMVCAT)
+47 QUIT
End DoDot:2
+48 QUIT
End DoDot:1
+49 SET @RESULT@(GMVD0)=$$FIXUP(@RESULT@(GMVD0))
+50 SET GMVER(0)=";"_$$GET1^DID(120.506,.01,"","POINTER")
+51 FOR GMVD1=1:1
IF $PIECE($PIECE(GMVCLIO(2),U,3),"~",GMVD1)=""
QUIT
Begin DoDot:1
+52 SET GMVER=$PIECE($PIECE(GMVCLIO(2),U,3),"~",GMVD1)
+53 IF GMVER(0)[(";"_GMVER_":")
Begin DoDot:2
+54 IF GMVFMT<3
SET @RESULT@(GMVD0)=@RESULT@(GMVD0)_GMVER_";"
+55 IF '$TEST
SET @RESULT@(GMVD0)=@RESULT@(GMVD0)_$PIECE($PIECE(GMVER(0),";"_GMVER_":",2),";")_";"
+56 QUIT
End DoDot:2
+57 QUIT
End DoDot:1
+58 SET @RESULT@(GMVD0)=$$FIXUP(@RESULT@(GMVD0))
+59 QUIT
+60 ;
FIXUP(X) ;
+1 QUIT $SELECT($EXTRACT(X,$LENGTH(X))=";":$EXTRACT(X,1,$LENGTH(X)-1),1:X)_U
+2 ;
PULSE ;;Pulse types to include in the latest vitals extract
+1 ;;APICAL
+2 ;;BRACHIAL
+3 ;;RADIAL
+4 ;;