ORQQVI2 ;SLC/dee- RPC calls to GMRVPCE0, Vitals data event drivers ;2/2/98
;;3.0;ORDER ENTRY/RESULTS REPORTING;**10**;Dec 17, 1997
;
Q
;
; ORQDATA is in the format
; ORQDATA(i)="VST^DT^encounter date" required
; ORQDATA(i)="VST^PT^pointer to patient" required
; ORQDATA(i)="VST^HL^pointer to Hospital Location" required
; ORQDATA(i)="VIT^vital type^^^value^provider^units^date/time"
; ORVITALS is the array passed to GMRV in the PCE Device Interface
; format.
; ORQVIT is an array subscipted by the index in ORVITALS that contains
; the subscript of the data gotten from ORQDATA. This is used to tell
; the caller which item had an ERROR or WARNING.
; ORRETURN(0) is 1 if no ERRORs or WARNINGs
; 0 if there are WARNING(s) but no ERRORs
; -1 if there are ERROR(s)
; ORRETURN(n) where n>0 is an error or warning in validating the data
; 1 piece: subscript of ORQDATA that the error or warning is on
; 2 piece: "ERROR" or "WARNING"
; 3 piece: text message about error or warning
; 4 piece: data item that generated the error or warning
;
VALIDATE(ORRETURN,ORQDATA) ;
; Given the array ORQDATA passed in by PCE Device Interface whose
; format is described in the PCE Device Interface documentation, this
; procedure will validate the Vitals data. If the data is invalid,
; the procedure will return the errors in the form given above.
;
N ORVITALS,ORQVIT
;Initialize RETURN to no errors
K ORRETURN
S ORRETURN(0)=1
D PREVITAL(.ORRETURN,.ORVITALS,.ORQVIT,.ORQDATA)
D VALIDATE^GMRVPCE0(.ORVITALS)
D POSTVIT(.ORRETURN,.ORQVIT,.ORVITALS)
Q
;
VALSTORE(ORRETURN,ORQDATA) ;Calls VALIDATE and if no errors calls STORE
; Given the array ORQDATA passed in by PCE Device Interface whose
; format is described in the PCE Device Interface documentation, this
; procedure will validate the Vitals data. If the data is invalid,
; the procedure will return the errors in the form given above.
; If there are no errors then this procedure will call
; Vitals/Measurements to store the data in the GMRV's
; Patient Measurements (120.5) file.
;
N ORVITALS,ORQVIT
;Initialize RETURN to no errors
K ORRETURN
S ORRETURN(0)=1
D PREVITAL(.ORRETURN,.ORVITALS,.ORQVIT,.ORQDATA)
D VALIDATE^GMRVPCE0(.ORVITALS)
D POSTVIT(.ORRETURN,.ORQVIT,.ORVITALS)
I ORRETURN(0)=1 D STORE^GMRVPCE0(.ORVITALS)
Q
;
PREVITAL(ORRETURN,ORVITALS,ORQVIT,ORQDATA) ;format array for call to Vitlals
N ORQTYPE,ORQCODE,ORINDEX1,ORINDEX2,ORRETINX,ORQITEM
N ORQNODT,ORQNOPT,ORQNOHL
S (ORQNODT,ORQNOPT,ORQNOHL)=1
S ORVITALS("SOURCE")="^"_DUZ
S ORINDEX2=0
S ORRETINX=$O(ORRETURN(""),-1)
S ORINDEX1=""
F S ORINDEX1=$O(ORQDATA(ORINDEX1)) Q:'ORINDEX1 D
. S ORQDATAX=ORQDATA(ORINDEX1),ORQTYPE=$P(ORQDATAX,"^"),ORQCODE=$P(ORQDATAX,"^",2)
. I ORQTYPE="PRV" S ORVITALS("PROVIDER",1)=ORQCODE Q
. I ORQTYPE="VST" D Q
.. I ORQCODE="DT" D Q
... S ORQNODT=0
... S ORQITEM=$P(ORQDATAX,"^",3)
... S $P(ORVITALS("ENCOUNTER"),"^",1)=ORQITEM
... I ORQITEM>$$NOW^XLFDT D
.... S ORRETINX=ORRETINX+1
.... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Date/Time entered cannot be in the future^"_$$FMTE^XLFDT(ORQITEM)
.... S ORRETURN(0)=-1
... I ORQITEM'>1800000 D
.... S ORRETINX=ORRETINX+1
.... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Encounter Date/Time not valid^"_ORQITEM
.... S ORRETURN(0)=-1
.. I ORQCODE="PT" D Q
... S ORQNOPT=0
... S ORQITEM=$P(ORQDATAX,"^",3)
... S $P(ORVITALS("ENCOUNTER"),"^",2)=ORQITEM
... I '($D(^DPT(+ORQITEM,0))#2) D
.... S ORRETINX=ORRETINX+1
.... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Patient missing or invalid in file 2^"_ORQITEM
.... S ORRETURN(0)=-1
.. I ORQCODE="HL" D Q
... S ORQNOHL=0
... S ORQITEM=$P(ORQDATAX,"^",3)
... S $P(ORVITALS("ENCOUNTER"),"^",3)=ORQITEM
... I '$D(^SC(ORQITEM,0)) D
.... S ORRETINX=ORRETINX+1
.... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^HOSPITAL LOCATION Missing is not in file 44^"_ORQITEM
.... S ORRETURN(0)=-1
...; I $D(^PX(815,1,"DHL","B",ORQITEM)) D
...;. S ORRETINX=ORRETINX+1
...;. S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^HOSPITAL LOCATION Can not be a disposition clinic^"_ORQITEM
...;. S ORRETURN(0)=-1
. I ORQTYPE="VIT" D Q
.. S ORINDEX2=ORINDEX2+1
.. S ORQVIT(ORINDEX2)=ORINDEX1
.. S ORVITALS("VITALS",+$P(ORQDATAX,"^",6),ORINDEX2)=ORQCODE_"^"_$P(ORQDATAX,"^",5)_"^"_$P(ORQDATAX,"^",7,8)
I ORQNODT D
. S ORRETINX=ORRETINX+1
. S ORRETURN(ORRETINX)="^ERROR^Required data item, ENCOUNTER DATE/TIME, is missing^"
. S ORRETURN(0)=-1
I ORQNOPT D
. S ORRETINX=ORRETINX+1
. S ORRETURN(ORRETINX)="^ERROR^Required data item, PATIENT, is missing^"
. S ORRETURN(0)=-1
I ORQNOHL D
. S ORRETINX=ORRETINX+1
. S ORRETURN(ORRETINX)="^ERROR^Required data item, HOSPITAL LOCATION, is missing^"
. S ORRETURN(0)=-1
Q
;
POSTVIT(ORRETURN,ORQVIT,ORVITALS) ;return errors and warnings
N ORVAR,ORINDEX,ORQTYPE
S ORINDEX=$O(ORRETURN(""),-1)
F ORQTYPE="WARNING","ERROR" D
. S ORVAR="ORVITALS("""_ORQTYPE_""")"
. F S ORVAR=$Q(@ORVAR) Q:ORVAR'[("ORVITALS("""_ORQTYPE_"""") D
.. S ORINDEX=ORINDEX+1
.. S ORRETURN(ORINDEX)=$G(ORQVIT($P(ORVAR,",",4)))_"^"_ORQTYPE_"^"_@ORVAR
.. I ORQTYPE="WARNING" S:ORRETURN(0)>0 ORRETURN(0)=0
.. E S ORRETURN(0)=-1
Q
;
HELP(ORQLST,ORQTYPE) ; This procedure will return help for a particular
; measurement type in an array.
; Input
; Variables: ORQTYPE=Type of measurement (abbreviation
; (req.) from PCE Device Interface Specification).
; ORQLST=Array root to store help text in
;
D HELP^GMRVPCE0(ORQTYPE,"ORQLST")
Q
;
RATECHK(ORRETURN,ORQTYPE,ORQRATE,ORQUNIT) ;
; Extrinsic function to validate the
; rate for a particular measurement
; Input
; Variables: ORQTYPE=Type of measurement (abbreviation
; (req.) from PCE Device Interface Specification).
; ORQRATE=Measurement rate to be validated.
; (req.)
; ORQUNIT=Unit of measurement for rate, if specified.
; (opt.)
; Return value: 1 if rate is valid.
; 0 if rate is invalid.
;
S ORRETURN=$$RATECHK^GMRVPCE0(ORQTYPE,ORQRATE,$G(ORQUNIT))
Q
;
VMTYPES(ORRETURN,ORQTYPE) ;
; This function returns one if ORQTYPE is a valid type abbrev.
; from the PCE Device Interface Specification.
S ORRETURN=$$VMTYPES^GMRVPCE0(ORQTYPE)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORQQVI2 6515 printed Oct 16, 2024@18:34:24 Page 2
ORQQVI2 ;SLC/dee- RPC calls to GMRVPCE0, Vitals data event drivers ;2/2/98
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10**;Dec 17, 1997
+2 ;
+3 QUIT
+4 ;
+5 ; ORQDATA is in the format
+6 ; ORQDATA(i)="VST^DT^encounter date" required
+7 ; ORQDATA(i)="VST^PT^pointer to patient" required
+8 ; ORQDATA(i)="VST^HL^pointer to Hospital Location" required
+9 ; ORQDATA(i)="VIT^vital type^^^value^provider^units^date/time"
+10 ; ORVITALS is the array passed to GMRV in the PCE Device Interface
+11 ; format.
+12 ; ORQVIT is an array subscipted by the index in ORVITALS that contains
+13 ; the subscript of the data gotten from ORQDATA. This is used to tell
+14 ; the caller which item had an ERROR or WARNING.
+15 ; ORRETURN(0) is 1 if no ERRORs or WARNINGs
+16 ; 0 if there are WARNING(s) but no ERRORs
+17 ; -1 if there are ERROR(s)
+18 ; ORRETURN(n) where n>0 is an error or warning in validating the data
+19 ; 1 piece: subscript of ORQDATA that the error or warning is on
+20 ; 2 piece: "ERROR" or "WARNING"
+21 ; 3 piece: text message about error or warning
+22 ; 4 piece: data item that generated the error or warning
+23 ;
VALIDATE(ORRETURN,ORQDATA) ;
+1 ; Given the array ORQDATA passed in by PCE Device Interface whose
+2 ; format is described in the PCE Device Interface documentation, this
+3 ; procedure will validate the Vitals data. If the data is invalid,
+4 ; the procedure will return the errors in the form given above.
+5 ;
+6 NEW ORVITALS,ORQVIT
+7 ;Initialize RETURN to no errors
+8 KILL ORRETURN
+9 SET ORRETURN(0)=1
+10 DO PREVITAL(.ORRETURN,.ORVITALS,.ORQVIT,.ORQDATA)
+11 DO VALIDATE^GMRVPCE0(.ORVITALS)
+12 DO POSTVIT(.ORRETURN,.ORQVIT,.ORVITALS)
+13 QUIT
+14 ;
VALSTORE(ORRETURN,ORQDATA) ;Calls VALIDATE and if no errors calls STORE
+1 ; Given the array ORQDATA passed in by PCE Device Interface whose
+2 ; format is described in the PCE Device Interface documentation, this
+3 ; procedure will validate the Vitals data. If the data is invalid,
+4 ; the procedure will return the errors in the form given above.
+5 ; If there are no errors then this procedure will call
+6 ; Vitals/Measurements to store the data in the GMRV's
+7 ; Patient Measurements (120.5) file.
+8 ;
+9 NEW ORVITALS,ORQVIT
+10 ;Initialize RETURN to no errors
+11 KILL ORRETURN
+12 SET ORRETURN(0)=1
+13 DO PREVITAL(.ORRETURN,.ORVITALS,.ORQVIT,.ORQDATA)
+14 DO VALIDATE^GMRVPCE0(.ORVITALS)
+15 DO POSTVIT(.ORRETURN,.ORQVIT,.ORVITALS)
+16 IF ORRETURN(0)=1
DO STORE^GMRVPCE0(.ORVITALS)
+17 QUIT
+18 ;
PREVITAL(ORRETURN,ORVITALS,ORQVIT,ORQDATA) ;format array for call to Vitlals
+1 NEW ORQTYPE,ORQCODE,ORINDEX1,ORINDEX2,ORRETINX,ORQITEM
+2 NEW ORQNODT,ORQNOPT,ORQNOHL
+3 SET (ORQNODT,ORQNOPT,ORQNOHL)=1
+4 SET ORVITALS("SOURCE")="^"_DUZ
+5 SET ORINDEX2=0
+6 SET ORRETINX=$ORDER(ORRETURN(""),-1)
+7 SET ORINDEX1=""
+8 FOR
SET ORINDEX1=$ORDER(ORQDATA(ORINDEX1))
if 'ORINDEX1
QUIT
Begin DoDot:1
+9 SET ORQDATAX=ORQDATA(ORINDEX1)
SET ORQTYPE=$PIECE(ORQDATAX,"^")
SET ORQCODE=$PIECE(ORQDATAX,"^",2)
+10 IF ORQTYPE="PRV"
SET ORVITALS("PROVIDER",1)=ORQCODE
QUIT
+11 IF ORQTYPE="VST"
Begin DoDot:2
+12 IF ORQCODE="DT"
Begin DoDot:3
+13 SET ORQNODT=0
+14 SET ORQITEM=$PIECE(ORQDATAX,"^",3)
+15 SET $PIECE(ORVITALS("ENCOUNTER"),"^",1)=ORQITEM
+16 IF ORQITEM>$$NOW^XLFDT
Begin DoDot:4
+17 SET ORRETINX=ORRETINX+1
+18 SET ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Date/Time entered cannot be in the future^"_$$FMTE^XLFDT(ORQITEM)
+19 SET ORRETURN(0)=-1
End DoDot:4
+20 IF ORQITEM'>1800000
Begin DoDot:4
+21 SET ORRETINX=ORRETINX+1
+22 SET ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Encounter Date/Time not valid^"_ORQITEM
+23 SET ORRETURN(0)=-1
End DoDot:4
End DoDot:3
QUIT
+24 IF ORQCODE="PT"
Begin DoDot:3
+25 SET ORQNOPT=0
+26 SET ORQITEM=$PIECE(ORQDATAX,"^",3)
+27 SET $PIECE(ORVITALS("ENCOUNTER"),"^",2)=ORQITEM
+28 IF '($DATA(^DPT(+ORQITEM,0))#2)
Begin DoDot:4
+29 SET ORRETINX=ORRETINX+1
+30 SET ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Patient missing or invalid in file 2^"_ORQITEM
+31 SET ORRETURN(0)=-1
End DoDot:4
End DoDot:3
QUIT
+32 IF ORQCODE="HL"
Begin DoDot:3
+33 SET ORQNOHL=0
+34 SET ORQITEM=$PIECE(ORQDATAX,"^",3)
+35 SET $PIECE(ORVITALS("ENCOUNTER"),"^",3)=ORQITEM
+36 IF '$DATA(^SC(ORQITEM,0))
Begin DoDot:4
+37 SET ORRETINX=ORRETINX+1
+38 SET ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^HOSPITAL LOCATION Missing is not in file 44^"_ORQITEM
+39 SET ORRETURN(0)=-1
End DoDot:4
+40 ; I $D(^PX(815,1,"DHL","B",ORQITEM)) D
+41 ;. S ORRETINX=ORRETINX+1
+42 ;. S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^HOSPITAL LOCATION Can not be a disposition clinic^"_ORQITEM
+43 ;. S ORRETURN(0)=-1
End DoDot:3
QUIT
End DoDot:2
QUIT
+44 IF ORQTYPE="VIT"
Begin DoDot:2
+45 SET ORINDEX2=ORINDEX2+1
+46 SET ORQVIT(ORINDEX2)=ORINDEX1
+47 SET ORVITALS("VITALS",+$PIECE(ORQDATAX,"^",6),ORINDEX2)=ORQCODE_"^"_$PIECE(ORQDATAX,"^",5)_"^"_$PIECE(ORQDATAX,"^",7,8)
End DoDot:2
QUIT
End DoDot:1
+48 IF ORQNODT
Begin DoDot:1
+49 SET ORRETINX=ORRETINX+1
+50 SET ORRETURN(ORRETINX)="^ERROR^Required data item, ENCOUNTER DATE/TIME, is missing^"
+51 SET ORRETURN(0)=-1
End DoDot:1
+52 IF ORQNOPT
Begin DoDot:1
+53 SET ORRETINX=ORRETINX+1
+54 SET ORRETURN(ORRETINX)="^ERROR^Required data item, PATIENT, is missing^"
+55 SET ORRETURN(0)=-1
End DoDot:1
+56 IF ORQNOHL
Begin DoDot:1
+57 SET ORRETINX=ORRETINX+1
+58 SET ORRETURN(ORRETINX)="^ERROR^Required data item, HOSPITAL LOCATION, is missing^"
+59 SET ORRETURN(0)=-1
End DoDot:1
+60 QUIT
+61 ;
POSTVIT(ORRETURN,ORQVIT,ORVITALS) ;return errors and warnings
+1 NEW ORVAR,ORINDEX,ORQTYPE
+2 SET ORINDEX=$ORDER(ORRETURN(""),-1)
+3 FOR ORQTYPE="WARNING","ERROR"
Begin DoDot:1
+4 SET ORVAR="ORVITALS("""_ORQTYPE_""")"
+5 FOR
SET ORVAR=$QUERY(@ORVAR)
if ORVAR'[("ORVITALS("""_ORQTYPE_"""")
QUIT
Begin DoDot:2
+6 SET ORINDEX=ORINDEX+1
+7 SET ORRETURN(ORINDEX)=$GET(ORQVIT($PIECE(ORVAR,",",4)))_"^"_ORQTYPE_"^"_@ORVAR
+8 IF ORQTYPE="WARNING"
if ORRETURN(0)>0
SET ORRETURN(0)=0
+9 IF '$TEST
SET ORRETURN(0)=-1
End DoDot:2
End DoDot:1
+10 QUIT
+11 ;
HELP(ORQLST,ORQTYPE) ; This procedure will return help for a particular
+1 ; measurement type in an array.
+2 ; Input
+3 ; Variables: ORQTYPE=Type of measurement (abbreviation
+4 ; (req.) from PCE Device Interface Specification).
+5 ; ORQLST=Array root to store help text in
+6 ;
+7 DO HELP^GMRVPCE0(ORQTYPE,"ORQLST")
+8 QUIT
+9 ;
RATECHK(ORRETURN,ORQTYPE,ORQRATE,ORQUNIT) ;
+1 ; Extrinsic function to validate the
+2 ; rate for a particular measurement
+3 ; Input
+4 ; Variables: ORQTYPE=Type of measurement (abbreviation
+5 ; (req.) from PCE Device Interface Specification).
+6 ; ORQRATE=Measurement rate to be validated.
+7 ; (req.)
+8 ; ORQUNIT=Unit of measurement for rate, if specified.
+9 ; (opt.)
+10 ; Return value: 1 if rate is valid.
+11 ; 0 if rate is invalid.
+12 ;
+13 SET ORRETURN=$$RATECHK^GMRVPCE0(ORQTYPE,ORQRATE,$GET(ORQUNIT))
+14 QUIT
+15 ;
VMTYPES(ORRETURN,ORQTYPE) ;
+1 ; This function returns one if ORQTYPE is a valid type abbrev.
+2 ; from the PCE Device Interface Specification.
+3 SET ORRETURN=$$VMTYPES^GMRVPCE0(ORQTYPE)
+4 QUIT