VENPCC ; IHS/OIT/GIS - ENTRY POINTS FOR THE PCC+ CHECK IN MODULE ;
;;2.6;PCC+;;NOV 12, 2007
;
; DEDICATED TO DON ENOS, DEAR FRIEND AND PRIMARY AUTHOR OF THE PCC
; 2.5 ENHANCEMENTS: NURSE CHECK IN AND EFNOTASK ENTRY POINT
;
CKIN ; EP-TO GENERATE AN EF AND HS DURING A NON-ILC CHECK-IN
NEW CLINIC,DEPTIEN,DIC,LOC,NOW,PATIENT,PRVIEN,TYPE,VIEN,X,Y,%,%H,%I,%Q,%Y,DTOUT,DUOUT,DEFEF,DEFHS,RESULT,CFIGIEN,VCN,AUPNDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX,DIPGM,APPT,VPFLAG,POP,NCCANCEL
N DISYS,DDH,AGE,SEX,SSN,DFN,DOB,%T,%1,%DT,ELIG,OGFLAG,EXT,UPDEM
D ^XBCLS
W !,"Welcome to the PATIENT CHECK-IN MODULE...."
S CFIGIEN=$$CFG^VENPCCU I 'CFIGIEN W !,"Unable to find configuration parameters! Notify the site manager...",!! Q
PATIENT ; EP-CHECK IN PATIENT
G ^VENPCCA ; VER 2.2 CHECK IN PROCESS
;
; -------------------------------------------------------------------
; CHECK-IN CODE IN VENPCCA AFTER VER 1.X
; ---------------------------------------------------------------------
;
DEBUG ; EP-FOR DEBUG MODE - NO VISIT CREATED AND RECORD SENT TO FILE NOT TCP SOCKET
N VENDEMO,VENNOTCP,NOTASK,VENDEBUG
S (NOTASK,VENDEMO,VENNOTCP)=1
D CKIN
Q
;
EFNOTASK ; EP-NO TASK (FOREGROUND MODE), DEBUG, NO VISIT, ENCOUNTER FORM ONLY
N EFONLY S EFONLY=1
NOTASK ; EP-NO TASK, DEBUG, NO VISIT
N NOTASK,VENDEMO S NOTASK=1,VENDEMO=1
D VENPCC
Q
;
HSNOTASK ; EP-NO TASK (FOREGROUND MODE), HEALTH SUMMARY ONLY
N NOTASK,HSONLY
S NOTASK=1,HSONLY=1
D VENPCC
Q
;
NCI ; EP-NURSE CHECK IN
N NCIFLAG
S NCIFLAG=1
D CKIN
Q
;
DEMO ; EP-FROM VEN MENU OPTION ; DEMO MODE - NO VISIT CREATED
N VENDEMO S VENDEMO=1
D CKIN
Q
;
DEMODATA ; EP-CREATE A DEMO DATA FILE IN THE TEMP DIRECTORY
; ASSUMES THAT DEMODATA ALREADY HAS A VALUE = DEMO FILE NAME
N EFONLY,VENDEMO,NOTASK
I '$L($G(DEMODATA)) Q ; THE DEMO DATA FILE MUST HAVE A NAME
S DEMODATA=$P(DEMODATA,".") ; STRIP OFF FILE EXTENSION
S EFONLY=1,VENDEMO=1,NOTASK=1
D CKIN
Q
;
REPRINT ; EP-FROM THE MENU OPTION ; REPRINT THE EF
N REPRINT S REPRINT=1
EFONLY ; EP-FROM VEN MENU OPTION ; PRINT THE EF ONLY
N EFONLY S EFONLY=1
D CKIN
Q
;
HSONLY ; EP-FROM VEN MENU OPTION ; PRINT THE HS ONLY
N HSONLY,VENDEMO S (HSONLY,VENDEMO)=1
D CKIN
Q
;
OGONLY ; EP-FROM VEN MENU OPTION ; OUTGUIDE ONLY
N OGONLY,VENDEMO S (OGONLY,VENDEMO)=1
D VENPCC
Q
;
EHR ; EP - USE THE VISIT CREATED BY THE EHR
N EHRFLAG
S EHRFLAG=1
D VENPCC
Q
;
CKONLY ; EP-CHECKIN ONLY
N CHECKIN S CHECKIN=1
D CKIN
Q
;
PGRP(CIEN) ; EP-RETURN THE SPECIAL PRINTER GROUP (SPGRP) ; ONLY FOR HS ONLY, TELEPHONE TRIAGE, OR CHART REV
; PATCHED BY GIS/OIT 1/15/06 ; PCC+ 2.5 PATCH 2
N DIC,X,Y,LOC,DUOUT,DTOUT,CNAME,PGRP
I $G(HSONLY) G PGRP0
S CNAME=$P($G(^DIC(40.7,CIEN,0)),U) ; GET THE STANDARD CLINIC STOP NAME
I CNAME'["TELEPHONE",CNAME'["CHART REVIEW" Q "" ; CAN ONLY DEFINE SPGRP FOR TELE TRIAGE & CHART REVIEW
PGRP0 S DIC="^VEN(7.95,",DIC(0)="AEQM",DIC("A")="Printer location: "
S DIC("S")="I $P($G(^(2)),U,1)"
PGRP1 D ^DIC I Y=-1 D ^XBFMK Q -1
S PGRP=$P($G(^VEN(7.95,+Y,2)),U)
D ^XBFMK
Q PGRP
;
DOCS N PATH,% ; EP-FROM VENPCCMX ; COUNT DOCUMENTS
S PATH=$G(^VEN(7.5,CFIGIEN,1)) I '$L(PATH) Q
S %=$$COUNT^VENPCCP(PATH)
I %'=1 W !,"There are now ",%," documents in the print queue"
E W !,"There is one document in the print queue"
Q
;
PACK() ; EP-TO PACK UP ENVIRONMENTAL VARIABLES
N %,Y,I,X,JOB,VENDEV
S %="DT^DTIME^DUZ^DUZ(0)^DUZ(2)^VENDEV^JOB^NOTASK^VENDEMO^VENNOTCP^EFONLY^HSONLY^OGONLY^OGFLAG^SPGRP",Y="",JOB=$J,VENDEV=$G(IO)
F I=1:1:$L(%,U) S X=$P(%,U,I) I $D(@X) S $P(Y,U,I)=X_"="_@X
Q Y
;
DUP(DFN,DIEN) ; EP-GIVEN A DFN AND DEPT STOP IEN RETURN A '1' IF DUPLICATE VISIT
I '$D(^DPT(+$G(DFN),0)) Q 0
I '$D(^VEN(7.95,+$G(DIEN),0)) Q 0
N QIEN,TIME,DIFF,DEPT,STOP,VISIT,LIM,VIEN,X,CS,V,VDT,CSIEN,%,%Y,TIME
; FIRST CHECK THE VISIT FILE
S VISIT=999999999999,STOP=0,LIM=$$FMADD^XLFDT($$NOW^VENPCCU,0,-6,0,0),VIEN=0
F V=1:1:10 S VISIT=$O(^AUPNVSIT("AC",DFN,VISIT),-1) Q:'VISIT D I STOP Q ; CHK LAST 10 VISITS FOR MATCHES
. S X=$G(^AUPNVSIT(VISIT,0)) I '$L(X) Q
. S VDT=+X
. I VDT<LIM Q
. S CS=$P(X,U,8) I CS,CS=$P($G(^VEN(7.95,+$G(DIEN),0)),U,4) S STOP=1,VIEN=VISIT Q
. Q
I 'VIEN,$G(EHRFLAG) W !,"PCC+ can't locate a valid EHR visit! Request cancelled.." Q "" ; IF EHR FLAG IS SET, A DUPLCATE MUST EXIST!!!!
I 'VIEN W !,"A new VISIT will be created for this encounter" Q "" ; NO DUPLICATE FOUND
; AT THIS POINT A POTENTIAL VISIT EXISTS
I $G(EHRFLAG) W !,"PCC+ has successfully located the EHR visit!" Q VIEN
DNCI I $G(NCIFLAG) D Q VIEN ; AUTOMATICALLY ASSIGN THE VISIT IF NURSE CHECK IN FLAG IS SET
. S CSIEN=$P($G(^AUPNVSIT(VIEN,0)),U,8) I 'CSIEN S VIEN="" Q
. S CS=$P($G(^DIC(40.7,CSIEN,0)),U) I '$L(CS) S VIEN="" Q
. S TIME="today"
. S %=+$G(^AUPNVSIT(VIEN,0)) I '% Q
. I $P(%,".",2)'=12 S TIME="on "_$$FMTE^XLFDT(%)
. W !,"This patient checked into a """,CS,""" clinic ",TIME
. W !,"Want to link your check-in measurements to this existing"
. W !,"visit (Answer NO only if you want to create a new visit!)"
. S %=1 D YN^DICN
. I %=1 Q
. W !,"OK, a new visit will be created to contain your check-in measurements"
. S VIEN="" ; FORCE THE CREATION OF A NEW NCI VISIT
. Q
DREG ; FROM HERE ON, POSSIBLE MATCH EXISTS BUT IT IS A REG VISIT - NOT AN NCI VISIT
W !,"This patient had a visit in this clinic within the past 6 hours..."
W !,"Want to create another visit" S %=2
D YN^DICN
I %=1 Q VIEN ; FORCE THE CREATION OF A NEW VISIT
Q ""
;
QUEUE(VISIT,DEPTIEN,OGFLAG,TRFLAG,UPDEM,PRVIEN) ; EP-LEGACY SIGNATURE EP FOR ANMC
G QSIG^VENPCCA
;
PIMS(PIMSDFN) ; EP - PRINTS A PCC+ FORM VIA USUAL DIALOG. CALLED DURING PIMS SCHEDULING
; PATIENT DFN IS KNOWN BUT NO VISIT WILL BE CREATED
; PATCHED BY GIS/OIT 6/15/06 ; PCC+ 2.5 PATCH 5
I '$D(^DPT(+$G(PIMSDFN),0)) Q
N NOVISIT
S NOVISIT=1
D CKIN
Q
;
VENPCC ; IHS/OIT/GIS - ENTRY POINTS FOR THE PCC+ CHECK IN MODULE ;
+1 ;;2.6;PCC+;;NOV 12, 2007
+2 ;
+3 ; DEDICATED TO DON ENOS, DEAR FRIEND AND PRIMARY AUTHOR OF THE PCC
+4 ; 2.5 ENHANCEMENTS: NURSE CHECK IN AND EFNOTASK ENTRY POINT
+5 ;
CKIN ; EP-TO GENERATE AN EF AND HS DURING A NON-ILC CHECK-IN
+1 NEW CLINIC,DEPTIEN,DIC,LOC,NOW,PATIENT,PRVIEN,TYPE,VIEN,X,Y,%,%H,%I,%Q,%Y,DTOUT,DUOUT,DEFEF,DEFHS,RESULT,CFIGIEN,VCN,AUPNDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX,DIPGM,APPT,VPFLAG,POP,NCCANCEL
+2 NEW DISYS,DDH,AGE,SEX,SSN,DFN,DOB,%T,%1,%DT,ELIG,OGFLAG,EXT,UPDEM
+3 DO ^XBCLS
+4 WRITE !,"Welcome to the PATIENT CHECK-IN MODULE...."
+5 SET CFIGIEN=$$CFG^VENPCCU
IF 'CFIGIEN
WRITE !,"Unable to find configuration parameters! Notify the site manager...",!!
QUIT
PATIENT ; EP-CHECK IN PATIENT
+1 ; VER 2.2 CHECK IN PROCESS
GOTO ^VENPCCA
+2 ;
+3 ; -------------------------------------------------------------------
+4 ; CHECK-IN CODE IN VENPCCA AFTER VER 1.X
+5 ; ---------------------------------------------------------------------
+6 ;
DEBUG ; EP-FOR DEBUG MODE - NO VISIT CREATED AND RECORD SENT TO FILE NOT TCP SOCKET
+1 NEW VENDEMO,VENNOTCP,NOTASK,VENDEBUG
+2 SET (NOTASK,VENDEMO,VENNOTCP)=1
+3 DO CKIN
+4 QUIT
+5 ;
EFNOTASK ; EP-NO TASK (FOREGROUND MODE), DEBUG, NO VISIT, ENCOUNTER FORM ONLY
+1 NEW EFONLY
SET EFONLY=1
NOTASK ; EP-NO TASK, DEBUG, NO VISIT
+1 NEW NOTASK,VENDEMO
SET NOTASK=1
SET VENDEMO=1
+2 DO VENPCC
+3 QUIT
+4 ;
HSNOTASK ; EP-NO TASK (FOREGROUND MODE), HEALTH SUMMARY ONLY
+1 NEW NOTASK,HSONLY
+2 SET NOTASK=1
SET HSONLY=1
+3 DO VENPCC
+4 QUIT
+5 ;
NCI ; EP-NURSE CHECK IN
+1 NEW NCIFLAG
+2 SET NCIFLAG=1
+3 DO CKIN
+4 QUIT
+5 ;
DEMO ; EP-FROM VEN MENU OPTION ; DEMO MODE - NO VISIT CREATED
+1 NEW VENDEMO
SET VENDEMO=1
+2 DO CKIN
+3 QUIT
+4 ;
DEMODATA ; EP-CREATE A DEMO DATA FILE IN THE TEMP DIRECTORY
+1 ; ASSUMES THAT DEMODATA ALREADY HAS A VALUE = DEMO FILE NAME
+2 NEW EFONLY,VENDEMO,NOTASK
+3 ; THE DEMO DATA FILE MUST HAVE A NAME
IF '$LENGTH($GET(DEMODATA))
QUIT
+4 ; STRIP OFF FILE EXTENSION
SET DEMODATA=$PIECE(DEMODATA,".")
+5 SET EFONLY=1
SET VENDEMO=1
SET NOTASK=1
+6 DO CKIN
+7 QUIT
+8 ;
REPRINT ; EP-FROM THE MENU OPTION ; REPRINT THE EF
+1 NEW REPRINT
SET REPRINT=1
EFONLY ; EP-FROM VEN MENU OPTION ; PRINT THE EF ONLY
+1 NEW EFONLY
SET EFONLY=1
+2 DO CKIN
+3 QUIT
+4 ;
HSONLY ; EP-FROM VEN MENU OPTION ; PRINT THE HS ONLY
+1 NEW HSONLY,VENDEMO
SET (HSONLY,VENDEMO)=1
+2 DO CKIN
+3 QUIT
+4 ;
OGONLY ; EP-FROM VEN MENU OPTION ; OUTGUIDE ONLY
+1 NEW OGONLY,VENDEMO
SET (OGONLY,VENDEMO)=1
+2 DO VENPCC
+3 QUIT
+4 ;
EHR ; EP - USE THE VISIT CREATED BY THE EHR
+1 NEW EHRFLAG
+2 SET EHRFLAG=1
+3 DO VENPCC
+4 QUIT
+5 ;
CKONLY ; EP-CHECKIN ONLY
+1 NEW CHECKIN
SET CHECKIN=1
+2 DO CKIN
+3 QUIT
+4 ;
PGRP(CIEN) ; EP-RETURN THE SPECIAL PRINTER GROUP (SPGRP) ; ONLY FOR HS ONLY, TELEPHONE TRIAGE, OR CHART REV
+1 ; PATCHED BY GIS/OIT 1/15/06 ; PCC+ 2.5 PATCH 2
+2 NEW DIC,X,Y,LOC,DUOUT,DTOUT,CNAME,PGRP
+3 IF $GET(HSONLY)
GOTO PGRP0
+4 ; GET THE STANDARD CLINIC STOP NAME
SET CNAME=$PIECE($GET(^DIC(40.7,CIEN,0)),U)
+5 ; CAN ONLY DEFINE SPGRP FOR TELE TRIAGE & CHART REVIEW
IF CNAME'["TELEPHONE"
IF CNAME'["CHART REVIEW"
QUIT ""
PGRP0 SET DIC="^VEN(7.95,"
SET DIC(0)="AEQM"
SET DIC("A")="Printer location: "
+1 SET DIC("S")="I $P($G(^(2)),U,1)"
PGRP1 DO ^DIC
IF Y=-1
DO ^XBFMK
QUIT -1
+1 SET PGRP=$PIECE($GET(^VEN(7.95,+Y,2)),U)
+2 DO ^XBFMK
+3 QUIT PGRP
+4 ;
DOCS ; EP-FROM VENPCCMX ; COUNT DOCUMENTS
NEW PATH,%
+1 SET PATH=$GET(^VEN(7.5,CFIGIEN,1))
IF '$LENGTH(PATH)
QUIT
+2 SET %=$$COUNT^VENPCCP(PATH)
+3 IF %'=1
WRITE !,"There are now ",%," documents in the print queue"
+4 IF '$TEST
WRITE !,"There is one document in the print queue"
+5 QUIT
+6 ;
PACK() ; EP-TO PACK UP ENVIRONMENTAL VARIABLES
+1 NEW %,Y,I,X,JOB,VENDEV
+2 SET %="DT^DTIME^DUZ^DUZ(0)^DUZ(2)^VENDEV^JOB^NOTASK^VENDEMO^VENNOTCP^EFONLY^HSONLY^OGONLY^OGFLAG^SPGRP"
SET Y=""
SET JOB=$JOB
SET VENDEV=$GET(IO)
+3 FOR I=1:1:$LENGTH(%,U)
SET X=$PIECE(%,U,I)
IF $DATA(@X)
SET $PIECE(Y,U,I)=X_"="_@X
+4 QUIT Y
+5 ;
DUP(DFN,DIEN) ; EP-GIVEN A DFN AND DEPT STOP IEN RETURN A '1' IF DUPLICATE VISIT
+1 IF '$DATA(^DPT(+$GET(DFN),0))
QUIT 0
+2 IF '$DATA(^VEN(7.95,+$GET(DIEN),0))
QUIT 0
+3 NEW QIEN,TIME,DIFF,DEPT,STOP,VISIT,LIM,VIEN,X,CS,V,VDT,CSIEN,%,%Y,TIME
+4 ; FIRST CHECK THE VISIT FILE
+5 SET VISIT=999999999999
SET STOP=0
SET LIM=$$FMADD^XLFDT($$NOW^VENPCCU,0,-6,0,0)
SET VIEN=0
+6 ; CHK LAST 10 VISITS FOR MATCHES
FOR V=1:1:10
SET VISIT=$ORDER(^AUPNVSIT("AC",DFN,VISIT),-1)
IF 'VISIT
QUIT
Begin DoDot:1
+7 SET X=$GET(^AUPNVSIT(VISIT,0))
IF '$LENGTH(X)
QUIT
+8 SET VDT=+X
+9 IF VDT<LIM
QUIT
+10 SET CS=$PIECE(X,U,8)
IF CS
IF CS=$PIECE($GET(^VEN(7.95,+$GET(DIEN),0)),U,4)
SET STOP=1
SET VIEN=VISIT
QUIT
+11 QUIT
End DoDot:1
IF STOP
QUIT
+12 ; IF EHR FLAG IS SET, A DUPLCATE MUST EXIST!!!!
IF 'VIEN
IF $GET(EHRFLAG)
WRITE !,"PCC+ can't locate a valid EHR visit! Request cancelled.."
QUIT ""
+13 ; NO DUPLICATE FOUND
IF 'VIEN
WRITE !,"A new VISIT will be created for this encounter"
QUIT ""
+14 ; AT THIS POINT A POTENTIAL VISIT EXISTS
+15 IF $GET(EHRFLAG)
WRITE !,"PCC+ has successfully located the EHR visit!"
QUIT VIEN
DNCI ; AUTOMATICALLY ASSIGN THE VISIT IF NURSE CHECK IN FLAG IS SET
IF $GET(NCIFLAG)
Begin DoDot:1
+1 SET CSIEN=$PIECE($GET(^AUPNVSIT(VIEN,0)),U,8)
IF 'CSIEN
SET VIEN=""
QUIT
+2 SET CS=$PIECE($GET(^DIC(40.7,CSIEN,0)),U)
IF '$LENGTH(CS)
SET VIEN=""
QUIT
+3 SET TIME="today"
+4 SET %=+$GET(^AUPNVSIT(VIEN,0))
IF '%
QUIT
+5 IF $PIECE(%,".",2)'=12
SET TIME="on "_$$FMTE^XLFDT(%)
+6 WRITE !,"This patient checked into a """,CS,""" clinic ",TIME
+7 WRITE !,"Want to link your check-in measurements to this existing"
+8 WRITE !,"visit (Answer NO only if you want to create a new visit!)"
+9 SET %=1
DO YN^DICN
+10 IF %=1
QUIT
+11 WRITE !,"OK, a new visit will be created to contain your check-in measurements"
+12 ; FORCE THE CREATION OF A NEW NCI VISIT
SET VIEN=""
+13 QUIT
End DoDot:1
QUIT VIEN
DREG ; FROM HERE ON, POSSIBLE MATCH EXISTS BUT IT IS A REG VISIT - NOT AN NCI VISIT
+1 WRITE !,"This patient had a visit in this clinic within the past 6 hours..."
+2 WRITE !,"Want to create another visit"
SET %=2
+3 DO YN^DICN
+4 ; FORCE THE CREATION OF A NEW VISIT
IF %=1
QUIT VIEN
+5 QUIT ""
+6 ;
QUEUE(VISIT,DEPTIEN,OGFLAG,TRFLAG,UPDEM,PRVIEN) ; EP-LEGACY SIGNATURE EP FOR ANMC
+1 GOTO QSIG^VENPCCA
+2 ;
PIMS(PIMSDFN) ; EP - PRINTS A PCC+ FORM VIA USUAL DIALOG. CALLED DURING PIMS SCHEDULING
+1 ; PATIENT DFN IS KNOWN BUT NO VISIT WILL BE CREATED
+2 ; PATCHED BY GIS/OIT 6/15/06 ; PCC+ 2.5 PATCH 5
+3 IF '$DATA(^DPT(+$GET(PIMSDFN),0))
QUIT
+4 NEW NOVISIT
+5 SET NOVISIT=1
+6 DO CKIN
+7 QUIT
+8 ;