GMVDCSAV ;HOIFO/DAD,FT-VITALS COMPONENT: SAVE DATA ; 5/8/08
;;5.0;GEN. MED. REC. - VITALS;**9,3,25,23**;Oct 31, 2002;Build 25
;
; This routine uses the following IAs:
; #4114 - ^PXRMINDX global (controlled)
; #10103 - ^XLFDT calls (supported)
;
; This routine supports the following IAs:
; #3996 - GMV ADD VM RPC called at EN1 (private)
;
; 01/28/2005 KAM GMRV*5*9 Record midnight with 1 second added
; Stop adding second on multiple patent entry
;
EN1(RESULT,GMVDATA) ; GMV ADD VM [RPC entry point]
; Saves vitals data
; GMVDATA has the following data:
; piece1^piece2^piece3^piece4^piece5
; where:
; piece1 = date/time in FileMan internal format
; piece2 = patient number from FILE 2 (i.e., DFN)
; piece3 = vital type, a semi-colon, the reading, a semi-colon, and
; oxygen flow rate and percentage values [optional] (e.g.,
; 21;99;1 l/min 90%)
; piece4 = hospital location (FILE 44) pointer value
; piece5 = FILE 200 user number (i.e., DUZ), an asterisk, and the
; qualifier (File 120.52) internal entry numbers separated by
; colons (e.g., 547*50:65)
; Example:
; > S GMVDATA="3051011.1635^134^1;120/80;^67^87*2:38:50:75"
; > D EN1^GMVDCSAV(.RESULT,GMVDATA)
;
N GMVCNT,GMVDFN,GMVDTDUN,GMVDTENT,GMVENTBY,GMVFDA,GMVHOSPL
N GMVLOOP,GMVMSG,GMVQUALS,GMVRES,GMVIEN,GMVVMEAS,GMVVQUAL,GMVVTYP
D QUALTWO
Q
QUALTWO ; Add a new entry to FILE 120.5
K GMVFDA
S GMVVMEAS=$P(GMVDATA,"*",1)
S GMVDTDUN=+$P(GMVVMEAS,"^",1) ; Date time
;01/28/2005 KAM GMRV*5*9 Added next Line PAL-0105-60940
I +$P(GMVDTDUN,".",2)'>0 S GMVDTDUN=$$FMADD^XLFDT(GMVDTDUN,"","","",1)
I +$P(GMVDTDUN,".",2)=24 S GMVDTDUN=$$FMADD^XLFDT(GMVDTDUN,"","","",1)
S GMVDFN=+$P(GMVVMEAS,"^",2) ; Patient DFN
S GMVVTYP=$P(GMVVMEAS,"^",3) ; Vital type
S GMVDTDUN=$$CHKDT(GMVDTDUN,$P(GMVVTYP,";",1))
S GMVDTENT=$$NOW^XLFDT ; Current date time
S GMVHOSPL=+$P(GMVVMEAS,"^",4) ; Hospital
S GMVENTBY=+$P(GMVVMEAS,"^",5) ; DUZ
S GMVFDA(120.5,"+1,",.01)=GMVDTDUN ; Date time taken
S GMVFDA(120.5,"+1,",.02)=GMVDFN ; Patient
S GMVFDA(120.5,"+1,",.03)=+$P(GMVVTYP,";",1) ; Vital Type
S GMVFDA(120.5,"+1,",.04)=GMVDTENT ; Date Time entered
S GMVFDA(120.5,"+1,",.05)=GMVHOSPL ; Hospital
S GMVFDA(120.5,"+1,",.06)=GMVENTBY ; Entered by (DUZ)
S GMVFDA(120.5,"+1,",1.2)=$P(GMVVTYP,";",2) ; Rate
S GMVFDA(120.5,"+1,",1.4)=$P(GMVVTYP,";",3) ; Sup 02
S GMVIEN=""
D UPDATE^DIE("","GMVFDA","GMVIEN"),FMERROR
S GMVCNT=1
S GMVQUALS=$P(GMVDATA,"*",2)
F GMVLOOP=1:1:$L(GMVQUALS,":")+1 D
. S GMVVQUAL=$P(GMVQUALS,":",GMVLOOP)
. Q:GMVVQUAL=""
. S GMVCNT=GMVCNT+1
. D ADDQUAL^GMVGETQ(.GMVRES,GMVIEN(1)_"^"_GMVVQUAL)
. Q
Q
;
CHKDT(GMVDT,GMVSAV) ;Check if there is a vital entered for that date and time.
; If there is then add one second to the date/time until you find a
; date/time not used.
N GMVFLAG
S GMVFLAG=0
F Q:GMVFLAG D
.I '$D(^PXRMINDX(120.5,"PI",GMVDFN,GMVSAV,GMVDT)) S GMVFLAG=1 Q
.S GMVDT=$$FMADD^XLFDT(GMVDT,"","","",1)
.Q
Q GMVDT
;
MSG(X) ; *** Add a line to the message array ***
S (GMVMSG,RESULT(-1))=1+$G(RESULT(-1),0)
S RESULT(GMVMSG)=X
I $P(X,":")="ERROR" S RESULT(0)="ERROR"
Q
;
FMERROR ;
I $O(^TMP("DIERR",$J,0))>0 D
. N GMVER1,GMVER2
. S GMVER1=0
. F S GMVER1=$O(^TMP("DIERR",$J,GMVER1)) Q:GMVER1'>0 D
.. S GMVER2=0
.. F S GMVER2=$O(^TMP("DIERR",$J,GMVER1,"TEXT",GMVER2)) Q:GMVER2'>0 D
... D MSG("ERROR: "_$G(^TMP("DIERR",$J,GMVER1,"TEXT",GMVER2)))
... Q
.. Q
. Q
D CLEAN^DILF
Q
GMVDCSAV ;HOIFO/DAD,FT-VITALS COMPONENT: SAVE DATA ; 5/8/08
+1 ;;5.0;GEN. MED. REC. - VITALS;**9,3,25,23**;Oct 31, 2002;Build 25
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #4114 - ^PXRMINDX global (controlled)
+5 ; #10103 - ^XLFDT calls (supported)
+6 ;
+7 ; This routine supports the following IAs:
+8 ; #3996 - GMV ADD VM RPC called at EN1 (private)
+9 ;
+10 ; 01/28/2005 KAM GMRV*5*9 Record midnight with 1 second added
+11 ; Stop adding second on multiple patent entry
+12 ;
EN1(RESULT,GMVDATA) ; GMV ADD VM [RPC entry point]
+1 ; Saves vitals data
+2 ; GMVDATA has the following data:
+3 ; piece1^piece2^piece3^piece4^piece5
+4 ; where:
+5 ; piece1 = date/time in FileMan internal format
+6 ; piece2 = patient number from FILE 2 (i.e., DFN)
+7 ; piece3 = vital type, a semi-colon, the reading, a semi-colon, and
+8 ; oxygen flow rate and percentage values [optional] (e.g.,
+9 ; 21;99;1 l/min 90%)
+10 ; piece4 = hospital location (FILE 44) pointer value
+11 ; piece5 = FILE 200 user number (i.e., DUZ), an asterisk, and the
+12 ; qualifier (File 120.52) internal entry numbers separated by
+13 ; colons (e.g., 547*50:65)
+14 ; Example:
+15 ; > S GMVDATA="3051011.1635^134^1;120/80;^67^87*2:38:50:75"
+16 ; > D EN1^GMVDCSAV(.RESULT,GMVDATA)
+17 ;
+18 NEW GMVCNT,GMVDFN,GMVDTDUN,GMVDTENT,GMVENTBY,GMVFDA,GMVHOSPL
+19 NEW GMVLOOP,GMVMSG,GMVQUALS,GMVRES,GMVIEN,GMVVMEAS,GMVVQUAL,GMVVTYP
+20 DO QUALTWO
+21 QUIT
QUALTWO ; Add a new entry to FILE 120.5
+1 KILL GMVFDA
+2 SET GMVVMEAS=$PIECE(GMVDATA,"*",1)
+3 ; Date time
SET GMVDTDUN=+$PIECE(GMVVMEAS,"^",1)
+4 ;01/28/2005 KAM GMRV*5*9 Added next Line PAL-0105-60940
+5 IF +$PIECE(GMVDTDUN,".",2)'>0
SET GMVDTDUN=$$FMADD^XLFDT(GMVDTDUN,"","","",1)
+6 IF +$PIECE(GMVDTDUN,".",2)=24
SET GMVDTDUN=$$FMADD^XLFDT(GMVDTDUN,"","","",1)
+7 ; Patient DFN
SET GMVDFN=+$PIECE(GMVVMEAS,"^",2)
+8 ; Vital type
SET GMVVTYP=$PIECE(GMVVMEAS,"^",3)
+9 SET GMVDTDUN=$$CHKDT(GMVDTDUN,$PIECE(GMVVTYP,";",1))
+10 ; Current date time
SET GMVDTENT=$$NOW^XLFDT
+11 ; Hospital
SET GMVHOSPL=+$PIECE(GMVVMEAS,"^",4)
+12 ; DUZ
SET GMVENTBY=+$PIECE(GMVVMEAS,"^",5)
+13 ; Date time taken
SET GMVFDA(120.5,"+1,",.01)=GMVDTDUN
+14 ; Patient
SET GMVFDA(120.5,"+1,",.02)=GMVDFN
+15 ; Vital Type
SET GMVFDA(120.5,"+1,",.03)=+$PIECE(GMVVTYP,";",1)
+16 ; Date Time entered
SET GMVFDA(120.5,"+1,",.04)=GMVDTENT
+17 ; Hospital
SET GMVFDA(120.5,"+1,",.05)=GMVHOSPL
+18 ; Entered by (DUZ)
SET GMVFDA(120.5,"+1,",.06)=GMVENTBY
+19 ; Rate
SET GMVFDA(120.5,"+1,",1.2)=$PIECE(GMVVTYP,";",2)
+20 ; Sup 02
SET GMVFDA(120.5,"+1,",1.4)=$PIECE(GMVVTYP,";",3)
+21 SET GMVIEN=""
+22 DO UPDATE^DIE("","GMVFDA","GMVIEN")
DO FMERROR
+23 SET GMVCNT=1
+24 SET GMVQUALS=$PIECE(GMVDATA,"*",2)
+25 FOR GMVLOOP=1:1:$LENGTH(GMVQUALS,":")+1
Begin DoDot:1
+26 SET GMVVQUAL=$PIECE(GMVQUALS,":",GMVLOOP)
+27 IF GMVVQUAL=""
QUIT
+28 SET GMVCNT=GMVCNT+1
+29 DO ADDQUAL^GMVGETQ(.GMVRES,GMVIEN(1)_"^"_GMVVQUAL)
+30 QUIT
End DoDot:1
+31 QUIT
+32 ;
CHKDT(GMVDT,GMVSAV) ;Check if there is a vital entered for that date and time.
+1 ; If there is then add one second to the date/time until you find a
+2 ; date/time not used.
+3 NEW GMVFLAG
+4 SET GMVFLAG=0
+5 FOR
IF GMVFLAG
QUIT
Begin DoDot:1
+6 IF '$DATA(^PXRMINDX(120.5,"PI",GMVDFN,GMVSAV,GMVDT))
SET GMVFLAG=1
QUIT
+7 SET GMVDT=$$FMADD^XLFDT(GMVDT,"","","",1)
+8 QUIT
End DoDot:1
+9 QUIT GMVDT
+10 ;
MSG(X) ; *** Add a line to the message array ***
+1 SET (GMVMSG,RESULT(-1))=1+$GET(RESULT(-1),0)
+2 SET RESULT(GMVMSG)=X
+3 IF $PIECE(X,":")="ERROR"
SET RESULT(0)="ERROR"
+4 QUIT
+5 ;
FMERROR ;
+1 IF $ORDER(^TMP("DIERR",$JOB,0))>0
Begin DoDot:1
+2 NEW GMVER1,GMVER2
+3 SET GMVER1=0
+4 FOR
SET GMVER1=$ORDER(^TMP("DIERR",$JOB,GMVER1))
IF GMVER1'>0
QUIT
Begin DoDot:2
+5 SET GMVER2=0
+6 FOR
SET GMVER2=$ORDER(^TMP("DIERR",$JOB,GMVER1,"TEXT",GMVER2))
IF GMVER2'>0
QUIT
Begin DoDot:3
+7 DO MSG("ERROR: "_$GET(^TMP("DIERR",$JOB,GMVER1,"TEXT",GMVER2)))
+8 QUIT
End DoDot:3
+9 QUIT
End DoDot:2
+10 QUIT
End DoDot:1
+11 DO CLEAN^DILF
+12 QUIT