GMVDCVAM ;HOIFO/DAD,FT-VITALS COMPONENT: VALIDATE DATA (CONT.) ;9/26/00 15:31
;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
;
; This routine uses the following IAs:
; #10104 - ^XLFSTR calls (supported)
;
DUPCHK ; *** Check for duplicate records ***
N GMVD0,GMVDATA,GMVDUP
S (GMVD0,GMVDUP)=0
D DUPCH
F S GMVD0=$O(^GMR(120.5,"AA",GMVDFN,GMVVD0,9999999-GMVDTDUN,GMVD0)) Q:(GMVD0'>0)!(GMVDUP>0) I $P($G(^GMR(120.5,GMVD0,2)),U)'>0 D
. S GMVDATA=$G(^GMR(120.5,GMVD0,0))
. I $P(GMVDATA,U,5,6)=(GMVHOSPL_U_GMVENTBY),$P(GMVDATA,U,8)=$P(GMVVMEAS,";") D DUPCH
. Q
S ^TMP($J,"GMVXREF",GMVVABBR,GMVQARRY)=""
Q
;
DUPCH ; *** Get qualifier lists for duplicate check ***
I "^BP^CG^P^R^"[(U_GMVVABBR_U) D ; Vital types allowed to have dups
. N GMVFLAG,GMVQD0,GMVSUB,GMVSUP
. I GMVD0>0 D
.. S GMVQD0=0,GMVQARRY(0)=U
.. S GMVDUP(0)=$S($O(^GMR(120.5,GMVD0,5,"B",GMVQD0))>0:1,1:0)
.. F S GMVQD0=$O(^GMR(120.5,GMVD0,5,"B",GMVQD0)) Q:GMVQD0'>0 D
... S GMVQARRY(0)=GMVQARRY(0)_GMVQD0_U
... Q
.. S GMVDUP(0)=$$DUPC(GMVQARRY(0),GMVQARRY,GMVDUP(0))
.. Q
. E D
.. S GMVQARRY(0)=""
.. S GMVDUP(0)=$S($O(^TMP($J,"GMVXREF",GMVVABBR,GMVQARRY(0)))]"":1,1:0)
.. F S GMVQARRY(0)=$O(^TMP($J,"GMVXREF",GMVVABBR,GMVQARRY(0))) Q:(GMVQARRY(0)="")!(GMVDUP(0)'>0) S GMVDUP(0)=$$DUPC(GMVQARRY(0),GMVQARRY,GMVDUP(0))
.. Q
. I GMVDUP(0)>0 D DUPMSG
. Q
E D
. I GMVD0>0 D
.. D DUPMSG
.. Q
. E D
.. I $D(^TMP($J,"GMVXREF",GMVVABBR)) D DUPMSG
.. Q
. Q
Q
;
DUPC(GMVQ1,GMVQ2,GMVDUP) ;
; *** Compare qualifiers look for duplicates ***
N GMV,GMVSUB,GMVSUP
S GMVSUP=$S($L(GMVQ1,U)>$L(GMVQ2,U):GMVQ1,1:GMVQ2)
S GMVSUB=$S($L(GMVQ1,U)<$L(GMVQ2,U):GMVQ1,1:GMVQ2)
I $L(GMVQ1,U)=$L(GMVQ2,U) S GMVSUP=GMVQ1,GMVSUB=GMVQ2
F GMV=2:1:$L(GMVSUB,U)-1 I GMVSUP'[(U_$P(GMVSUB,U,GMV)_U) S GMVDUP=0 Q
Q GMVDUP
;
DUPMSG ; *** Duplicate message ***
S GMVDUP=1
D MSG^GMVDCVAL("ERROR: Duplicate Vital Measurement data found (V^"_GMVVNUM_"="_GMVVHOLD_")")
Q
;
BP ; *** Validate Systolic only Blood Pressure data ***
I GMVVABBR'="BP" Q
I $P(GMVVMEAS,";")?1.N S GMVSYSBP=1
Q
;
PO2 ; *** Validate Supplemental O2 data ***
S GMVVMEAS("PO2")=""
I GMVVABBR'="PO2" Q
I $$OMIT(GMVVMEAS),($P(GMVVMEAS,";",2)]"")!($P(GMVVMEAS,";",3)]"") D
. D MSG^GMVDCVAL("ERROR: Supplemental O2 data not allowed if Pulse Oximetry is omitted (V^"_GMVVNUM_"="_GMVVHOLD_")")
. Q
I $P(GMVVMEAS,";",2)]"" D
. I ($P(GMVVMEAS,";",2)'<.5)&($P(GMVVMEAS,";",2)'>20) D
.. S GMVVMEAS("PO2")=$P(GMVVMEAS,";",2)_"L/min"
.. Q
. E D
.. D MSG^GMVDCVAL("ERROR: O2 Flow Rate must be in the range 0.5-20 (V^"_GMVVNUM_"="_GMVVHOLD_")")
.. Q
. Q
I $P(GMVVMEAS,";",3)]"" D
. I ($P(GMVVMEAS,";",3)'<0)&($P(GMVVMEAS,";",3)'>100) D
.. S GMVVMEAS("PO2")=GMVVMEAS("PO2")_$S(GMVVMEAS("PO2")]"":" ",1:"")_$P(GMVVMEAS,";",3)_"%"
.. Q
. E D
.. D MSG^GMVDCVAL("ERROR: Percent O2 Concentration must be in the range 0-100 (V^"_GMVVNUM_"="_GMVVHOLD_")")
.. Q
. Q
S GMVVMEAS=$P(GMVVMEAS,";")
Q
;
OMIT(GMVVMEAS) ;
; *** Determine if measurement was omitted ***
; Input:
; GMVVMEAS = A vital measurement
; Output:
; 1 - Measurement was omitted, 0 - Measurement was not omitted
Q "^UNAVAILABLE^PASS^REFUSED^"[(U_$$UP^XLFSTR($P(GMVVMEAS,";"))_U)
;
GMVDCVAM ;HOIFO/DAD,FT-VITALS COMPONENT: VALIDATE DATA (CONT.) ;9/26/00 15:31
+1 ;;5.0;GEN. MED. REC. - VITALS;;Oct 31, 2002
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #10104 - ^XLFSTR calls (supported)
+5 ;
DUPCHK ; *** Check for duplicate records ***
+1 NEW GMVD0,GMVDATA,GMVDUP
+2 SET (GMVD0,GMVDUP)=0
+3 DO DUPCH
+4 FOR
SET GMVD0=$ORDER(^GMR(120.5,"AA",GMVDFN,GMVVD0,9999999-GMVDTDUN,GMVD0))
IF (GMVD0'>0)!(GMVDUP>0)
QUIT
IF $PIECE($GET(^GMR(120.5,GMVD0,2)),U)'>0
Begin DoDot:1
+5 SET GMVDATA=$GET(^GMR(120.5,GMVD0,0))
+6 IF $PIECE(GMVDATA,U,5,6)=(GMVHOSPL_U_GMVENTBY)
IF $PIECE(GMVDATA,U,8)=$PIECE(GMVVMEAS,";")
DO DUPCH
+7 QUIT
End DoDot:1
+8 SET ^TMP($JOB,"GMVXREF",GMVVABBR,GMVQARRY)=""
+9 QUIT
+10 ;
DUPCH ; *** Get qualifier lists for duplicate check ***
+1 ; Vital types allowed to have dups
IF "^BP^CG^P^R^"[(U_GMVVABBR_U)
Begin DoDot:1
+2 NEW GMVFLAG,GMVQD0,GMVSUB,GMVSUP
+3 IF GMVD0>0
Begin DoDot:2
+4 SET GMVQD0=0
SET GMVQARRY(0)=U
+5 SET GMVDUP(0)=$SELECT($ORDER(^GMR(120.5,GMVD0,5,"B",GMVQD0))>0:1,1:0)
+6 FOR
SET GMVQD0=$ORDER(^GMR(120.5,GMVD0,5,"B",GMVQD0))
IF GMVQD0'>0
QUIT
Begin DoDot:3
+7 SET GMVQARRY(0)=GMVQARRY(0)_GMVQD0_U
+8 QUIT
End DoDot:3
+9 SET GMVDUP(0)=$$DUPC(GMVQARRY(0),GMVQARRY,GMVDUP(0))
+10 QUIT
End DoDot:2
+11 IF '$TEST
Begin DoDot:2
+12 SET GMVQARRY(0)=""
+13 SET GMVDUP(0)=$SELECT($ORDER(^TMP($JOB,"GMVXREF",GMVVABBR,GMVQARRY(0)))]"":1,1:0)
+14 FOR
SET GMVQARRY(0)=$ORDER(^TMP($JOB,"GMVXREF",GMVVABBR,GMVQARRY(0)))
IF (GMVQARRY(0)="")!(GMVDUP(0)'>0)
QUIT
SET GMVDUP(0)=$$DUPC(GMVQARRY(0),GMVQARRY,GMVDUP(0))
+15 QUIT
End DoDot:2
+16 IF GMVDUP(0)>0
DO DUPMSG
+17 QUIT
End DoDot:1
+18 IF '$TEST
Begin DoDot:1
+19 IF GMVD0>0
Begin DoDot:2
+20 DO DUPMSG
+21 QUIT
End DoDot:2
+22 IF '$TEST
Begin DoDot:2
+23 IF $DATA(^TMP($JOB,"GMVXREF",GMVVABBR))
DO DUPMSG
+24 QUIT
End DoDot:2
+25 QUIT
End DoDot:1
+26 QUIT
+27 ;
DUPC(GMVQ1,GMVQ2,GMVDUP) ;
+1 ; *** Compare qualifiers look for duplicates ***
+2 NEW GMV,GMVSUB,GMVSUP
+3 SET GMVSUP=$SELECT($LENGTH(GMVQ1,U)>$LENGTH(GMVQ2,U):GMVQ1,1:GMVQ2)
+4 SET GMVSUB=$SELECT($LENGTH(GMVQ1,U)<$LENGTH(GMVQ2,U):GMVQ1,1:GMVQ2)
+5 IF $LENGTH(GMVQ1,U)=$LENGTH(GMVQ2,U)
SET GMVSUP=GMVQ1
SET GMVSUB=GMVQ2
+6 FOR GMV=2:1:$LENGTH(GMVSUB,U)-1
IF GMVSUP'[(U_$PIECE(GMVSUB,U,GMV)_U)
SET GMVDUP=0
QUIT
+7 QUIT GMVDUP
+8 ;
DUPMSG ; *** Duplicate message ***
+1 SET GMVDUP=1
+2 DO MSG^GMVDCVAL("ERROR: Duplicate Vital Measurement data found (V^"_GMVVNUM_"="_GMVVHOLD_")")
+3 QUIT
+4 ;
BP ; *** Validate Systolic only Blood Pressure data ***
+1 IF GMVVABBR'="BP"
QUIT
+2 IF $PIECE(GMVVMEAS,";")?1.N
SET GMVSYSBP=1
+3 QUIT
+4 ;
PO2 ; *** Validate Supplemental O2 data ***
+1 SET GMVVMEAS("PO2")=""
+2 IF GMVVABBR'="PO2"
QUIT
+3 IF $$OMIT(GMVVMEAS)
IF ($PIECE(GMVVMEAS,";",2)]"")!($PIECE(GMVVMEAS,";",3)]"")
Begin DoDot:1
+4 DO MSG^GMVDCVAL("ERROR: Supplemental O2 data not allowed if Pulse Oximetry is omitted (V^"_GMVVNUM_"="_GMVVHOLD_")")
+5 QUIT
End DoDot:1
+6 IF $PIECE(GMVVMEAS,";",2)]""
Begin DoDot:1
+7 IF ($PIECE(GMVVMEAS,";",2)'<.5)&($PIECE(GMVVMEAS,";",2)'>20)
Begin DoDot:2
+8 SET GMVVMEAS("PO2")=$PIECE(GMVVMEAS,";",2)_"L/min"
+9 QUIT
End DoDot:2
+10 IF '$TEST
Begin DoDot:2
+11 DO MSG^GMVDCVAL("ERROR: O2 Flow Rate must be in the range 0.5-20 (V^"_GMVVNUM_"="_GMVVHOLD_")")
+12 QUIT
End DoDot:2
+13 QUIT
End DoDot:1
+14 IF $PIECE(GMVVMEAS,";",3)]""
Begin DoDot:1
+15 IF ($PIECE(GMVVMEAS,";",3)'<0)&($PIECE(GMVVMEAS,";",3)'>100)
Begin DoDot:2
+16 SET GMVVMEAS("PO2")=GMVVMEAS("PO2")_$SELECT(GMVVMEAS("PO2")]"":" ",1:"")_$PIECE(GMVVMEAS,";",3)_"%"
+17 QUIT
End DoDot:2
+18 IF '$TEST
Begin DoDot:2
+19 DO MSG^GMVDCVAL("ERROR: Percent O2 Concentration must be in the range 0-100 (V^"_GMVVNUM_"="_GMVVHOLD_")")
+20 QUIT
End DoDot:2
+21 QUIT
End DoDot:1
+22 SET GMVVMEAS=$PIECE(GMVVMEAS,";")
+23 QUIT
+24 ;
OMIT(GMVVMEAS) ;
+1 ; *** Determine if measurement was omitted ***
+2 ; Input:
+3 ; GMVVMEAS = A vital measurement
+4 ; Output:
+5 ; 1 - Measurement was omitted, 0 - Measurement was not omitted
+6 QUIT "^UNAVAILABLE^PASS^REFUSED^"[(U_$$UP^XLFSTR($PIECE(GMVVMEAS,";"))_U)
+7 ;