GMVUTL7 ;HIOFO/DS,FT-RPC API TO RETURN ALL VITALS/CATEGORIES/QUALIFIERS ;7/17/02 14:52
;;5.0;GEN. MED. REC. - VITALS;**3**;Oct 31, 2002
;
; This routine uses the following IAs:
; #10035 - FILE 2 references (supported)
; #10103 - ^XLFDT calls (supported)
;
; This routine supports the following IAs:
; #4355 - GMV GET CURRENT TIME RPC is called at TIME (private)
; #4359 - GMV VITALS/CAT/QUAL RPC is called at GETVITAL (private)
;
GETVITAL(RESULT,GMVLIST) ; GMV VITALS/CAT/QUAL [RPC entry point]
; Returns all vital qual info in RESULT
;GMVLIST is either "" for all vitals or a list of required eg 1^2^
N GMVNUM,GMVDATA,GMVDO,GMVLOOP
S GMVNUM=1
I GMVLIST'="" D
. F GMVLOOP=1:1:$L(GMVLIST,"^") D
.. S GMVDO=$P(GMVLIST,"^",GMVLOOP)
.. Q:GMVDO=""
.. S GMVDO=$$GETIEN(GMVDO)
.. Q:GMVDO=""
.. S RESULT(GMVNUM)=$$GETDATA(GMVDO)_"^"_$$ABBVAL(GMVDO)
.. D GETALL(GMVNUM,.RESULT)
.. S GMVNUM=GMVNUM+1
.. Q
. Q
E D
. S GMVLOOP=0
. F S GMVLOOP=$O(^GMRD(120.51,GMVLOOP)) Q:GMVLOOP'>0 D
.. S RESULT(GMVNUM)=$$GETDATA(GMVLOOP)_"^"_$$ABBVAL(GMVLOOP)
.. D GETALL(GMVNUM,.RESULT)
.. S GMVNUM=GMVNUM+1
.. Q
. Q
Q
GETALL(GMVLOOP,RESULT) ;
S GMVCNT=0
;S GMVLOOP="" F S GMVLOOP=$O(RESULT(GMVLOOP)) Q:GMVLOOP="" D
Q:$G(RESULT(GMVLOOP))=""
Q:$P(RESULT(GMVLOOP),"^",1)'="V"
S GMVITTYP=$P(RESULT(GMVLOOP),"^",2)
S GMVD2=""
S GMVCNT=GMVLOOP+.001
F S GMVD2=$O(^GMRD(120.53,"C",GMVITTYP,GMVD2)) Q:GMVD2'>0 D
. S GMVD1=0
. F S GMVD1=$O(^GMRD(120.53,"C",GMVITTYP,GMVD2,GMVD1)) Q:GMVD1'>0 D
.. S GMVDATA=$P($G(^GMRD(120.53,GMVD2,0)),U)
.. I GMVDATA]"" D
... S GMVITTYP(0)=$G(^GMRD(120.51,+GMVITTYP,0))
... S GMVITTYP(1)=GMVITTYP,GMVITTYP(2)=$P(GMVITTYP(0),U,2)
... S GMVITTYP(3)=$P(GMVITTYP(0),U)
... S GMVDEFQ=$P($G(^GMRD(120.53,GMVD2,1,GMVD1,0)),U,7)
... S GMVDEFQ(0)=$G(^GMRD(120.52,+GMVDEFQ,0))
... S GMVDEFQ(1)=GMVDEFQ,GMVDEFQ(2)=$P(GMVDEFQ(0),U,2)
... S GMVDEFQ(3)=$P(GMVDEFQ(0),U)
... S RESULT(GMVCNT)="C"_U_GMVD2_U_GMVDATA
... D GETCAT(GMVITTYP,GMVD2,.RESULT,.GMVCNT)
... S GMVCNT=GMVCNT+.001
... Q
.. Q
. Q
Q
GETDATA(GMVVITAL) ;
N GMVDATA,GMVD0,GMVD1
I $G(^GMRD(120.51,GMVVITAL,0))="" D Q GMVRES
. S GMVRES="V^"_GMVVITAL_"^ERROR"
. Q
S GMVDATA=$G(^GMRD(120.51,GMVVITAL,0))
I GMVDATA]"" S GMVRES="V"_U_GMVVITAL_U_$P(GMVDATA,U)_U_$P(GMVDATA,U,2)_U_$P(GMVDATA,U,7)
Q GMVRES
GETCAT(GMVVTP,GMVITCAT,RESULT,GMVNUM) ;
N GMVD0,GMVD1,GMVCNT
S GMVD0=0,GMVCNT=0
F S GMVD0=$O(^GMRD(120.52,"C",GMVITTYP,GMVD0)) Q:GMVD0'>0 D
. S GMVD1=0
. F S GMVD1=$O(^GMRD(120.52,"C",GMVITTYP,GMVD0,GMVD1)) Q:GMVD1'>0 D
.. S GMVCATD0=$P($G(^GMRD(120.52,GMVD0,1,GMVD1,0)),U,2)
.. I $G(GMVITCAT)>0,GMVITCAT'=GMVCATD0 Q
.. S GMVDATA=$G(^GMRD(120.52,GMVD0,0))
.. I GMVDATA]"" D
... S GMVITTYP(0)=$G(^GMRD(120.51,+GMVITTYP,0))
... S GMVITTYP(1)=GMVITTYP,GMVITTYP(2)=$P(GMVITTYP(0),U,2)
... S GMVITTYP(3)=$P(GMVITTYP(0),U)
... S GMVITCAT(0)=$G(^GMRD(120.53,+GMVCATD0,0))
... S GMVITCAT(1)=GMVCATD0,(GMVITCAT(2),GMVITCAT(3))=$P(GMVITCAT(0),U)
... S GMVNUM=GMVNUM+.001
... S RESULT(GMVNUM)="Q"_U_GMVD0_U_$P(GMVDATA,U)_U_$P(GMVDATA,U,2)
... Q
.. Q
. Q
Q
ABBVAL(VITALTYP) ;
N RESULT,GMVDATA
; Gets high low values if they exist
I $G(^GMRD(120.57,1,1))="" Q ""
S RESULT=""
S GMVDATA=$P($G(^GMRD(120.57,1,1)),U,1,13)
I VITALTYP=1 D
. ; BP
. S RESULT=$P(GMVDATA,U,7,10)
. Q
I VITALTYP=2 D
. ; Temprature
. S RESULT=$P(GMVDATA,U,1,2)
. Q
I VITALTYP=5 D
. ; Pulse
. S RESULT=$P(GMVDATA,U,3,4)
. Q
I VITALTYP=3 D
. ;Respirations
. S RESULT=$P(GMVDATA,U,5,6)
. Q
I VITALTYP=19 D
. ;CVP
. S RESULT=$P(GMVDATA,U,11,13)
. Q
Q RESULT
GETIEN(GMVABB) ; Gets IEN from the Abbreviation code.
Q $O(^GMRD(120.51,"C",GMVABB,""))
ROOMPT(RESULTS,GMVWRD,GMVRLST) ; GMV WARD/ROOM PATIENTS [RPC entry point]
; Returns a list of patients in the ward and rooms specified
; Input:
; RESULTS - name of the array to hold the patient list
; GMVWRD - name of the ward (e.g., 2EAST)
; GMVRLST - the room numbers of the ward separated by comma
; (e.g., 200,210,220)
; Output:
; RESULT(n)=patient name^DFN^DOB (external)^SSN (no hyphens)
;
; n is a sequential number beginning with 0 (zero)
N GMRVROOM,GMRVLST,GMRVCNT,GMVT,GMVDF
K RESULTS
S GMVWARD(1)=GMVWRD
I GMVRLST["," D
. F GMVA=1:1:$L(GMVRLST)+1 D
. . Q:$P(GMVRLST,",",GMVA)=""
. . S GMVROOM($P($P(GMVRLST,",",GMVA),"-"))=""
. . Q
. Q
E D
. S GMVROOM($P(GMVRLST,"-"))=""
. Q
S GMVEDB="S"
K ^TMP($J)
D WARD^GMVDS1
S GMVT="",GMVCNT=0
F S GMVT=$O(^TMP($J,GMVT)) Q:GMVT="" D
. S GMVN=""
. F S GMVN=$O(^TMP($J,GMVT,GMVN)) Q:GMVN="" D
. . S GMVDF=""
. . F S GMVDF=$O(^TMP($J,GMVT,GMVN,GMVDF)) Q:GMVDF="" D
. . . S GMVDOB=$$FMTE^XLFDT($P(^DPT(GMVDF,0),"^",3))
. . . S GMVSSN=$P(^DPT(GMVDF,0),"^",9)
. . . S RESULTS(GMVCNT)=GMVN_"^"_GMVDF_"^"_GMVDOB_"^"_GMVSSN
. . . S GMVCNT=GMVCNT+1
. . . Q
. . Q
. Q
Q
TIME(RESULT,P2) ;Gets current time
S RESULT=$$NOW^XLFDT()
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMVUTL7 5114 printed Sep 02, 2024@18:45:21 Page 2
GMVUTL7 ;HIOFO/DS,FT-RPC API TO RETURN ALL VITALS/CATEGORIES/QUALIFIERS ;7/17/02 14:52
+1 ;;5.0;GEN. MED. REC. - VITALS;**3**;Oct 31, 2002
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #10035 - FILE 2 references (supported)
+5 ; #10103 - ^XLFDT calls (supported)
+6 ;
+7 ; This routine supports the following IAs:
+8 ; #4355 - GMV GET CURRENT TIME RPC is called at TIME (private)
+9 ; #4359 - GMV VITALS/CAT/QUAL RPC is called at GETVITAL (private)
+10 ;
GETVITAL(RESULT,GMVLIST) ; GMV VITALS/CAT/QUAL [RPC entry point]
+1 ; Returns all vital qual info in RESULT
+2 ;GMVLIST is either "" for all vitals or a list of required eg 1^2^
+3 NEW GMVNUM,GMVDATA,GMVDO,GMVLOOP
+4 SET GMVNUM=1
+5 IF GMVLIST'=""
Begin DoDot:1
+6 FOR GMVLOOP=1:1:$LENGTH(GMVLIST,"^")
Begin DoDot:2
+7 SET GMVDO=$PIECE(GMVLIST,"^",GMVLOOP)
+8 if GMVDO=""
QUIT
+9 SET GMVDO=$$GETIEN(GMVDO)
+10 if GMVDO=""
QUIT
+11 SET RESULT(GMVNUM)=$$GETDATA(GMVDO)_"^"_$$ABBVAL(GMVDO)
+12 DO GETALL(GMVNUM,.RESULT)
+13 SET GMVNUM=GMVNUM+1
+14 QUIT
End DoDot:2
+15 QUIT
End DoDot:1
+16 IF '$TEST
Begin DoDot:1
+17 SET GMVLOOP=0
+18 FOR
SET GMVLOOP=$ORDER(^GMRD(120.51,GMVLOOP))
if GMVLOOP'>0
QUIT
Begin DoDot:2
+19 SET RESULT(GMVNUM)=$$GETDATA(GMVLOOP)_"^"_$$ABBVAL(GMVLOOP)
+20 DO GETALL(GMVNUM,.RESULT)
+21 SET GMVNUM=GMVNUM+1
+22 QUIT
End DoDot:2
+23 QUIT
End DoDot:1
+24 QUIT
GETALL(GMVLOOP,RESULT) ;
+1 SET GMVCNT=0
+2 ;S GMVLOOP="" F S GMVLOOP=$O(RESULT(GMVLOOP)) Q:GMVLOOP="" D
+3 if $GET(RESULT(GMVLOOP))=""
QUIT
+4 if $PIECE(RESULT(GMVLOOP),"^",1)'="V"
QUIT
+5 SET GMVITTYP=$PIECE(RESULT(GMVLOOP),"^",2)
+6 SET GMVD2=""
+7 SET GMVCNT=GMVLOOP+.001
+8 FOR
SET GMVD2=$ORDER(^GMRD(120.53,"C",GMVITTYP,GMVD2))
if GMVD2'>0
QUIT
Begin DoDot:1
+9 SET GMVD1=0
+10 FOR
SET GMVD1=$ORDER(^GMRD(120.53,"C",GMVITTYP,GMVD2,GMVD1))
if GMVD1'>0
QUIT
Begin DoDot:2
+11 SET GMVDATA=$PIECE($GET(^GMRD(120.53,GMVD2,0)),U)
+12 IF GMVDATA]""
Begin DoDot:3
+13 SET GMVITTYP(0)=$GET(^GMRD(120.51,+GMVITTYP,0))
+14 SET GMVITTYP(1)=GMVITTYP
SET GMVITTYP(2)=$PIECE(GMVITTYP(0),U,2)
+15 SET GMVITTYP(3)=$PIECE(GMVITTYP(0),U)
+16 SET GMVDEFQ=$PIECE($GET(^GMRD(120.53,GMVD2,1,GMVD1,0)),U,7)
+17 SET GMVDEFQ(0)=$GET(^GMRD(120.52,+GMVDEFQ,0))
+18 SET GMVDEFQ(1)=GMVDEFQ
SET GMVDEFQ(2)=$PIECE(GMVDEFQ(0),U,2)
+19 SET GMVDEFQ(3)=$PIECE(GMVDEFQ(0),U)
+20 SET RESULT(GMVCNT)="C"_U_GMVD2_U_GMVDATA
+21 DO GETCAT(GMVITTYP,GMVD2,.RESULT,.GMVCNT)
+22 SET GMVCNT=GMVCNT+.001
+23 QUIT
End DoDot:3
+24 QUIT
End DoDot:2
+25 QUIT
End DoDot:1
+26 QUIT
GETDATA(GMVVITAL) ;
+1 NEW GMVDATA,GMVD0,GMVD1
+2 IF $GET(^GMRD(120.51,GMVVITAL,0))=""
Begin DoDot:1
+3 SET GMVRES="V^"_GMVVITAL_"^ERROR"
+4 QUIT
End DoDot:1
QUIT GMVRES
+5 SET GMVDATA=$GET(^GMRD(120.51,GMVVITAL,0))
+6 IF GMVDATA]""
SET GMVRES="V"_U_GMVVITAL_U_$PIECE(GMVDATA,U)_U_$PIECE(GMVDATA,U,2)_U_$PIECE(GMVDATA,U,7)
+7 QUIT GMVRES
GETCAT(GMVVTP,GMVITCAT,RESULT,GMVNUM) ;
+1 NEW GMVD0,GMVD1,GMVCNT
+2 SET GMVD0=0
SET GMVCNT=0
+3 FOR
SET GMVD0=$ORDER(^GMRD(120.52,"C",GMVITTYP,GMVD0))
if GMVD0'>0
QUIT
Begin DoDot:1
+4 SET GMVD1=0
+5 FOR
SET GMVD1=$ORDER(^GMRD(120.52,"C",GMVITTYP,GMVD0,GMVD1))
if GMVD1'>0
QUIT
Begin DoDot:2
+6 SET GMVCATD0=$PIECE($GET(^GMRD(120.52,GMVD0,1,GMVD1,0)),U,2)
+7 IF $GET(GMVITCAT)>0
IF GMVITCAT'=GMVCATD0
QUIT
+8 SET GMVDATA=$GET(^GMRD(120.52,GMVD0,0))
+9 IF GMVDATA]""
Begin DoDot:3
+10 SET GMVITTYP(0)=$GET(^GMRD(120.51,+GMVITTYP,0))
+11 SET GMVITTYP(1)=GMVITTYP
SET GMVITTYP(2)=$PIECE(GMVITTYP(0),U,2)
+12 SET GMVITTYP(3)=$PIECE(GMVITTYP(0),U)
+13 SET GMVITCAT(0)=$GET(^GMRD(120.53,+GMVCATD0,0))
+14 SET GMVITCAT(1)=GMVCATD0
SET (GMVITCAT(2),GMVITCAT(3))=$PIECE(GMVITCAT(0),U)
+15 SET GMVNUM=GMVNUM+.001
+16 SET RESULT(GMVNUM)="Q"_U_GMVD0_U_$PIECE(GMVDATA,U)_U_$PIECE(GMVDATA,U,2)
+17 QUIT
End DoDot:3
+18 QUIT
End DoDot:2
+19 QUIT
End DoDot:1
+20 QUIT
ABBVAL(VITALTYP) ;
+1 NEW RESULT,GMVDATA
+2 ; Gets high low values if they exist
+3 IF $GET(^GMRD(120.57,1,1))=""
QUIT ""
+4 SET RESULT=""
+5 SET GMVDATA=$PIECE($GET(^GMRD(120.57,1,1)),U,1,13)
+6 IF VITALTYP=1
Begin DoDot:1
+7 ; BP
+8 SET RESULT=$PIECE(GMVDATA,U,7,10)
+9 QUIT
End DoDot:1
+10 IF VITALTYP=2
Begin DoDot:1
+11 ; Temprature
+12 SET RESULT=$PIECE(GMVDATA,U,1,2)
+13 QUIT
End DoDot:1
+14 IF VITALTYP=5
Begin DoDot:1
+15 ; Pulse
+16 SET RESULT=$PIECE(GMVDATA,U,3,4)
+17 QUIT
End DoDot:1
+18 IF VITALTYP=3
Begin DoDot:1
+19 ;Respirations
+20 SET RESULT=$PIECE(GMVDATA,U,5,6)
+21 QUIT
End DoDot:1
+22 IF VITALTYP=19
Begin DoDot:1
+23 ;CVP
+24 SET RESULT=$PIECE(GMVDATA,U,11,13)
+25 QUIT
End DoDot:1
+26 QUIT RESULT
GETIEN(GMVABB) ; Gets IEN from the Abbreviation code.
+1 QUIT $ORDER(^GMRD(120.51,"C",GMVABB,""))
ROOMPT(RESULTS,GMVWRD,GMVRLST) ; GMV WARD/ROOM PATIENTS [RPC entry point]
+1 ; Returns a list of patients in the ward and rooms specified
+2 ; Input:
+3 ; RESULTS - name of the array to hold the patient list
+4 ; GMVWRD - name of the ward (e.g., 2EAST)
+5 ; GMVRLST - the room numbers of the ward separated by comma
+6 ; (e.g., 200,210,220)
+7 ; Output:
+8 ; RESULT(n)=patient name^DFN^DOB (external)^SSN (no hyphens)
+9 ;
+10 ; n is a sequential number beginning with 0 (zero)
+11 NEW GMRVROOM,GMRVLST,GMRVCNT,GMVT,GMVDF
+12 KILL RESULTS
+13 SET GMVWARD(1)=GMVWRD
+14 IF GMVRLST[","
Begin DoDot:1
+15 FOR GMVA=1:1:$LENGTH(GMVRLST)+1
Begin DoDot:2
+16 if $PIECE(GMVRLST,",",GMVA)=""
QUIT
+17 SET GMVROOM($PIECE($PIECE(GMVRLST,",",GMVA),"-"))=""
+18 QUIT
End DoDot:2
+19 QUIT
End DoDot:1
+20 IF '$TEST
Begin DoDot:1
+21 SET GMVROOM($PIECE(GMVRLST,"-"))=""
+22 QUIT
End DoDot:1
+23 SET GMVEDB="S"
+24 KILL ^TMP($JOB)
+25 DO WARD^GMVDS1
+26 SET GMVT=""
SET GMVCNT=0
+27 FOR
SET GMVT=$ORDER(^TMP($JOB,GMVT))
if GMVT=""
QUIT
Begin DoDot:1
+28 SET GMVN=""
+29 FOR
SET GMVN=$ORDER(^TMP($JOB,GMVT,GMVN))
if GMVN=""
QUIT
Begin DoDot:2
+30 SET GMVDF=""
+31 FOR
SET GMVDF=$ORDER(^TMP($JOB,GMVT,GMVN,GMVDF))
if GMVDF=""
QUIT
Begin DoDot:3
+32 SET GMVDOB=$$FMTE^XLFDT($PIECE(^DPT(GMVDF,0),"^",3))
+33 SET GMVSSN=$PIECE(^DPT(GMVDF,0),"^",9)
+34 SET RESULTS(GMVCNT)=GMVN_"^"_GMVDF_"^"_GMVDOB_"^"_GMVSSN
+35 SET GMVCNT=GMVCNT+1
+36 QUIT
End DoDot:3
+37 QUIT
End DoDot:2
+38 QUIT
End DoDot:1
+39 QUIT
TIME(RESULT,P2) ;Gets current time
+1 SET RESULT=$$NOW^XLFDT()
+2 QUIT