Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: VENPCCW

VENPCCW.m

Go to the documentation of this file.
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
 ;