ORQQVI ; slc/STAFF - Functions which return patient vital and I/O data ;31-Dec-2012 10:33;PLS
;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,198,215,250,260,285,1010**;Dec 17, 1997;Build 47
;Modified - IHS/MSC/MGH - 10/23/2012 - Line VITAL+2
VITALS(ORY,DFN,ORSDT,OREDT) ; return patient's vital measurements taken between start date/time and end date/time
;ORY: return variable, results are returned in the format:
; vital measurement ien^vital type^date/time taken^rate
;DFN: patient identifier from Patient File [#2]
;ORSDT: start date/time in Fileman format
;OREDT: end date/time in Fileman format
;DBIA for PXRMINDX(120.5 is 4290
;DBIA for ^GMVPXRM is 3647
;DBIA for ^GMRVUT0 is 1446
K ^UTILITY($J,"GMRVD")
S GMRVSTR="BP;HT;WT;T;R;P;PN" ;dee 2/12/99 added PN
S GMRVSTR(0)=ORSDT_"^"_OREDT_"^"_"^"
D EN1^GMRVUT0
N ORT,ORD,ORI,I
S ORT="",ORD=0,ORI=0,I=0
F S ORT=$O(^UTILITY($J,"GMRVD",ORT)) Q:ORT="" D
.F S ORD=$O(^UTILITY($J,"GMRVD",ORT,ORD)) Q:ORD<1 D
..F S ORI=$O(^UTILITY($J,"GMRVD",ORT,ORD,ORI)) Q:ORI<1 D
...S I=I+1
...S ORY(I)=ORI_"^"_ORT_"^"_$P(^UTILITY($J,"GMRVD",ORT,ORD,ORI),"^",8)_"^"_$P(^(ORI),"^")
I I=0 S ORY(1)="^No vitals found."
K GMRVSTR
Q
;
XFASTVIT(ORY,DFN,F1,F2) ; return patient's most recent vital measurements
;ORY: return variable, results are returned in the format:
; vital measurement ien^vital type^rate^date/time taken
;DFN: patient identifier from Patient File [#2]
; F1 & F2 are ignored
;
N CNT
S CNT=0
D VITAL("TEMPERATURE","T",DFN,.ORY,.CNT)
D VITAL("PULSE","P",DFN,.ORY,.CNT)
D VITAL("RESPIRATION","R",DFN,.ORY,.CNT)
D VITAL("BLOOD PRESSURE","BP",DFN,.ORY,.CNT)
D VITAL("HEIGHT","HT",DFN,.ORY,.CNT)
D VITAL("WEIGHT","WT",DFN,.ORY,.CNT)
D VITAL("PAIN","PN",DFN,ORY,.CNT) ;dee 2/11/99
Q
;
XVITAL(VITAL,ABBREV,DFN,ORY,CNT) ; get vital measurement
N DATA,IDT,IEN,OK,VTYPE
S VTYPE=$$FIND1^DIC(120.51,"","BX",VITAL,"","","ERR")
I 'VTYPE Q
S OK=0,IDT=0 F S IDT=$O(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT),-1) Q:IDT<1 D Q:OK
.S IEN="" F S IEN=$O(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT,IEN)) Q:$L(IEN)<1 D Q:OK
..D EN^GMVPXRM(.DATA,IEN,"I")
..I $P(DATA(1),U)=-1 Q
..S CNT=CNT+1,OK=1
..S ORY(CNT)=IEN_U_ABBREV_U_$P(DATA(7),U)_U_$P(DATA(1),U)
Q
;
NOTEVIT(ORY,DFN,NOTEIEN) ;
N VSTR,NOTEDATE
D NOTEVSTR^ORWPCE(.VSTR,NOTEIEN)
Q:$P(VSTR,";",2)=""
D FASTVIT(.ORY,DFN,$P(VSTR,";",2))
Q
;
FASTVIT(ORY,DFN,F1,F2) ; return patient's most recent vital measurements
; in date range
;ORY: return variable, results are returned in the format:
; vital measurement ien^vital type^rate^date/time taken
;DFN: patient identifier from Patient File [#2]
; F1: starting date/time range
; F2: ending date/time range
;
N CNT,DT1,DT2
S CNT=0
I $G(F1)>0 D
. I $G(F2)="",F1["." S DT1=$P(F1,".",1)_"."_$E($P(F1,".",2),1,4)
. E S DT1=F1
E S DT1=1
S DT2=$S($G(F2)>0:F2,DT1>1:DT1,1:9999998)
;
D VITAL("TEMPERATURE","T",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("PULSE","P",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("RESPIRATION","R",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("BLOOD PRESSURE","BP",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("HEIGHT","HT",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("WEIGHT","WT",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("PAIN","PN",DFN,.ORY,.CNT,DT1,DT2) ;dee 2/11/99
D VITAL("PULSE OXIMETRY","PO2",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("CENTRAL VENOUS PRESSURE","CVP",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("CIRCUMFERENCE/GIRTH","CG",DFN,.ORY,.CNT,DT1,DT2)
D VITAL("BODY MASS INDEX","BMI",DFN,.ORY,.CNT,DT1,DT2)
Q
;
VITAL(VITAL,ABBREV,DFN,ORY,CNT,F1,F2) ;
;get most recent vital measurement in date range
;IHS/MSC/MGH Get vitals from V Measurement file
I DUZ("AG")="I" D MSR(VITAL,ABBREV,DFN,.ORY,CNT,F1,F2) Q
I ABBREV="BMI" D BMILAST^ORWGAPIX(DFN,.ORY,.CNT) Q
N DATA,IDT,ENDIDT,IEN,LOOP,OK,QUALS,VTYPE,MVAL,VALUE
S VTYPE=$$FIND1^DIC(120.51,"","BX",VITAL,"","","ERR")
I 'VTYPE Q
S OK=0
S IDT=F2+$S(F2#1:.0000001,1:.7)
S ENDIDT=F1-.0000001
F S IDT=$O(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT),-1) Q:IDT<ENDIDT!'IDT D Q:OK
.S IEN="" F S IEN=$O(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT,IEN)) Q:$L(IEN)<1 D Q:OK
..D EN^GMVPXRM(.DATA,IEN,"B")
..I $P(DATA(1),U)=-1 Q
..S CNT=CNT+1,OK=1,VALUE=$P(DATA(7),U)
..S QUALS(CNT)=""
..F LOOP=1:1 Q:'$D(DATA(12,LOOP)) D
...S QUALS(CNT)=QUALS(CNT)_$S(QUALS(CNT)="":"",1:",")_$P(DATA(12,LOOP),U,2)
..; changed to display 'POX' rather than 'PO2' per CQ 10592
..S ORY(CNT)=IEN_U_$S(ABBREV="PO2":"POX",1:ABBREV)_U_VALUE_U_$P(DATA(1),U)
..I $P(ORY(CNT),"^",2)="T" D ; Temperature.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" F",1:"")
...S MVAL=+VALUE
...Q:'MVAL
...S MVAL=MVAL-32
...S MVAL=$J((MVAL*(5/9)),3,1)
...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" C)"
..I $P(ORY(CNT),"^",2)="P" D ; Pulse.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..I $P(ORY(CNT),"^",2)="R" D ; Respiration.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..I $P(ORY(CNT),"^",2)="BP" D ; Blood Pressure.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..I $P(ORY(CNT),"^",2)="HT" D ; Height.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" in",1:"")
...S MVAL=+VALUE
...Q:'MVAL
...S MVAL=$J((MVAL*2.54),3,1)
...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" cm)"
..I $P(ORY(CNT),"^",2)="WT" D ; Weight.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" lb",1:"")
...S MVAL=+VALUE
...Q:'MVAL
...; changed 2.2 to 2.20462262 per CQ 10637
...S MVAL=$J((MVAL/2.20462262),3,1)
...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" kg)"
..I $P(ORY(CNT),"^",2)="PN" D ; Pain
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..; looks for 'POX' rather than 'PO2' due to change for CQ 10592 above
..I $P(ORY(CNT),"^",2)="POX" D ; Pulse Oximetry.
...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
...S $P(ORY(CNT),U,8)=$P(DATA(8),U)
..I $P(ORY(CNT),"^",2)="CVP" D ; Central Venous Pressure.
...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
...S MVAL=$P(ORY(CNT),"^",3)
...I MVAL'=+MVAL,+MVAL=0 S ORY(CNT)=ORY(CNT)_"^",$P(ORY(CNT),U,7)="" Q
...S MVAL=$J((MVAL/1.36),3,1)
...S ORY(CNT)=ORY(CNT)_" cmH20^("_MVAL_" mmHg)"
..I $P(ORY(CNT),"^",2)="CG" D ; Circumference Girth.
...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
...S MVAL=$P(ORY(CNT),"^",3)
...I MVAL'=+MVAL,+MVAL=0 S ORY(CNT)=ORY(CNT)_"^",$P(ORY(CNT),U,7)="" Q
...S MVAL=$J((MVAL*2.54),3,1)
...S ORY(CNT)=ORY(CNT)_" in^("_MVAL_" cm)"
..S $P(ORY(CNT),U,7)=QUALS(CNT)
Q
MSR(VITAL,ABBREV,DFN,ORY,CNT,F1,F2) ;EP-
;I ABBREV="BMI" D BMILAST^ORWGAPIX(DFN,.ORY,.CNT) Q
I ABBREV="BMI" Q
N DATA,IDT,ENDIDT,IEN,LOOP,OK,QUALS,VTYPE,MVAL,VALUE
S ABBREV=$S(ABBREV="T":"TMP",ABBREV="P":"PU",ABBREV="R":"RS",ABBREV="PN":"PA",ABBREV="PO2":"O2",1:ABBREV)
S VTYPE=$$FIND1^DIC(9999999.07,"","BX",ABBREV,"","","ERR")
I 'VTYPE Q
S OK=0
S IDT=F2+$S(F2#1:.0000001,1:.7)
S ENDIDT=F1-.0000001
F S IDT=$O(^PXRMINDX(9000010.01,"PI",DFN,VTYPE,IDT),-1) Q:IDT<ENDIDT!'IDT D Q:OK
.S IEN="" F S IEN=$O(^PXRMINDX(9000010.01,"PI",DFN,VTYPE,IDT,IEN)) Q:$L(IEN)<1 D Q:OK
..D VMEA^BPXRMPX(.DATA,IEN,"B")
..I $P(DATA(1),U)=-1 Q
..S CNT=CNT+1,OK=1,VALUE=$P(DATA(7),U)
..S QUALS(CNT)=""
..F LOOP=1:1 Q:'$D(DATA(12,LOOP)) D
...S QUALS(CNT)=QUALS(CNT)_$S(QUALS(CNT)="":"",1:",")_$P(DATA(12,LOOP),U,2)
..; changed to display 'POX' rather than 'PO2' per CQ 10592
..S ORY(CNT)=IEN_U_$S(ABBREV="PO2":"O2",1:ABBREV)_U_VALUE_U_$P(DATA(1),U)
..I $P(ORY(CNT),"^",2)="TMP" D ; Temperature.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" F",1:"")
...S MVAL=+VALUE
...Q:'MVAL
...S MVAL=MVAL-32
...S MVAL=$J((MVAL*(5/9)),3,1)
...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" C)"
..I $P(ORY(CNT),"^",2)="PU" D ; Pulse.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..I $P(ORY(CNT),"^",2)="RS" D ; Respiration.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..I $P(ORY(CNT),"^",2)="BP" D ; Blood Pressure.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..I $P(ORY(CNT),"^",2)="HT" D ; Height.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" in",1:"")
...S MVAL=+VALUE
...Q:'MVAL
...S MVAL=$J((MVAL*2.54),3,1)
...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" cm)"
..I $P(ORY(CNT),"^",2)="WT" D ; Weight.
...S ORY(CNT)=ORY(CNT)_"^"_VALUE_$S($E(VALUE):" lb",1:"")
...S MVAL=+VALUE
...Q:'MVAL
...; changed 2.2 to 2.20462262 per CQ 10637
...S MVAL=$J((MVAL/2.20462262),3,1)
...S ORY(CNT)=ORY(CNT)_"^("_MVAL_" kg)"
..I $P(ORY(CNT),"^",2)="PA" D ; Pain
...S ORY(CNT)=ORY(CNT)_"^"_VALUE
..; looks for 'POX' rather than 'PO2' due to change for CQ 10592 above
..I $P(ORY(CNT),"^",2)="O2" D ; Pulse Oximetry.
...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
...S $P(ORY(CNT),U,8)=$P(DATA(8),U)
..I $P(ORY(CNT),"^",2)="CVP" D ; Central Venous Pressure.
...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
...S MVAL=$P(ORY(CNT),"^",3)
...I MVAL'=+MVAL,+MVAL=0 S ORY(CNT)=ORY(CNT)_"^",$P(ORY(CNT),U,7)="" Q
...S MVAL=$J((MVAL/1.36),3,1)
...S ORY(CNT)=ORY(CNT)_" cmH20^("_MVAL_" mmHg)"
..I $P(ORY(CNT),"^",2)="CG" D ; Circumference Girth.
...S ORY(CNT)=ORY(CNT)_"^"_$P(ORY(CNT),"^",3)
...S MVAL=$P(ORY(CNT),"^",3)
...I MVAL'=+MVAL,+MVAL=0 S ORY(CNT)=ORY(CNT)_"^",$P(ORY(CNT),U,7)="" Q
...S MVAL=$J((MVAL*2.54),3,1)
...S ORY(CNT)=ORY(CNT)_" in^("_MVAL_" cm)"
..S $P(ORY(CNT),U,7)=QUALS(CNT)
Q
ORQQVI ; slc/STAFF - Functions which return patient vital and I/O data ;31-Dec-2012 10:33;PLS
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,198,215,250,260,285,1010**;Dec 17, 1997;Build 47
+2 ;Modified - IHS/MSC/MGH - 10/23/2012 - Line VITAL+2
VITALS(ORY,DFN,ORSDT,OREDT) ; return patient's vital measurements taken between start date/time and end date/time
+1 ;ORY: return variable, results are returned in the format:
+2 ; vital measurement ien^vital type^date/time taken^rate
+3 ;DFN: patient identifier from Patient File [#2]
+4 ;ORSDT: start date/time in Fileman format
+5 ;OREDT: end date/time in Fileman format
+6 ;DBIA for PXRMINDX(120.5 is 4290
+7 ;DBIA for ^GMVPXRM is 3647
+8 ;DBIA for ^GMRVUT0 is 1446
+9 KILL ^UTILITY($JOB,"GMRVD")
+10 ;dee 2/12/99 added PN
SET GMRVSTR="BP;HT;WT;T;R;P;PN"
+11 SET GMRVSTR(0)=ORSDT_"^"_OREDT_"^"_"^"
+12 DO EN1^GMRVUT0
+13 NEW ORT,ORD,ORI,I
+14 SET ORT=""
SET ORD=0
SET ORI=0
SET I=0
+15 FOR
SET ORT=$ORDER(^UTILITY($JOB,"GMRVD",ORT))
IF ORT=""
QUIT
Begin DoDot:1
+16 FOR
SET ORD=$ORDER(^UTILITY($JOB,"GMRVD",ORT,ORD))
IF ORD<1
QUIT
Begin DoDot:2
+17 FOR
SET ORI=$ORDER(^UTILITY($JOB,"GMRVD",ORT,ORD,ORI))
IF ORI<1
QUIT
Begin DoDot:3
+18 SET I=I+1
+19 SET ORY(I)=ORI_"^"_ORT_"^"_$PIECE(^UTILITY($JOB,"GMRVD",ORT,ORD,ORI),"^",8)_"^"_$PIECE(^(ORI),"^")
End DoDot:3
End DoDot:2
End DoDot:1
+20 IF I=0
SET ORY(1)="^No vitals found."
+21 KILL GMRVSTR
+22 QUIT
+23 ;
XFASTVIT(ORY,DFN,F1,F2) ; return patient's most recent vital measurements
+1 ;ORY: return variable, results are returned in the format:
+2 ; vital measurement ien^vital type^rate^date/time taken
+3 ;DFN: patient identifier from Patient File [#2]
+4 ; F1 & F2 are ignored
+5 ;
+6 NEW CNT
+7 SET CNT=0
+8 DO VITAL("TEMPERATURE","T",DFN,.ORY,.CNT)
+9 DO VITAL("PULSE","P",DFN,.ORY,.CNT)
+10 DO VITAL("RESPIRATION","R",DFN,.ORY,.CNT)
+11 DO VITAL("BLOOD PRESSURE","BP",DFN,.ORY,.CNT)
+12 DO VITAL("HEIGHT","HT",DFN,.ORY,.CNT)
+13 DO VITAL("WEIGHT","WT",DFN,.ORY,.CNT)
+14 ;dee 2/11/99
DO VITAL("PAIN","PN",DFN,ORY,.CNT)
+15 QUIT
+16 ;
XVITAL(VITAL,ABBREV,DFN,ORY,CNT) ; get vital measurement
+1 NEW DATA,IDT,IEN,OK,VTYPE
+2 SET VTYPE=$$FIND1^DIC(120.51,"","BX",VITAL,"","","ERR")
+3 IF 'VTYPE
QUIT
+4 SET OK=0
SET IDT=0
FOR
SET IDT=$ORDER(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT),-1)
IF IDT<1
QUIT
Begin DoDot:1
+5 SET IEN=""
FOR
SET IEN=$ORDER(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT,IEN))
IF $LENGTH(IEN)<1
QUIT
Begin DoDot:2
+6 DO EN^GMVPXRM(.DATA,IEN,"I")
+7 IF $PIECE(DATA(1),U)=-1
QUIT
+8 SET CNT=CNT+1
SET OK=1
+9 SET ORY(CNT)=IEN_U_ABBREV_U_$PIECE(DATA(7),U)_U_$PIECE(DATA(1),U)
End DoDot:2
IF OK
QUIT
End DoDot:1
IF OK
QUIT
+10 QUIT
+11 ;
NOTEVIT(ORY,DFN,NOTEIEN) ;
+1 NEW VSTR,NOTEDATE
+2 DO NOTEVSTR^ORWPCE(.VSTR,NOTEIEN)
+3 IF $PIECE(VSTR,";",2)=""
QUIT
+4 DO FASTVIT(.ORY,DFN,$PIECE(VSTR,";",2))
+5 QUIT
+6 ;
FASTVIT(ORY,DFN,F1,F2) ; return patient's most recent vital measurements
+1 ; in date range
+2 ;ORY: return variable, results are returned in the format:
+3 ; vital measurement ien^vital type^rate^date/time taken
+4 ;DFN: patient identifier from Patient File [#2]
+5 ; F1: starting date/time range
+6 ; F2: ending date/time range
+7 ;
+8 NEW CNT,DT1,DT2
+9 SET CNT=0
+10 IF $GET(F1)>0
Begin DoDot:1
+11 IF $GET(F2)=""
IF F1["."
SET DT1=$PIECE(F1,".",1)_"."_$EXTRACT($PIECE(F1,".",2),1,4)
+12 IF '$TEST
SET DT1=F1
End DoDot:1
+13 IF '$TEST
SET DT1=1
+14 SET DT2=$SELECT($GET(F2)>0:F2,DT1>1:DT1,1:9999998)
+15 ;
+16 DO VITAL("TEMPERATURE","T",DFN,.ORY,.CNT,DT1,DT2)
+17 DO VITAL("PULSE","P",DFN,.ORY,.CNT,DT1,DT2)
+18 DO VITAL("RESPIRATION","R",DFN,.ORY,.CNT,DT1,DT2)
+19 DO VITAL("BLOOD PRESSURE","BP",DFN,.ORY,.CNT,DT1,DT2)
+20 DO VITAL("HEIGHT","HT",DFN,.ORY,.CNT,DT1,DT2)
+21 DO VITAL("WEIGHT","WT",DFN,.ORY,.CNT,DT1,DT2)
+22 ;dee 2/11/99
DO VITAL("PAIN","PN",DFN,.ORY,.CNT,DT1,DT2)
+23 DO VITAL("PULSE OXIMETRY","PO2",DFN,.ORY,.CNT,DT1,DT2)
+24 DO VITAL("CENTRAL VENOUS PRESSURE","CVP",DFN,.ORY,.CNT,DT1,DT2)
+25 DO VITAL("CIRCUMFERENCE/GIRTH","CG",DFN,.ORY,.CNT,DT1,DT2)
+26 DO VITAL("BODY MASS INDEX","BMI",DFN,.ORY,.CNT,DT1,DT2)
+27 QUIT
+28 ;
VITAL(VITAL,ABBREV,DFN,ORY,CNT,F1,F2) ;
+1 ;get most recent vital measurement in date range
+2 ;IHS/MSC/MGH Get vitals from V Measurement file
+3 IF DUZ("AG")="I"
DO MSR(VITAL,ABBREV,DFN,.ORY,CNT,F1,F2)
QUIT
+4 IF ABBREV="BMI"
DO BMILAST^ORWGAPIX(DFN,.ORY,.CNT)
QUIT
+5 NEW DATA,IDT,ENDIDT,IEN,LOOP,OK,QUALS,VTYPE,MVAL,VALUE
+6 SET VTYPE=$$FIND1^DIC(120.51,"","BX",VITAL,"","","ERR")
+7 IF 'VTYPE
QUIT
+8 SET OK=0
+9 SET IDT=F2+$SELECT(F2#1:.0000001,1:.7)
+10 SET ENDIDT=F1-.0000001
+11 FOR
SET IDT=$ORDER(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT),-1)
IF IDT<ENDIDT!'IDT
QUIT
Begin DoDot:1
+12 SET IEN=""
FOR
SET IEN=$ORDER(^PXRMINDX(120.5,"PI",DFN,VTYPE,IDT,IEN))
IF $LENGTH(IEN)<1
QUIT
Begin DoDot:2
+13 DO EN^GMVPXRM(.DATA,IEN,"B")
+14 IF $PIECE(DATA(1),U)=-1
QUIT
+15 SET CNT=CNT+1
SET OK=1
SET VALUE=$PIECE(DATA(7),U)
+16 SET QUALS(CNT)=""
+17 FOR LOOP=1:1
IF '$DATA(DATA(12,LOOP))
QUIT
Begin DoDot:3
+18 SET QUALS(CNT)=QUALS(CNT)_$SELECT(QUALS(CNT)="":"",1:",")_$PIECE(DATA(12,LOOP),U,2)
End DoDot:3
+19 ; changed to display 'POX' rather than 'PO2' per CQ 10592
+20 SET ORY(CNT)=IEN_U_$SELECT(ABBREV="PO2":"POX",1:ABBREV)_U_VALUE_U_$PIECE(DATA(1),U)
+21 ; Temperature.
IF $PIECE(ORY(CNT),"^",2)="T"
Begin DoDot:3
+22 SET ORY(CNT)=ORY(CNT)_"^"_VALUE_$SELECT($EXTRACT(VALUE):" F",1:"")
+23 SET MVAL=+VALUE
+24 IF 'MVAL
QUIT
+25 SET MVAL=MVAL-32
+26 SET MVAL=$JUSTIFY((MVAL*(5/9)),3,1)
+27 SET ORY(CNT)=ORY(CNT)_"^("_MVAL_" C)"
End DoDot:3
+28 ; Pulse.
IF $PIECE(ORY(CNT),"^",2)="P"
Begin DoDot:3
+29 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+30 ; Respiration.
IF $PIECE(ORY(CNT),"^",2)="R"
Begin DoDot:3
+31 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+32 ; Blood Pressure.
IF $PIECE(ORY(CNT),"^",2)="BP"
Begin DoDot:3
+33 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+34 ; Height.
IF $PIECE(ORY(CNT),"^",2)="HT"
Begin DoDot:3
+35 SET ORY(CNT)=ORY(CNT)_"^"_VALUE_$SELECT($EXTRACT(VALUE):" in",1:"")
+36 SET MVAL=+VALUE
+37 IF 'MVAL
QUIT
+38 SET MVAL=$JUSTIFY((MVAL*2.54),3,1)
+39 SET ORY(CNT)=ORY(CNT)_"^("_MVAL_" cm)"
End DoDot:3
+40 ; Weight.
IF $PIECE(ORY(CNT),"^",2)="WT"
Begin DoDot:3
+41 SET ORY(CNT)=ORY(CNT)_"^"_VALUE_$SELECT($EXTRACT(VALUE):" lb",1:"")
+42 SET MVAL=+VALUE
+43 IF 'MVAL
QUIT
+44 ; changed 2.2 to 2.20462262 per CQ 10637
+45 SET MVAL=$JUSTIFY((MVAL/2.20462262),3,1)
+46 SET ORY(CNT)=ORY(CNT)_"^("_MVAL_" kg)"
End DoDot:3
+47 ; Pain
IF $PIECE(ORY(CNT),"^",2)="PN"
Begin DoDot:3
+48 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+49 ; looks for 'POX' rather than 'PO2' due to change for CQ 10592 above
+50 ; Pulse Oximetry.
IF $PIECE(ORY(CNT),"^",2)="POX"
Begin DoDot:3
+51 SET ORY(CNT)=ORY(CNT)_"^"_$PIECE(ORY(CNT),"^",3)
+52 SET $PIECE(ORY(CNT),U,8)=$PIECE(DATA(8),U)
End DoDot:3
+53 ; Central Venous Pressure.
IF $PIECE(ORY(CNT),"^",2)="CVP"
Begin DoDot:3
+54 SET ORY(CNT)=ORY(CNT)_"^"_$PIECE(ORY(CNT),"^",3)
+55 SET MVAL=$PIECE(ORY(CNT),"^",3)
+56 IF MVAL'=+MVAL
IF +MVAL=0
SET ORY(CNT)=ORY(CNT)_"^"
SET $PIECE(ORY(CNT),U,7)=""
QUIT
+57 SET MVAL=$JUSTIFY((MVAL/1.36),3,1)
+58 SET ORY(CNT)=ORY(CNT)_" cmH20^("_MVAL_" mmHg)"
End DoDot:3
+59 ; Circumference Girth.
IF $PIECE(ORY(CNT),"^",2)="CG"
Begin DoDot:3
+60 SET ORY(CNT)=ORY(CNT)_"^"_$PIECE(ORY(CNT),"^",3)
+61 SET MVAL=$PIECE(ORY(CNT),"^",3)
+62 IF MVAL'=+MVAL
IF +MVAL=0
SET ORY(CNT)=ORY(CNT)_"^"
SET $PIECE(ORY(CNT),U,7)=""
QUIT
+63 SET MVAL=$JUSTIFY((MVAL*2.54),3,1)
+64 SET ORY(CNT)=ORY(CNT)_" in^("_MVAL_" cm)"
End DoDot:3
+65 SET $PIECE(ORY(CNT),U,7)=QUALS(CNT)
End DoDot:2
IF OK
QUIT
End DoDot:1
IF OK
QUIT
+66 QUIT
MSR(VITAL,ABBREV,DFN,ORY,CNT,F1,F2) ;EP-
+1 ;I ABBREV="BMI" D BMILAST^ORWGAPIX(DFN,.ORY,.CNT) Q
+2 IF ABBREV="BMI"
QUIT
+3 NEW DATA,IDT,ENDIDT,IEN,LOOP,OK,QUALS,VTYPE,MVAL,VALUE
+4 SET ABBREV=$SELECT(ABBREV="T":"TMP",ABBREV="P":"PU",ABBREV="R":"RS",ABBREV="PN":"PA",ABBREV="PO2":"O2",1:ABBREV)
+5 SET VTYPE=$$FIND1^DIC(9999999.07,"","BX",ABBREV,"","","ERR")
+6 IF 'VTYPE
QUIT
+7 SET OK=0
+8 SET IDT=F2+$SELECT(F2#1:.0000001,1:.7)
+9 SET ENDIDT=F1-.0000001
+10 FOR
SET IDT=$ORDER(^PXRMINDX(9000010.01,"PI",DFN,VTYPE,IDT),-1)
IF IDT<ENDIDT!'IDT
QUIT
Begin DoDot:1
+11 SET IEN=""
FOR
SET IEN=$ORDER(^PXRMINDX(9000010.01,"PI",DFN,VTYPE,IDT,IEN))
IF $LENGTH(IEN)<1
QUIT
Begin DoDot:2
+12 DO VMEA^BPXRMPX(.DATA,IEN,"B")
+13 IF $PIECE(DATA(1),U)=-1
QUIT
+14 SET CNT=CNT+1
SET OK=1
SET VALUE=$PIECE(DATA(7),U)
+15 SET QUALS(CNT)=""
+16 FOR LOOP=1:1
IF '$DATA(DATA(12,LOOP))
QUIT
Begin DoDot:3
+17 SET QUALS(CNT)=QUALS(CNT)_$SELECT(QUALS(CNT)="":"",1:",")_$PIECE(DATA(12,LOOP),U,2)
End DoDot:3
+18 ; changed to display 'POX' rather than 'PO2' per CQ 10592
+19 SET ORY(CNT)=IEN_U_$SELECT(ABBREV="PO2":"O2",1:ABBREV)_U_VALUE_U_$PIECE(DATA(1),U)
+20 ; Temperature.
IF $PIECE(ORY(CNT),"^",2)="TMP"
Begin DoDot:3
+21 SET ORY(CNT)=ORY(CNT)_"^"_VALUE_$SELECT($EXTRACT(VALUE):" F",1:"")
+22 SET MVAL=+VALUE
+23 IF 'MVAL
QUIT
+24 SET MVAL=MVAL-32
+25 SET MVAL=$JUSTIFY((MVAL*(5/9)),3,1)
+26 SET ORY(CNT)=ORY(CNT)_"^("_MVAL_" C)"
End DoDot:3
+27 ; Pulse.
IF $PIECE(ORY(CNT),"^",2)="PU"
Begin DoDot:3
+28 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+29 ; Respiration.
IF $PIECE(ORY(CNT),"^",2)="RS"
Begin DoDot:3
+30 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+31 ; Blood Pressure.
IF $PIECE(ORY(CNT),"^",2)="BP"
Begin DoDot:3
+32 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+33 ; Height.
IF $PIECE(ORY(CNT),"^",2)="HT"
Begin DoDot:3
+34 SET ORY(CNT)=ORY(CNT)_"^"_VALUE_$SELECT($EXTRACT(VALUE):" in",1:"")
+35 SET MVAL=+VALUE
+36 IF 'MVAL
QUIT
+37 SET MVAL=$JUSTIFY((MVAL*2.54),3,1)
+38 SET ORY(CNT)=ORY(CNT)_"^("_MVAL_" cm)"
End DoDot:3
+39 ; Weight.
IF $PIECE(ORY(CNT),"^",2)="WT"
Begin DoDot:3
+40 SET ORY(CNT)=ORY(CNT)_"^"_VALUE_$SELECT($EXTRACT(VALUE):" lb",1:"")
+41 SET MVAL=+VALUE
+42 IF 'MVAL
QUIT
+43 ; changed 2.2 to 2.20462262 per CQ 10637
+44 SET MVAL=$JUSTIFY((MVAL/2.20462262),3,1)
+45 SET ORY(CNT)=ORY(CNT)_"^("_MVAL_" kg)"
End DoDot:3
+46 ; Pain
IF $PIECE(ORY(CNT),"^",2)="PA"
Begin DoDot:3
+47 SET ORY(CNT)=ORY(CNT)_"^"_VALUE
End DoDot:3
+48 ; looks for 'POX' rather than 'PO2' due to change for CQ 10592 above
+49 ; Pulse Oximetry.
IF $PIECE(ORY(CNT),"^",2)="O2"
Begin DoDot:3
+50 SET ORY(CNT)=ORY(CNT)_"^"_$PIECE(ORY(CNT),"^",3)
+51 SET $PIECE(ORY(CNT),U,8)=$PIECE(DATA(8),U)
End DoDot:3
+52 ; Central Venous Pressure.
IF $PIECE(ORY(CNT),"^",2)="CVP"
Begin DoDot:3
+53 SET ORY(CNT)=ORY(CNT)_"^"_$PIECE(ORY(CNT),"^",3)
+54 SET MVAL=$PIECE(ORY(CNT),"^",3)
+55 IF MVAL'=+MVAL
IF +MVAL=0
SET ORY(CNT)=ORY(CNT)_"^"
SET $PIECE(ORY(CNT),U,7)=""
QUIT
+56 SET MVAL=$JUSTIFY((MVAL/1.36),3,1)
+57 SET ORY(CNT)=ORY(CNT)_" cmH20^("_MVAL_" mmHg)"
End DoDot:3
+58 ; Circumference Girth.
IF $PIECE(ORY(CNT),"^",2)="CG"
Begin DoDot:3
+59 SET ORY(CNT)=ORY(CNT)_"^"_$PIECE(ORY(CNT),"^",3)
+60 SET MVAL=$PIECE(ORY(CNT),"^",3)
+61 IF MVAL'=+MVAL
IF +MVAL=0
SET ORY(CNT)=ORY(CNT)_"^"
SET $PIECE(ORY(CNT),U,7)=""
QUIT
+62 SET MVAL=$JUSTIFY((MVAL*2.54),3,1)
+63 SET ORY(CNT)=ORY(CNT)_" in^("_MVAL_" cm)"
End DoDot:3
+64 SET $PIECE(ORY(CNT),U,7)=QUALS(CNT)
End DoDot:2
IF OK
QUIT
End DoDot:1
IF OK
QUIT
+65 QUIT