VENPCCW ; IHS/OIT/GIS - SILENT VISIT CHECK-IN CALL ;
;;2.6;PCC+;;NOV 12, 2007
; MOJO EXTENSIONS FOR PCC+
;
; 2.5 EXTENSIONS FOR MOJO AND THE NEW GUI SCHEDULER
;
;
CHECKIND(OUT,CKINDT,DFN,PRVIEN,CLIEN,DEFEF,OUTGUIDE,NEWVISIT,OUTMODE) ; EP-debug mode
S ^GREG("CKIN")=$G(DFN)
; D DEBUG^%Serenji("CHECKIN^VENPCCW(.OUT,CKINDT,DFN,PRVIEN,CLIEN,DEFEF,OUTGUIDE,NEWVISIT,OUTMODE)")
Q
;
CHECKIN(OUT,CKINDT,DFN,PRVIEN,CLIEN,DEFEF,OUTGUIDE,NEWVISIT,OUTMODE) ;EP - RPC (VEN CHECKIN): Check in appointment
; MOJO ENABLED!
; CKINDT = Checkin date/time
; DFN = patient IEN
; PRVIEN = Provider IEN
; OUTGUIDE = true/false print OutGuide
; CLIEN = VEN EHP CLINIC IEN
; DEFEF = VEN EHP TEMPLATE IEN
; NEWVISIT = OK TO CREATE A NEW VISIT
; OUTMODE = CLASSICPCC, TABLET, DIGITALPEN (MOJO)
INIT ; INITIALIZE VARIABLES
N X,NODE,%,%DT,Y,VIEN,VCN,DEFHS,VARS,APPT,EXT,MOJOFLAG,OGFLAG,CSTOP,LOC,ELIG,ICD9,ICD,VENDEV,JOB,TQIEN,DHS
D ^XBKVAR S X="ERROR^VENPCCW",@^%ZOSF("TRAP")
S NODE=0
S OUT=$NA(^TMP("BSDX",$J))
K @OUT
HDR ; GET ADO HEADER RECORD
S @OUT@(0)="T00020ERRORID^T00030ERRORTEXT^T16000MOJODATA"_$C(30)
VDT ; GET CHECKIN DATE AND TIME
S:CKINDT["@0000" CKINDT=$P(CKINDT,"@")
S %DT="T",X=CKINDT D ^%DT S CKINDT=Y
TF ; TRANSFORM FLAGS
S OUTGUIDE=$E($$UP^XLFSTR($G(OUTGUIDE)))
S NEWVISIT=$E($$UP^XLFSTR($G(NEWVISIT)))
VALID ; CHECK TO MAKE SURE ALL REQUIRED PARAMS ARE PRESENT
I CKINDT=-1 D ERR(0,"VENPCCW: Invalid checkin date/time Parameter") Q
I '+DFN D ERR(0,"VENPCCW: Invalid patient ID Parameter") Q
I '+PRVIEN D ERR(0,"VENPCCW: Invalid provider ID Parameter") Q
I '+CLIEN D ERR(0,"VENPCCW: Invalid PCC+ Clinic Parameter") Q
I '+DEFEF D ERR(0,"VENPCCW: Invalid PCC+ Template Parameter") Q
SECVAR ; MAKE SECONDARY VARIABLES
S %=$G(OUTGUIDE) I %="T"!(%="t") S OGFLAG=1
S DEFHS="" S APPT="" S EXT=""
S LOC=$G(DUZ(2)) I 'LOC S LOC=$P($G(^VEN(7.95,+$G(CLIEN),2)),U,4)
I 'LOC D ERR(0,"VENPCCW: Unable to determine Location IEN") Q
S CSTOP=$P($G(^VEN(7.95,+$G(CLIEN),0)),U,4)
I 'CSTOP D ERR(0,"VENPCCW: Unable to determine Clinic Stop IEN") Q
VISIT S VIEN=""
S VIEN=$$DUP^VENPCCW(DFN,CLIEN) ; CHECK FOR DUP VISIT: SAME PT & PCC+ CLINIC WITHIN 6 HRS
I 'VIEN S VIEN=$$VISIT^VENPCC3(DFN,CKINDT,LOC,CSTOP)
I 'VIEN D ERR(0,"VENPCCW: Unable to create a visit") Q
S VCN=$P($G(^AUPNVSIT(VIEN,11)),U,3)
I '$L(VCN) S VCN=$$VCN^VENPCC3(VIEN,CLIEN) S VCN=$P(VCN,U)
I '$L(VCN) D ERR(0,"VENPCCW: Unable to find VCN") Q
S VARS=$$PACK^VENPCC
GETDATA ; GET DATA FROM PCCPLUS
I $G(OUTMODE)="STD"!($G(OUTMODE)="") S OUTMODE="CLASSICPCC" ; FOR BKWD COMPATIBILITY
I $G(OUTMODE)'="CLASSICPCC" D G QUEUE ; IF THIS IS A MOJO REQUEST...
. S MOJOFLAG=1 ; TELLS PCC+ TO OUTPUT THE DATA FILE TO MOJO ARRAY
. S MOJOFLAG(1)=OUTMODE
. Q
QUEUE ; UPDATE THE VEN QUEUE FILE
D QUEUE^VENPCCA(VIEN,CLIEN,$G(OGFLAG),"","",PRVIEN) ; 2.5 ADD PARAMETER FOR PROVIDER
PCCPLUS ; GET DATA STRING FROM PCC+ AND MAKE MOJO ARRAY IF MOJOFLAG IS SET
D PRINT^VENPCC10(VIEN,VCN,CLIEN,PRVIEN,DEFEF,DEFHS,$G(APPT),$G(VARS),$G(EXT))
FIN ; ADD END OF FILE MARKER AND QUIT
S NODE=$O(@OUT@(999999999),-1)+1
I '$G(MOJOFLAG) S @OUT@(NODE)="1^OK^"_$C(30),NODE=NODE+1 ; CLASSIC PCC+ FEEDBACK
S @OUT@(NODE)=$C(31)
K ^TMP("VEN PRNT",$J) ; CLEAN OUT CLASSIC PCC+ NODES FROM TMP GLOBAL - THEY ARE NOT NEEDED ANYMORE
Q
;
DUP(DFN,DIEN) ; EP-GIVEN A DFN AND DEPT STOP IEN RETURN VIEN IF DUPLICATE VISIT
I '$D(^DPT(+$G(DFN),0)) Q ""
I '$D(^VEN(7.95,+$G(DIEN),0)) Q ""
N QIEN,TIME,DIFF,DEPT,STOP
S QIEN=99999999999,VIEN=0
F S QIEN=$O(^VEN(7.2,"AP",DFN,QIEN),-1) Q:'QIEN D I $G(STOP) Q
. S TIME=+$G(^VEN(7.2,QIEN,0)) I 'TIME Q
. S DIFF=$$FMDIFF^XLFDT($$NOW^XLFDT,TIME,2)
. I DIFF>(3600*6) S STOP=1 Q
. S DEPT=$P(^VEN(7.2,QIEN,0),U,4) I 'DEPT Q
. I DEPT'=DIEN Q
. S VIEN=$P($G(^VEN(7.2,QIEN,1)),U,2),STOP=1
. Q
Q VIEN
;
;-----------------------------------------------------------------
;
MOJODATA ; EP-MAKE MOJO ARRAY
; IF MOJOFLAG=1, PCC+ DATA MINING PROCESS BRANCHES HERE FOR ITS OUTPUT
N CREF,DA,FLD,VAL,STG,X,ERR,RED,FIEN,FID,%,NODE,MP,TAB
S TAB=$C(68)_" TQ"_U
S TAB=TAB_"VENPCCTQ"
S CREF=$NA(^TMP("VEN PRNT",$J)),DA=0,STG=""
S RED="^chart^dob^patient^agesex^tribe^ssn^community^provider^timestamp^ellig^uid^hdr^" ; REDUNDANT ENTRY LIST
I $G(MOJOFLAG(1))="DIGITALPEN" D I MP="" Q ; MOJO PRINTER MUST EXIST IN DIGITAL PEN MODE
. D HS(VISIT,DEPTIEN) ; FIRST, PRINT STANDARD HEALTH SUMMARY AND OUTGUIDE (IF NECESSARY)
. S MP=$P($G(^VEN(7.95,+$G(DEPTIEN),3)),U) ; GET MOJO PRINTER
. I MP="" D Q
.. S ERR="MOJO printer is undefined" D ERR^VENPCC1(ERR) ; UPDATE PCC+ ERROR FILE
.. S @OUT@(1)="0^MOJO printer is undefined^"_$C(30) ; UPDATE RPC STRING
.. Q
. S @CREF@(1,"group")=MP ; ADD MOJO PRINTER TO ARRAY
. Q
HARDCODE ; EP-FOR DIGITAL FORMS ONLY, ADD HARD CODED FIELDS TO THE DATA STRING
S FIEN=0 F S FIEN=$O(^VEN(7.41,+$G(DEFEF),13,FIEN)) Q:'FIEN D
. S X=$G(^VEN(7.41,+$G(DEFEF),13,FIEN,0)) I '$L(X) Q
. S FLD=$P(X,U),VAL=$P(X,U,2)
. S @CREF@(1,FLD)=VAL ; CREATE NEW DATA VALUE OR OVERWRITE AN EXISTING DATA VALUE
. Q
; DON'T NEED TO WORRY ABOUT OVERWRITING OR DELETING FIELDS THAT ARE NOT ON THE FORM ANYWAY!
CVT ; CONVERT DATA ARRYA TO A PREFILL STRING FOR MOJO
S FLD=""
F S FLD=$O(@CREF@(1,FLD)) Q:FLD="" D ; MAIN PROCESSING LOOP!!!
. S VAL=$G(@CREF@(1,FLD))
. S VAL=$TR(VAL,"{","[") ; VAL CAN'T CONTAIN A DELIMITER CHARACTER
. S VAL=$TR(VAL,"}","]") ; VAL CAN'T CONTAIN A DELIMITER CHARACTER
. S %="" I $L(STG) S %="}" ; MUST NOT USE "^" AS A DELIMITER AT THIS LEVEL ; FIX
. S STG=STG_%_FLD_"{"_VAL
RED . I RED[(U_FLD_U) S STG=STG_"}"_FLD_"_2"_"{"_VAL Q ; MAKE STD REDUNDANT IDENTIFIERS FOR SECOND PAGE OF THE FORM
. I $D(^VEN(7.41,+$G(DEFEF),12,"B",FLD)) S STG=STG_%_FLD_"_2"_"{"_VAL Q ; MAKE CUSTOM REDUNDANT IDENTIFIERS
. Q
FID ; ADD FORM INSTANCE ID AND METADATA FIELDS TO THE PREFILL STRING
S %=$H,FID=+$G(VIEN,"X999")_"."_+%_"."_$P(%,",",2)
S STG=STG_"}FormInstanceID{"_FID
META ; DATA THAT MUST PASS THRU FROM THE PRE-FILL TO THE UPLOAD ; FORMAT fieldname1~val1~fieldname2~val2;...
S STG=STG_"}metadata{u100~"_$P($G(^VEN(7.41,+$G(DEFEF),11)),U) ; FORM ID
S STG=STG_";EDET~"_$$DTIME(+$G(DEFEF)) ; NEED EARLIEST DE TIME OTHER END
MODE ; ALL PREVIOUS MOJO PROCESSING LEADS TO THIS MAIN DIVISION POINT: TABLET OR PEN
I $G(MOJOFLAG(1))="TABLET" S STG=STG_";CLIEN~"_$G(CLIEN) G TABLET
I $G(MOJOFLAG(1))="DIGITALPEN" G PEN
Q
;
TABLET ; "TABLET" MODE
X TAB ; ADD NEW RECORD TO TABLET QUEUE FILE INCLUDING THE PRE-FILL DATA NODES
; IN TABLET MODE, THE DATA NODE MUST BE HELD UNTIL THE FORM IS ACTUALLY CREATED ON THE TABLET SCREEN
; THE DATA IS HELD (HIDDEN) IN A ROW OF THE TABLET QUEUE FILE ROW
; WHEN THE USER SELECTS A RECORD IN THE TABLET QUEUE, THE PREFILL DATA IS FINALLY UTILIZED TO BUILD THE FORM
S @OUT@(1)="1^OK^"_$C(30) ; SEND FEEDBACK TO THE RPC ASSOCIATED WITH THE "TABLET" BUTTON
Q
;
PEN ; "DIGITALPEN" MODE
; UNLIKE THE TABLET MODE, PEN DATA IS NOT HELD FOR FUTURE USE BECAUSE THE FORM IS BUILT IMMEDIATLY
; THE PRE-FILL DATA ARRAY IS PASSED BACK TO THE RPC AS SOON AS IT IS COLLECTED
S @OUT@(1)="1^OK^" ; SEND A "{}" DELIMITED DATA ARRAY BACK TO THE RPC ASSOCOATED WITH THE "DIGITAL PEN" BUTTON
F NODE=2:1 Q:'$L(STG) S @OUT@(NODE)=$E(STG,1,240),STG=$E(STG,241,999999999)
S @OUT@(NODE)=$C(30)
Q
;
DTIME(DEFEF) ; EP - DELAY TIME BEFORE DATA ENTRY IS ALLOWED
N T1,T2,DELAY
S DELAY=$P($G(^VEN(7.41,+$G(DEFEF),11)),U,4) I 'DELAY S DELAY=0
S T1=$$NOW^VENPCCU
S T2=$$FMADD^XLFDT(T1,,DELAY)
Q T2
;
HS(VIEN,DEPTIEN) ; EP-PRINT PCC+ HEALTH SUMMARY WITHIN MOJO (PEN MODE ONLY)
HSQ Q ; TEMP BYPASS HS PRINTOUT
N %,DEFHS,DFN
I '$D(CFIGIEN) S CFIGIEN=$$CFG^VENPCCU
I '$G(EFONLY),'$G(OGONLY),$G(DEPTIEN),$G(VIEN) ; OK TO PRINT HS & REQD VARIABLES ARE PRESENT
E Q
S DFN=$P($G(^AUPNVSIT(VIEN,0)),U,5) I 'DFN Q
S DEFHS=+$P($G(^VEN(7.95,DEPTIEN,2)),U,6)
I 'DEFHS D I 'DEFHS Q
. S %=+$P($G(^DPT(DFN,0)),U,3)
. I % S %=(DT-%)\10000 I %<12 S DEFHS=$O(^APCHCTL("B","PEDIATRIC",0)) I DEFHS Q ; AGE <12 SO USE PEDS HS
. S DEFHS=$O(^APCHCTL("B","ADULT REGULAR",0))
. Q
D HS^VENPCC2A(DFN,DEFHS,VIEN,DEPTIEN)
Q
;
; --------------------------------------------------
;
SCX(PRV,VISIT,VCN,CSIEN) ; EP-SCHEDULING PKG INTERFACE FROM BSDX
N %,%Y,CIEN,TOT,DEPT,CFIGIEN,DEPTIEN,DIC,X,Y,LOC,PGRP,VPFLAG,APPT,DEFEF,DEFHS,EFONLY,EXT,VARS,ELIG,TIME,DFN,%DT,DI,DISYS,DLAYGO
N IO,IOF,IOM,ION,IOS,IOST,IOT,IOXY,%E,POP
N OGFLAG
S OGFLAG=$G(BSDXVEN("OUTGUIDE"))
S OGFLAG=$S(OGFLAG="true":1,1:0)
S PRV=+$$PRV^VENPCCU(+$G(PRV))
S CFIGIEN=$$CFG^VENPCCU
S DEPTIEN=$G(BSDXVEN("CLINIC"))
I '+DEPTIEN Q
I '$G(PRV) S PRV=$P($G(^VEN(7.95,DEPTIEN,2)),U,2) I 'PRV S PRV=$P($G(^VEN(7.5,CFIGIEN,0)),U,13)
I '$D(^VA(200,+$G(PRV),0)) Q
S DEFEF=$G(BSDXVEN("FORM"))
I '+DEFEF Q
S DEFHS="",EFONLY=1,APPT=$G(ASDDT),EXT=""
D QUEUE^VENPCCA(VISIT,DEPTIEN,"","","",PRV)
I $D(NOTASK) D EN1^VENPCCA("D",1)
S VARS=$$PACK^VENPCC,EXT=""
D EN1^VENPCCA("J",1)
I $D(VPFLAG) K HSONLY,VPFLAG
Q
;
; -----------------------
;
ERR(ERRID,ERRTXT) ; EP-Error processing
S:'+$G(NODE) NODE=999999
S NODE=NODE+1
S @OUT@(NODE)=ERRID_"^"_ERRTXT_U_$C(30)
S NODE=NODE+1
S @OUT@(NODE)=$C(31)
Q
;
ERROR ; EP-MUMPS ERROR TRAP
D ^%ZTER
I '+$G(NODE) N NODE S NODE=999999
S NODE=NODE+1
D ERR(0,"VENPCCW M Error: <"_$G(%ZTERROR)_">")
Q
;
VENPCCW ; IHS/OIT/GIS - SILENT VISIT CHECK-IN CALL ;
+1 ;;2.6;PCC+;;NOV 12, 2007
+2 ; MOJO EXTENSIONS FOR PCC+
+3 ;
+4 ; 2.5 EXTENSIONS FOR MOJO AND THE NEW GUI SCHEDULER
+5 ;
+6 ;
CHECKIND(OUT,CKINDT,DFN,PRVIEN,CLIEN,DEFEF,OUTGUIDE,NEWVISIT,OUTMODE) ; EP-debug mode
+1 SET ^GREG("CKIN")=$GET(DFN)
+2 ; D DEBUG^%Serenji("CHECKIN^VENPCCW(.OUT,CKINDT,DFN,PRVIEN,CLIEN,DEFEF,OUTGUIDE,NEWVISIT,OUTMODE)")
+3 QUIT
+4 ;
CHECKIN(OUT,CKINDT,DFN,PRVIEN,CLIEN,DEFEF,OUTGUIDE,NEWVISIT,OUTMODE) ;EP - RPC (VEN CHECKIN): Check in appointment
+1 ; MOJO ENABLED!
+2 ; CKINDT = Checkin date/time
+3 ; DFN = patient IEN
+4 ; PRVIEN = Provider IEN
+5 ; OUTGUIDE = true/false print OutGuide
+6 ; CLIEN = VEN EHP CLINIC IEN
+7 ; DEFEF = VEN EHP TEMPLATE IEN
+8 ; NEWVISIT = OK TO CREATE A NEW VISIT
+9 ; OUTMODE = CLASSICPCC, TABLET, DIGITALPEN (MOJO)
INIT ; INITIALIZE VARIABLES
+1 NEW X,NODE,%,%DT,Y,VIEN,VCN,DEFHS,VARS,APPT,EXT,MOJOFLAG,OGFLAG,CSTOP,LOC,ELIG,ICD9,ICD,VENDEV,JOB,TQIEN,DHS
+2 DO ^XBKVAR
SET X="ERROR^VENPCCW"
SET @^%ZOSF("TRAP")
+3 SET NODE=0
+4 SET OUT=$NAME(^TMP("BSDX",$JOB))
+5 KILL @OUT
HDR ; GET ADO HEADER RECORD
+1 SET @OUT@(0)="T00020ERRORID^T00030ERRORTEXT^T16000MOJODATA"_$CHAR(30)
VDT ; GET CHECKIN DATE AND TIME
+1 IF CKINDT["@0000"
SET CKINDT=$PIECE(CKINDT,"@")
+2 SET %DT="T"
SET X=CKINDT
DO ^%DT
SET CKINDT=Y
TF ; TRANSFORM FLAGS
+1 SET OUTGUIDE=$EXTRACT($$UP^XLFSTR($GET(OUTGUIDE)))
+2 SET NEWVISIT=$EXTRACT($$UP^XLFSTR($GET(NEWVISIT)))
VALID ; CHECK TO MAKE SURE ALL REQUIRED PARAMS ARE PRESENT
+1 IF CKINDT=-1
DO ERR(0,"VENPCCW: Invalid checkin date/time Parameter")
QUIT
+2 IF '+DFN
DO ERR(0,"VENPCCW: Invalid patient ID Parameter")
QUIT
+3 IF '+PRVIEN
DO ERR(0,"VENPCCW: Invalid provider ID Parameter")
QUIT
+4 IF '+CLIEN
DO ERR(0,"VENPCCW: Invalid PCC+ Clinic Parameter")
QUIT
+5 IF '+DEFEF
DO ERR(0,"VENPCCW: Invalid PCC+ Template Parameter")
QUIT
SECVAR ; MAKE SECONDARY VARIABLES
+1 SET %=$GET(OUTGUIDE)
IF %="T"!(%="t")
SET OGFLAG=1
+2 SET DEFHS=""
SET APPT=""
SET EXT=""
+3 SET LOC=$GET(DUZ(2))
IF 'LOC
SET LOC=$PIECE($GET(^VEN(7.95,+$GET(CLIEN),2)),U,4)
+4 IF 'LOC
DO ERR(0,"VENPCCW: Unable to determine Location IEN")
QUIT
+5 SET CSTOP=$PIECE($GET(^VEN(7.95,+$GET(CLIEN),0)),U,4)
+6 IF 'CSTOP
DO ERR(0,"VENPCCW: Unable to determine Clinic Stop IEN")
QUIT
VISIT SET VIEN=""
+1 ; CHECK FOR DUP VISIT: SAME PT & PCC+ CLINIC WITHIN 6 HRS
SET VIEN=$$DUP^VENPCCW(DFN,CLIEN)
+2 IF 'VIEN
SET VIEN=$$VISIT^VENPCC3(DFN,CKINDT,LOC,CSTOP)
+3 IF 'VIEN
DO ERR(0,"VENPCCW: Unable to create a visit")
QUIT
+4 SET VCN=$PIECE($GET(^AUPNVSIT(VIEN,11)),U,3)
+5 IF '$LENGTH(VCN)
SET VCN=$$VCN^VENPCC3(VIEN,CLIEN)
SET VCN=$PIECE(VCN,U)
+6 IF '$LENGTH(VCN)
DO ERR(0,"VENPCCW: Unable to find VCN")
QUIT
+7 SET VARS=$$PACK^VENPCC
GETDATA ; GET DATA FROM PCCPLUS
+1 ; FOR BKWD COMPATIBILITY
IF $GET(OUTMODE)="STD"!($GET(OUTMODE)="")
SET OUTMODE="CLASSICPCC"
+2 ; IF THIS IS A MOJO REQUEST...
IF $GET(OUTMODE)'="CLASSICPCC"
Begin DoDot:1
+3 ; TELLS PCC+ TO OUTPUT THE DATA FILE TO MOJO ARRAY
SET MOJOFLAG=1
+4 SET MOJOFLAG(1)=OUTMODE
+5 QUIT
End DoDot:1
GOTO QUEUE
QUEUE ; UPDATE THE VEN QUEUE FILE
+1 ; 2.5 ADD PARAMETER FOR PROVIDER
DO QUEUE^VENPCCA(VIEN,CLIEN,$GET(OGFLAG),"","",PRVIEN)
PCCPLUS ; GET DATA STRING FROM PCC+ AND MAKE MOJO ARRAY IF MOJOFLAG IS SET
+1 DO PRINT^VENPCC10(VIEN,VCN,CLIEN,PRVIEN,DEFEF,DEFHS,$GET(APPT),$GET(VARS),$GET(EXT))
FIN ; ADD END OF FILE MARKER AND QUIT
+1 SET NODE=$ORDER(@OUT@(999999999),-1)+1
+2 ; CLASSIC PCC+ FEEDBACK
IF '$GET(MOJOFLAG)
SET @OUT@(NODE)="1^OK^"_$CHAR(30)
SET NODE=NODE+1
+3 SET @OUT@(NODE)=$CHAR(31)
+4 ; CLEAN OUT CLASSIC PCC+ NODES FROM TMP GLOBAL - THEY ARE NOT NEEDED ANYMORE
KILL ^TMP("VEN PRNT",$JOB)
+5 QUIT
+6 ;
DUP(DFN,DIEN) ; EP-GIVEN A DFN AND DEPT STOP IEN RETURN VIEN IF DUPLICATE VISIT
+1 IF '$DATA(^DPT(+$GET(DFN),0))
QUIT ""
+2 IF '$DATA(^VEN(7.95,+$GET(DIEN),0))
QUIT ""
+3 NEW QIEN,TIME,DIFF,DEPT,STOP
+4 SET QIEN=99999999999
SET VIEN=0
+5 FOR
SET QIEN=$ORDER(^VEN(7.2,"AP",DFN,QIEN),-1)
IF 'QIEN
QUIT
Begin DoDot:1
+6 SET TIME=+$GET(^VEN(7.2,QIEN,0))
IF 'TIME
QUIT
+7 SET DIFF=$$FMDIFF^XLFDT($$NOW^XLFDT,TIME,2)
+8 IF DIFF>(3600*6)
SET STOP=1
QUIT
+9 SET DEPT=$PIECE(^VEN(7.2,QIEN,0),U,4)
IF 'DEPT
QUIT
+10 IF DEPT'=DIEN
QUIT
+11 SET VIEN=$PIECE($GET(^VEN(7.2,QIEN,1)),U,2)
SET STOP=1
+12 QUIT
End DoDot:1
IF $GET(STOP)
QUIT
+13 QUIT VIEN
+14 ;
+15 ;-----------------------------------------------------------------
+16 ;
MOJODATA ; EP-MAKE MOJO ARRAY
+1 ; IF MOJOFLAG=1, PCC+ DATA MINING PROCESS BRANCHES HERE FOR ITS OUTPUT
+2 NEW CREF,DA,FLD,VAL,STG,X,ERR,RED,FIEN,FID,%,NODE,MP,TAB
+3 SET TAB=$CHAR(68)_" TQ"_U
+4 SET TAB=TAB_"VENPCCTQ"
+5 SET CREF=$NAME(^TMP("VEN PRNT",$JOB))
SET DA=0
SET STG=""
+6 ; REDUNDANT ENTRY LIST
SET RED="^chart^dob^patient^agesex^tribe^ssn^community^provider^timestamp^ellig^uid^hdr^"
+7 ; MOJO PRINTER MUST EXIST IN DIGITAL PEN MODE
IF $GET(MOJOFLAG(1))="DIGITALPEN"
Begin DoDot:1
+8 ; FIRST, PRINT STANDARD HEALTH SUMMARY AND OUTGUIDE (IF NECESSARY)
DO HS(VISIT,DEPTIEN)
+9 ; GET MOJO PRINTER
SET MP=$PIECE($GET(^VEN(7.95,+$GET(DEPTIEN),3)),U)
+10 IF MP=""
Begin DoDot:2
+11 ; UPDATE PCC+ ERROR FILE
SET ERR="MOJO printer is undefined"
DO ERR^VENPCC1(ERR)
+12 ; UPDATE RPC STRING
SET @OUT@(1)="0^MOJO printer is undefined^"_$CHAR(30)
+13 QUIT
End DoDot:2
QUIT
+14 ; ADD MOJO PRINTER TO ARRAY
SET @CREF@(1,"group")=MP
+15 QUIT
End DoDot:1
IF MP=""
QUIT
HARDCODE ; EP-FOR DIGITAL FORMS ONLY, ADD HARD CODED FIELDS TO THE DATA STRING
+1 SET FIEN=0
FOR
SET FIEN=$ORDER(^VEN(7.41,+$GET(DEFEF),13,FIEN))
IF 'FIEN
QUIT
Begin DoDot:1
+2 SET X=$GET(^VEN(7.41,+$GET(DEFEF),13,FIEN,0))
IF '$LENGTH(X)
QUIT
+3 SET FLD=$PIECE(X,U)
SET VAL=$PIECE(X,U,2)
+4 ; CREATE NEW DATA VALUE OR OVERWRITE AN EXISTING DATA VALUE
SET @CREF@(1,FLD)=VAL
+5 QUIT
End DoDot:1
+6 ; DON'T NEED TO WORRY ABOUT OVERWRITING OR DELETING FIELDS THAT ARE NOT ON THE FORM ANYWAY!
CVT ; CONVERT DATA ARRYA TO A PREFILL STRING FOR MOJO
+1 SET FLD=""
+2 ; MAIN PROCESSING LOOP!!!
FOR
SET FLD=$ORDER(@CREF@(1,FLD))
IF FLD=""
QUIT
Begin DoDot:1
+3 SET VAL=$GET(@CREF@(1,FLD))
+4 ; VAL CAN'T CONTAIN A DELIMITER CHARACTER
SET VAL=$TRANSLATE(VAL,"{","[")
+5 ; VAL CAN'T CONTAIN A DELIMITER CHARACTER
SET VAL=$TRANSLATE(VAL,"}","]")
+6 ; MUST NOT USE "^" AS A DELIMITER AT THIS LEVEL ; FIX
SET %=""
IF $LENGTH(STG)
SET %="}"
+7 SET STG=STG_%_FLD_"{"_VAL
RED ; MAKE STD REDUNDANT IDENTIFIERS FOR SECOND PAGE OF THE FORM
IF RED[(U_FLD_U)
SET STG=STG_"}"_FLD_"_2"_"{"_VAL
QUIT
+1 ; MAKE CUSTOM REDUNDANT IDENTIFIERS
IF $DATA(^VEN(7.41,+$GET(DEFEF),12,"B",FLD))
SET STG=STG_%_FLD_"_2"_"{"_VAL
QUIT
+2 QUIT
End DoDot:1
FID ; ADD FORM INSTANCE ID AND METADATA FIELDS TO THE PREFILL STRING
+1 SET %=$HOROLOG
SET FID=+$GET(VIEN,"X999")_"."_+%_"."_$PIECE(%,",",2)
+2 SET STG=STG_"}FormInstanceID{"_FID
META ; DATA THAT MUST PASS THRU FROM THE PRE-FILL TO THE UPLOAD ; FORMAT fieldname1~val1~fieldname2~val2;...
+1 ; FORM ID
SET STG=STG_"}metadata{u100~"_$PIECE($GET(^VEN(7.41,+$GET(DEFEF),11)),U)
+2 ; NEED EARLIEST DE TIME OTHER END
SET STG=STG_";EDET~"_$$DTIME(+$GET(DEFEF))
MODE ; ALL PREVIOUS MOJO PROCESSING LEADS TO THIS MAIN DIVISION POINT: TABLET OR PEN
+1 IF $GET(MOJOFLAG(1))="TABLET"
SET STG=STG_";CLIEN~"_$GET(CLIEN)
GOTO TABLET
+2 IF $GET(MOJOFLAG(1))="DIGITALPEN"
GOTO PEN
+3 QUIT
+4 ;
TABLET ; "TABLET" MODE
+1 ; ADD NEW RECORD TO TABLET QUEUE FILE INCLUDING THE PRE-FILL DATA NODES
XECUTE TAB
+2 ; IN TABLET MODE, THE DATA NODE MUST BE HELD UNTIL THE FORM IS ACTUALLY CREATED ON THE TABLET SCREEN
+3 ; THE DATA IS HELD (HIDDEN) IN A ROW OF THE TABLET QUEUE FILE ROW
+4 ; WHEN THE USER SELECTS A RECORD IN THE TABLET QUEUE, THE PREFILL DATA IS FINALLY UTILIZED TO BUILD THE FORM
+5 ; SEND FEEDBACK TO THE RPC ASSOCIATED WITH THE "TABLET" BUTTON
SET @OUT@(1)="1^OK^"_$CHAR(30)
+6 QUIT
+7 ;
PEN ; "DIGITALPEN" MODE
+1 ; UNLIKE THE TABLET MODE, PEN DATA IS NOT HELD FOR FUTURE USE BECAUSE THE FORM IS BUILT IMMEDIATLY
+2 ; THE PRE-FILL DATA ARRAY IS PASSED BACK TO THE RPC AS SOON AS IT IS COLLECTED
+3 ; SEND A "{}" DELIMITED DATA ARRAY BACK TO THE RPC ASSOCOATED WITH THE "DIGITAL PEN" BUTTON
SET @OUT@(1)="1^OK^"
+4 FOR NODE=2:1
IF '$LENGTH(STG)
QUIT
SET @OUT@(NODE)=$EXTRACT(STG,1,240)
SET STG=$EXTRACT(STG,241,999999999)
+5 SET @OUT@(NODE)=$CHAR(30)
+6 QUIT
+7 ;
DTIME(DEFEF) ; EP - DELAY TIME BEFORE DATA ENTRY IS ALLOWED
+1 NEW T1,T2,DELAY
+2 SET DELAY=$PIECE($GET(^VEN(7.41,+$GET(DEFEF),11)),U,4)
IF 'DELAY
SET DELAY=0
+3 SET T1=$$NOW^VENPCCU
+4 SET T2=$$FMADD^XLFDT(T1,,DELAY)
+5 QUIT T2
+6 ;
HS(VIEN,DEPTIEN) ; EP-PRINT PCC+ HEALTH SUMMARY WITHIN MOJO (PEN MODE ONLY)
HSQ ; TEMP BYPASS HS PRINTOUT
QUIT
+1 NEW %,DEFHS,DFN
+2 IF '$DATA(CFIGIEN)
SET CFIGIEN=$$CFG^VENPCCU
+3 ; OK TO PRINT HS & REQD VARIABLES ARE PRESENT
IF '$GET(EFONLY)
IF '$GET(OGONLY)
IF $GET(DEPTIEN)
IF $GET(VIEN)
+4 IF '$TEST
QUIT
+5 SET DFN=$PIECE($GET(^AUPNVSIT(VIEN,0)),U,5)
IF 'DFN
QUIT
+6 SET DEFHS=+$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U,6)
+7 IF 'DEFHS
Begin DoDot:1
+8 SET %=+$PIECE($GET(^DPT(DFN,0)),U,3)
+9 ; AGE <12 SO USE PEDS HS
IF %
SET %=(DT-%)\10000
IF %<12
SET DEFHS=$ORDER(^APCHCTL("B","PEDIATRIC",0))
IF DEFHS
QUIT
+10 SET DEFHS=$ORDER(^APCHCTL("B","ADULT REGULAR",0))
+11 QUIT
End DoDot:1
IF 'DEFHS
QUIT
+12 DO HS^VENPCC2A(DFN,DEFHS,VIEN,DEPTIEN)
+13 QUIT
+14 ;
+15 ; --------------------------------------------------
+16 ;
SCX(PRV,VISIT,VCN,CSIEN) ; EP-SCHEDULING PKG INTERFACE FROM BSDX
+1 NEW %,%Y,CIEN,TOT,DEPT,CFIGIEN,DEPTIEN,DIC,X,Y,LOC,PGRP,VPFLAG,APPT,DEFEF,DEFHS,EFONLY,EXT,VARS,ELIG,TIME,DFN,%DT,DI,DISYS,DLAYGO
+2 NEW IO,IOF,IOM,ION,IOS,IOST,IOT,IOXY,%E,POP
+3 NEW OGFLAG
+4 SET OGFLAG=$GET(BSDXVEN("OUTGUIDE"))
+5 SET OGFLAG=$SELECT(OGFLAG="true":1,1:0)
+6 SET PRV=+$$PRV^VENPCCU(+$GET(PRV))
+7 SET CFIGIEN=$$CFG^VENPCCU
+8 SET DEPTIEN=$GET(BSDXVEN("CLINIC"))
+9 IF '+DEPTIEN
QUIT
+10 IF '$GET(PRV)
SET PRV=$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U,2)
IF 'PRV
SET PRV=$PIECE($GET(^VEN(7.5,CFIGIEN,0)),U,13)
+11 IF '$DATA(^VA(200,+$GET(PRV),0))
QUIT
+12 SET DEFEF=$GET(BSDXVEN("FORM"))
+13 IF '+DEFEF
QUIT
+14 SET DEFHS=""
SET EFONLY=1
SET APPT=$GET(ASDDT)
SET EXT=""
+15 DO QUEUE^VENPCCA(VISIT,DEPTIEN,"","","",PRV)
+16 IF $DATA(NOTASK)
DO EN1^VENPCCA("D",1)
+17 SET VARS=$$PACK^VENPCC
SET EXT=""
+18 DO EN1^VENPCCA("J",1)
+19 IF $DATA(VPFLAG)
KILL HSONLY,VPFLAG
+20 QUIT
+21 ;
+22 ; -----------------------
+23 ;
ERR(ERRID,ERRTXT) ; EP-Error processing
+1 IF '+$GET(NODE)
SET NODE=999999
+2 SET NODE=NODE+1
+3 SET @OUT@(NODE)=ERRID_"^"_ERRTXT_U_$CHAR(30)
+4 SET NODE=NODE+1
+5 SET @OUT@(NODE)=$CHAR(31)
+6 QUIT
+7 ;
ERROR ; EP-MUMPS ERROR TRAP
+1 DO ^%ZTER
+2 IF '+$GET(NODE)
NEW NODE
SET NODE=999999
+3 SET NODE=NODE+1
+4 DO ERR(0,"VENPCCW M Error: <"_$GET(%ZTERROR)_">")
+5 QUIT
+6 ;