GMVER1 ;HOIFO/RM,YH,FT-ENTERED IN ERROR FOR A PATIENT & DATE RANGE ;12/12/01 12:36
;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
;
; This routine uses the following IAs:
; #10104 - ^XLFSTR calls (supported)
; #10103 - ^XLFDT calls (supported)
;
EN1(RESULT,GMVDFN,GMVBEG,GMVEND) ; [RPC entry point]
; Returns Entered in Error records for a date range
; Input:
; RESULT = Where data is returned (closed array reference) (Required)
; GMVDFN = A pointer to the Patient file (#2) (Required)
; GMVBEG = Beginning date for all vitals
; GMVEND = Ending date for all vitals
;
; Output:
; RESULT() = TMP global address with the nodes of report text
; The TMP global nodes are:
; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,1)=date/time of the error, Vital
; type, name of user
; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,2)=error reason
; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,3)=revised data, if any (optional)
; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,4)=the incorrect data
;
S GMRVITY=0
K ^TMP($J,"LIST"),^TMP($J,"ERRORS")
F S GMRVITY=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY)) Q:GMRVITY'>0 F GMRVDT=0:0 S GMRVDT=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT)) Q:GMRVDT'>0 S GMRVDATE=9999999-GMRVDT I GMRVDATE'<GMVBEG,GMRVDATE'>GMVEND D SORT
S GMRDATE=0
F S GMRDATE=$O(^TMP($J,"LIST",GMRDATE)) Q:GMRDATE'>0 F GMRVITY=0:0 S GMRVITY=$O(^TMP($J,"LIST",GMRDATE,GMRVITY)) Q:GMRVITY'>0 F GMRVDA=0:0 S GMRVDA=$O(^TMP($J,"LIST",GMRDATE,GMRVITY,GMRVDA)) Q:GMRVDA'>0 D WRT
Q ; KILL VARIABLES
K BADRATE,GOODRATE,GMRDAT,GMRDATE,GMRPR,GMRVDA,GMRVDATE,GMRVDT,GMRVERR,GMVEND,GMRVITY,GMVBEG,GMRVX,GMRP,GMRTYPE
K GREASON,GMRZZ,GMRVARY,GMRQUAL,GMRVPO,GMVNODE,GMVSPACE,^TMP($J,"LIST")
I '$D(^TMP($J,"ERRORS")) S ^TMP($J,"ERRORS",0)="No data for the time period indicated."
S RESULT=$NA(^TMP($J,"ERRORS"))
Q
SORT ; loop through the AA x-ref and find patient entries marked as
; entered in error (i.e., node 2 exists).
S GMRVERR=0
F S GMRVERR=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT,GMRVERR)) Q:GMRVERR'>0 I '$D(^GMR(120.5,GMRVERR,2)) Q
S GMRVDA=0
F S GMRVDA=$O(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT,GMRVDA)) Q:GMRVDA'>0 I $D(^GMR(120.5,GMRVDA,2)) S ^TMP($J,"LIST",GMRVDATE,GMRVITY,GMRVDA)=GMRVERR
Q
WRT ;
S GMRVERR=^TMP($J,"LIST",GMRDATE,GMRVITY,GMRVDA)
S GMRDAT("GOOD")=$S($D(^GMR(120.5,+GMRVERR,0)):^(0),1:"")
I $D(^GMR(120.5,+GMRVERR,0)) D
.K GMRVX
.S GMRVX=$P(^GMRD(120.51,GMRVITY,0),"^",2)
.S GMRVX(0)=$P(GMRDAT("GOOD"),"^",8)
.D:GMRVX(0)>0!(GMRVX(0)=0) EN1^GMVSAS0
.S GMRVX(1)=$S('$D(GMRVX(1)):"",'GMRVX(1):"",1:"*")
.S GMRVX(0)=$$WRTDAT(GMRVX,GMRVX(0))
.S GMRZZ=""
.I $P($G(^GMR(120.5,GMRVERR,5,0)),"^",4)>0 D
..K GMRVARY
..S GMRVARY=""
..D CHAR^GMVCHAR(GMRVERR,.GMRVARY,GMRVITY)
..S GMRZZ=$$WRITECH^GMVCHAR(GMRVERR,.GMRVARY,9)
..S:GMRZZ'=""&(GMRVX'="PO2") GMRZZ=" ("_GMRZZ_")"
..Q
. I GMRVX="P" D
..I GMRZZ'="",GMRVX(0)=1 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)=""
..I GMRZZ'="",GMRVX(0)=0 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)="*"
..Q
.S GMRVPO=$P(^GMR(120.5,GMRVERR,0),"^",10)
.S $P(GMRDAT("GOOD"),"^",8)=GMRVX(0)_GMRVX(1)_$S(GMRVPO'="":" with supplemental O2 "_$S(GMRVPO["l/min":$P(GMRVPO," l/min")_"L/min",1:"")_$S(GMRVPO["l/min":$P(GMRVPO," l/min",2),1:GMRVPO),1:"")_$S(GMRZZ'=""&(GMRVX="PO2"):" via ",1:"")_GMRZZ
.Q
I $D(^GMR(120.5,+GMRVDA,0)) D
.S GMRDAT("BAD")=$S($D(^GMR(120.5,+GMRVDA,0)):^(0),1:"")
.K GMRVX,GMRVX(0),GMRVX(1)
.S GMRVX=$P(^GMRD(120.51,GMRVITY,0),"^",2)
.S GMRVX(0)=$P(GMRDAT("BAD"),"^",8)
.D:GMRVX(0)>0 EN1^GMVSAS0
.S GMRVX(1)=$S('$D(GMRVX(1)):"",'GMRVX(1):"",1:"*")
.S GMRVX(0)=$$WRTDAT(GMRVX,GMRVX(0))
.S GMRZZ=""
.I $P($G(^GMR(120.5,GMRVDA,5,0)),"^",4)>0 D
..K GMRVARY
..S GMRVARY=""
..D CHAR^GMVCHAR(GMRVDA,.GMRVARY,GMRVITY)
..S GMRZZ=$$WRITECH^GMVCHAR(GMRVDA,.GMRVARY,9)
..S:GMRZZ'=""&(GMRVX'="PO2") GMRZZ=" ("_GMRZZ_")"
..Q
.I GMRVX="P" D
..I GMRZZ'="",GMRVX(0)=1 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)=""
..I GMRZZ'="",GMRVX(0)=0 S:$F(GMRZZ,"DORSALIS PEDIS")>0 GMRVX(1)="*"
..Q
.S GMRVPO=$P(^GMR(120.5,GMRVDA,0),"^",10)
.S $P(GMRDAT("BAD"),"^",8)=GMRVX(0)_GMRVX(1)_$S(GMRVPO'="":" with supplemental O2 "_$S(GMRVPO["l/min":$P(GMRVPO," l/min")_"L/min",1:"")_$S(GMRVPO["l/min":$P(GMRVPO," l/min",2),1:GMRVPO),1:"")_$S(GMRZZ'=""&(GMRVX="PO2"):" via ",1:"")_GMRZZ
.S GREASON="" D ERREASON
S GMRPR("VSDT")=$$FMTE^XLFDT(GMRDATE)
S GMRPR("ENUS")=$E($$PERSON^GMVUTL1(+$P(GMRDAT("BAD"),U,6)),1,21)
S GMRPR("TYPE")=$S(GMRVITY="":"",$D(^GMRD(120.51,GMRVITY,0)):$P(^(0),"^"),1:"")
S GMVNODE=""
S GMVSPACE=$$REPEAT^XLFSTR(" ",79) ;line of spaces
S GMVNODE=GMRPR("VSDT")
S GMVNODE=GMVNODE_$$FILLER^GMVUTL1(21,$L(GMVNODE),GMVSPACE)_GMRPR("TYPE")
S GMVNODE=GMVNODE_$$FILLER^GMVUTL1(58,$L(GMVNODE),GMVSPACE)_GMRPR("ENUS")
S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,1)=GMVNODE
S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,2)=" Reason: "_GREASON
S GMVNODE=""
I $G(GMRVERR)>0 S GMVNODE=" (Revised) "_$P(GMRDAT("GOOD"),"^",8) D
.I GMRVX="PN" D
..S GOODRATE=$P(GMRDAT("GOOD"),U,8)
..S GMVNODE=GMVNODE_$S(GOODRATE=0:" No pain",GOODRATE=10:" Worst imaginable pain",GOODRATE=99:" Unable to respond",1:"")
..Q
.Q
I $L(GMVNODE)>0 D
.S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,3)=GMVNODE
.Q
S GMVNODE=""
I GMRVDA>0 S GMVNODE=" (Bad data) "_$P(GMRDAT("BAD"),"^",8) D
.I GMRVX="PN" D
..S BADRATE=$P(GMRDAT("BAD"),U,8)
..S GMVNODE=GMVNODE_$S(BADRATE=0:" No pain",BADRATE=10:" Worst imaginable pain",BADRATE=99:" Unable to respond",1:"")
..Q
.Q
I $L(GMVNODE)>0 D
.S ^TMP($J,"ERRORS",GMRDATE,GMRVITY,GMRVDA,4)=GMVNODE
.Q
Q
ERREASON ;ERROR REASON
Q:'$D(^GMR(120.5,+GMRVDA,2.1))
S GER=0
F S GER=$O(^GMR(120.5,+GMRVDA,2.1,GER)) Q:GER'>0 S GER(1)=+$G(^GMR(120.5,+GMRVDA,2.1,GER,0)) D
.S GER(2)=$S(GER(1)=1:"incorrect date/time",GER(1)=2:"incorrect reading",GER(1)=3:"incorrect patient",GER(1)=4:"invalid record",1:"")
.I GER(2)'="" S GREASON=GREASON_$S(GREASON'="":", ",1:"")_GER(2)
.Q
K GER
Q
WRTDAT(TYPE,DATA) ;
I '((TYPE="BP")!(TYPE="P")!(TYPE="R")),DATA>0 D @($$UP^XLFSTR(TYPE))
Q DATA
T S DATA=DATA_" F ("_$J(+DATA-32*5/9,0,1)_" C)" Q
WT S DATA=DATA_" lb ("_$J(DATA/2.2,0,2)_" kg)" Q
HT S DATA=$S(DATA\12:DATA\12_" ft ",1:"")_$S(DATA#12:DATA#12_" in",1:"")_" ("_$J(DATA*2.54,0,2)_" cm)" Q
CG S DATA=DATA_" in ("_$J(+DATA/.3937,0,2)_" cm)" Q
CVP S DATA=DATA_" cmH2O ("_$J(DATA/1.36,0,1)_" mmHg)" Q
PO2 S DATA=DATA_"%" Q
PN I DATA=0 S DATA=DATA_" No pain " Q
I DATA=99 S DATA=DATA_" Unable to respond " Q
I DATA=10 S DATA=DATA_" Worst imaginable pain " Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMVER1 6652 printed Dec 13, 2024@01:58:42 Page 2
GMVER1 ;HOIFO/RM,YH,FT-ENTERED IN ERROR FOR A PATIENT & DATE RANGE ;12/12/01 12:36
+1 ;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #10104 - ^XLFSTR calls (supported)
+5 ; #10103 - ^XLFDT calls (supported)
+6 ;
EN1(RESULT,GMVDFN,GMVBEG,GMVEND) ; [RPC entry point]
+1 ; Returns Entered in Error records for a date range
+2 ; Input:
+3 ; RESULT = Where data is returned (closed array reference) (Required)
+4 ; GMVDFN = A pointer to the Patient file (#2) (Required)
+5 ; GMVBEG = Beginning date for all vitals
+6 ; GMVEND = Ending date for all vitals
+7 ;
+8 ; Output:
+9 ; RESULT() = TMP global address with the nodes of report text
+10 ; The TMP global nodes are:
+11 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,1)=date/time of the error, Vital
+12 ; type, name of user
+13 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,2)=error reason
+14 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,3)=revised data, if any (optional)
+15 ; ^TMP($J,GMRDATE,GMRVITY,GMRVDA,4)=the incorrect data
+16 ;
+17 SET GMRVITY=0
+18 KILL ^TMP($JOB,"LIST"),^TMP($JOB,"ERRORS")
+19 FOR
SET GMRVITY=$ORDER(^GMR(120.5,"AA",GMVDFN,GMRVITY))
if GMRVITY'>0
QUIT
FOR GMRVDT=0:0
SET GMRVDT=$ORDER(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT))
if GMRVDT'>0
QUIT
SET GMRVDATE=9999999-GMRVDT
IF GMRVDATE'<GMVBEG
IF GMRVDATE'>GMVEND
DO SORT
+20 SET GMRDATE=0
+21 FOR
SET GMRDATE=$ORDER(^TMP($JOB,"LIST",GMRDATE))
if GMRDATE'>0
QUIT
FOR GMRVITY=0:0
SET GMRVITY=$ORDER(^TMP($JOB,"LIST",GMRDATE,GMRVITY))
if GMRVITY'>0
QUIT
FOR GMRVDA=0:0
SET GMRVDA=$ORDER(^TMP($JOB,"LIST",GMRDATE,GMRVITY,GMRVDA))
if GMRVDA'>0
QUIT
DO WRT
Q ; KILL VARIABLES
+1 KILL BADRATE,GOODRATE,GMRDAT,GMRDATE,GMRPR,GMRVDA,GMRVDATE,GMRVDT,GMRVERR,GMVEND,GMRVITY,GMVBEG,GMRVX,GMRP,GMRTYPE
+2 KILL GREASON,GMRZZ,GMRVARY,GMRQUAL,GMRVPO,GMVNODE,GMVSPACE,^TMP($JOB,"LIST")
+3 IF '$DATA(^TMP($JOB,"ERRORS"))
SET ^TMP($JOB,"ERRORS",0)="No data for the time period indicated."
+4 SET RESULT=$NAME(^TMP($JOB,"ERRORS"))
+5 QUIT
SORT ; loop through the AA x-ref and find patient entries marked as
+1 ; entered in error (i.e., node 2 exists).
+2 SET GMRVERR=0
+3 FOR
SET GMRVERR=$ORDER(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT,GMRVERR))
if GMRVERR'>0
QUIT
IF '$DATA(^GMR(120.5,GMRVERR,2))
QUIT
+4 SET GMRVDA=0
+5 FOR
SET GMRVDA=$ORDER(^GMR(120.5,"AA",GMVDFN,GMRVITY,GMRVDT,GMRVDA))
if GMRVDA'>0
QUIT
IF $DATA(^GMR(120.5,GMRVDA,2))
SET ^TMP($JOB,"LIST",GMRVDATE,GMRVITY,GMRVDA)=GMRVERR
+6 QUIT
WRT ;
+1 SET GMRVERR=^TMP($JOB,"LIST",GMRDATE,GMRVITY,GMRVDA)
+2 SET GMRDAT("GOOD")=$SELECT($DATA(^GMR(120.5,+GMRVERR,0)):^(0),1:"")
+3 IF $DATA(^GMR(120.5,+GMRVERR,0))
Begin DoDot:1
+4 KILL GMRVX
+5 SET GMRVX=$PIECE(^GMRD(120.51,GMRVITY,0),"^",2)
+6 SET GMRVX(0)=$PIECE(GMRDAT("GOOD"),"^",8)
+7 if GMRVX(0)>0!(GMRVX(0)=0)
DO EN1^GMVSAS0
+8 SET GMRVX(1)=$SELECT('$DATA(GMRVX(1)):"",'GMRVX(1):"",1:"*")
+9 SET GMRVX(0)=$$WRTDAT(GMRVX,GMRVX(0))
+10 SET GMRZZ=""
+11 IF $PIECE($GET(^GMR(120.5,GMRVERR,5,0)),"^",4)>0
Begin DoDot:2
+12 KILL GMRVARY
+13 SET GMRVARY=""
+14 DO CHAR^GMVCHAR(GMRVERR,.GMRVARY,GMRVITY)
+15 SET GMRZZ=$$WRITECH^GMVCHAR(GMRVERR,.GMRVARY,9)
+16 if GMRZZ'=""&(GMRVX'="PO2")
SET GMRZZ=" ("_GMRZZ_")"
+17 QUIT
End DoDot:2
+18 IF GMRVX="P"
Begin DoDot:2
+19 IF GMRZZ'=""
IF GMRVX(0)=1
if $FIND(GMRZZ,"DORSALIS PEDIS")>0
SET GMRVX(1)=""
+20 IF GMRZZ'=""
IF GMRVX(0)=0
if $FIND(GMRZZ,"DORSALIS PEDIS")>0
SET GMRVX(1)="*"
+21 QUIT
End DoDot:2
+22 SET GMRVPO=$PIECE(^GMR(120.5,GMRVERR,0),"^",10)
+23 SET $PIECE(GMRDAT("GOOD"),"^",8)=GMRVX(0)_GMRVX(1)_$SELECT(GMRVPO'="":" with supplemental O2 "_$SELECT(GMRVPO["l/min":...
... $PIECE(GMRVPO," l/min")_"L/min",1:"")_$SELECT(GMRVPO["l/min":$PIECE(GMRVPO," l/min",2),1:GMRVPO),1:"")_$SELECT(GMRZZ'=""&(GMRVX="PO2"):" via ",1:"")_GMRZZ
+24 QUIT
End DoDot:1
+25 IF $DATA(^GMR(120.5,+GMRVDA,0))
Begin DoDot:1
+26 SET GMRDAT("BAD")=$SELECT($DATA(^GMR(120.5,+GMRVDA,0)):^(0),1:"")
+27 KILL GMRVX,GMRVX(0),GMRVX(1)
+28 SET GMRVX=$PIECE(^GMRD(120.51,GMRVITY,0),"^",2)
+29 SET GMRVX(0)=$PIECE(GMRDAT("BAD"),"^",8)
+30 if GMRVX(0)>0
DO EN1^GMVSAS0
+31 SET GMRVX(1)=$SELECT('$DATA(GMRVX(1)):"",'GMRVX(1):"",1:"*")
+32 SET GMRVX(0)=$$WRTDAT(GMRVX,GMRVX(0))
+33 SET GMRZZ=""
+34 IF $PIECE($GET(^GMR(120.5,GMRVDA,5,0)),"^",4)>0
Begin DoDot:2
+35 KILL GMRVARY
+36 SET GMRVARY=""
+37 DO CHAR^GMVCHAR(GMRVDA,.GMRVARY,GMRVITY)
+38 SET GMRZZ=$$WRITECH^GMVCHAR(GMRVDA,.GMRVARY,9)
+39 if GMRZZ'=""&(GMRVX'="PO2")
SET GMRZZ=" ("_GMRZZ_")"
+40 QUIT
End DoDot:2
+41 IF GMRVX="P"
Begin DoDot:2
+42 IF GMRZZ'=""
IF GMRVX(0)=1
if $FIND(GMRZZ,"DORSALIS PEDIS")>0
SET GMRVX(1)=""
+43 IF GMRZZ'=""
IF GMRVX(0)=0
if $FIND(GMRZZ,"DORSALIS PEDIS")>0
SET GMRVX(1)="*"
+44 QUIT
End DoDot:2
+45 SET GMRVPO=$PIECE(^GMR(120.5,GMRVDA,0),"^",10)
+46 SET $PIECE(GMRDAT("BAD"),"^",8)=GMRVX(0)_GMRVX(1)_$SELECT(GMRVPO'="":" with supplemental O2 "_$SELECT(GMRVPO["l/min":...
... $PIECE(GMRVPO," l/min")_"L/min",1:"")_$SELECT(GMRVPO["l/min":$PIECE(GMRVPO," l/min",2),1:GMRVPO),1:"")_$SELECT(GMRZZ'=""&(GMRVX="PO2"):" via ",1:"")_GMRZZ
+47 SET GREASON=""
DO ERREASON
End DoDot:1
+48 SET GMRPR("VSDT")=$$FMTE^XLFDT(GMRDATE)
+49 SET GMRPR("ENUS")=$EXTRACT($$PERSON^GMVUTL1(+$PIECE(GMRDAT("BAD"),U,6)),1,21)
+50 SET GMRPR("TYPE")=$SELECT(GMRVITY="":"",$DATA(^GMRD(120.51,GMRVITY,0)):$PIECE(^(0),"^"),1:"")
+51 SET GMVNODE=""
+52 ;line of spaces
SET GMVSPACE=$$REPEAT^XLFSTR(" ",79)
+53 SET GMVNODE=GMRPR("VSDT")
+54 SET GMVNODE=GMVNODE_$$FILLER^GMVUTL1(21,$LENGTH(GMVNODE),GMVSPACE)_GMRPR("TYPE")
+55 SET GMVNODE=GMVNODE_$$FILLER^GMVUTL1(58,$LENGTH(GMVNODE),GMVSPACE)_GMRPR("ENUS")
+56 SET ^TMP($JOB,"ERRORS",GMRDATE,GMRVITY,GMRVDA,1)=GMVNODE
+57 SET ^TMP($JOB,"ERRORS",GMRDATE,GMRVITY,GMRVDA,2)=" Reason: "_GREASON
+58 SET GMVNODE=""
+59 IF $GET(GMRVERR)>0
SET GMVNODE=" (Revised) "_$PIECE(GMRDAT("GOOD"),"^",8)
Begin DoDot:1
+60 IF GMRVX="PN"
Begin DoDot:2
+61 SET GOODRATE=$PIECE(GMRDAT("GOOD"),U,8)
+62 SET GMVNODE=GMVNODE_$SELECT(GOODRATE=0:" No pain",GOODRATE=10:" Worst imaginable pain",GOODRATE=99:" Unable to respond",1:"")
+63 QUIT
End DoDot:2
+64 QUIT
End DoDot:1
+65 IF $LENGTH(GMVNODE)>0
Begin DoDot:1
+66 SET ^TMP($JOB,"ERRORS",GMRDATE,GMRVITY,GMRVDA,3)=GMVNODE
+67 QUIT
End DoDot:1
+68 SET GMVNODE=""
+69 IF GMRVDA>0
SET GMVNODE=" (Bad data) "_$PIECE(GMRDAT("BAD"),"^",8)
Begin DoDot:1
+70 IF GMRVX="PN"
Begin DoDot:2
+71 SET BADRATE=$PIECE(GMRDAT("BAD"),U,8)
+72 SET GMVNODE=GMVNODE_$SELECT(BADRATE=0:" No pain",BADRATE=10:" Worst imaginable pain",BADRATE=99:" Unable to respond",1:"")
+73 QUIT
End DoDot:2
+74 QUIT
End DoDot:1
+75 IF $LENGTH(GMVNODE)>0
Begin DoDot:1
+76 SET ^TMP($JOB,"ERRORS",GMRDATE,GMRVITY,GMRVDA,4)=GMVNODE
+77 QUIT
End DoDot:1
+78 QUIT
ERREASON ;ERROR REASON
+1 if '$DATA(^GMR(120.5,+GMRVDA,2.1))
QUIT
+2 SET GER=0
+3 FOR
SET GER=$ORDER(^GMR(120.5,+GMRVDA,2.1,GER))
if GER'>0
QUIT
SET GER(1)=+$GET(^GMR(120.5,+GMRVDA,2.1,GER,0))
Begin DoDot:1
+4 SET GER(2)=$SELECT(GER(1)=1:"incorrect date/time",GER(1)=2:"incorrect reading",GER(1)=3:"incorrect patient",GER(1)=4:"invalid record",1:"")
+5 IF GER(2)'=""
SET GREASON=GREASON_$SELECT(GREASON'="":", ",1:"")_GER(2)
+6 QUIT
End DoDot:1
+7 KILL GER
+8 QUIT
WRTDAT(TYPE,DATA) ;
+1 IF '((TYPE="BP")!(TYPE="P")!(TYPE="R"))
IF DATA>0
DO @($$UP^XLFSTR(TYPE))
+2 QUIT DATA
T SET DATA=DATA_" F ("_$JUSTIFY(+DATA-32*5/9,0,1)_" C)"
QUIT
WT SET DATA=DATA_" lb ("_$JUSTIFY(DATA/2.2,0,2)_" kg)"
QUIT
HT SET DATA=$SELECT(DATA\12:DATA\12_" ft ",1:"")_$SELECT(DATA#12:DATA#12_" in",1:"")_" ("_$JUSTIFY(DATA*2.54,0,2)_" cm)"
QUIT
CG SET DATA=DATA_" in ("_$JUSTIFY(+DATA/.3937,0,2)_" cm)"
QUIT
CVP SET DATA=DATA_" cmH2O ("_$JUSTIFY(DATA/1.36,0,1)_" mmHg)"
QUIT
PO2 SET DATA=DATA_"%"
QUIT
PN IF DATA=0
SET DATA=DATA_" No pain "
QUIT
+1 IF DATA=99
SET DATA=DATA_" Unable to respond "
QUIT
+2 IF DATA=10
SET DATA=DATA_" Worst imaginable pain "
QUIT
+3 QUIT