VENPCC1 ; IHS/OIT/GIS - CREATE THE PCC+ ENCOUNTER FORM AND HEALTH SUMMARY ;
;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
;
; MAIN DATA EXRACTOR IS ^VENPCC10 IN 2.2
; THIS ROUTINE DOES ERROR PROCESSING, PRINT SERVICE CONNECTION/PACKAGING, AND EXTENDED PRINT GRP MGMT
; IN VER 2.5 IT MANAGES ALTERNAT OUTPUT PACKAGING FOR THE NEW PRINT SERVICE
; PATCH 4 ADD SUPPORT FOR AN INTEGRATED LABEL PRINTER CYCLE
;
; ---------------------------------------
;
MERR ; EP-M ERROR TRAP
S X="ERRQ^VENPCC1",@^%ZOSF("TRAP") ; SET MUMPS ERROR TRAP AT THIS LEVEL
I $G(ERRSTOP) Q
S ERRSTOP=1
S DFN=$P($G(^AUPNVSIT(+$G(VISIT),0)),"^",5)
X ("S %=$"_"ZE")
S ERR="MUMPS OS reports error: "_%
D ERR(ERR)
Q
;
ERR1 S ERR="Missing or invalid visit IEN" D ERR(ERR) Q ; EP-FROM VENPCC10
ERR2 S ERR="Undefined print group" D ERR(ERR) Q ; EP-FROM SEVERAL VEN ROUTINES
ERR3 S ERR="Missing or invalid patient DFN" D ERR(ERR) Q ; EP-FROM VENPCC2
ERR4 S ERR="Unable to open a temporary DOS file" D ERR(ERR) Q ; EP-FROM VENPCC10
ERR5 S ERR="Unable to generate demographic data" D ERR(ERR) Q ; EP-FROM VENPCC10
ERR6 S ERR="Missing preference table for provider #"_PRV D ERR(ERR) Q ; EP-FROM VENPCC10
ERR7 S ERR="Missing path for configuration #"_CFIGIEN D ERR(ERR) Q ; EP-FROM VENPCC2
ERR8 S ERR="Missing or invalid configuration" D ERR(ERR) Q ; EP-FROM VENPCC10
ERR9 S ERR="Missing or invalid template" D ERR(ERR) Q ; EP-FROM VENPCC10
ERR10 S ERR="Unable to access header file data" D ERR(ERR) Q ; EP-FROM VENPCC10
ERR11 S ERR="Requested encounter form not available at this time" D ERR(ERR) ; EP-FROM VENPCC10
Q
;
ERR(ERR) ; EP-FROM SEVERAL VEN CHECK-IN ROUTINES ; MAKE AN ENTRY IN THE ERROR LOG
I $G(ERR)="" Q
NEW %,%DT,%H,%I,%Q,%Y,D,D0,DA,DI,DIC,DIE,DQ,DR,X,Y,DLAYGO,GBL,MGBL
S GBL="^TMP("_"""BSDX"","""_$J_""",1)",MGBL=$NA(^TMP("VEN MON"))
D NOW^%DTC S X=%
S DIC="^VEN(7.7,",DIC(0)="L",DLAYGO=19707.7 D ^DIC
I Y=-1 Q
S DIE=DIC,DA=+Y
S DR=".02////^S X=$G(VISIT);.03////^S X=$G(DUZ);.04////^S X=$G(DUZ(2));.05////^S X=$G(VENDEV);.07////^S X=$G(DFN);1////^S X=$G(ERR)"
; S %=$C(68,85,90),@%(0)=$C(64)
L +^VEN(7.7,DA):1 I $T D ^DIE L -^VEN(7.7,DA)
I $G(MOJOFLAG) S @GBL="1^"_ERR_U_$C(30)
I $G(JOB),$G(MGBL)'="",$D(@MGBL@(JOB)) S @MGBL@(JOB)=ERR H 2
Q
;
ERRQ Q
;
; ----------------------------------------------------
;
TXT(DFN) ; EP - MAKE THE DATA FILE ; MOJO CODE HAS BRANCHED OFF BEFORE THIS EP
; CONTAINS CODE TO SUPPRT VER 2.5 PRINT SERVICE
N N,NAME,%,LOK,MGBL
S %=$$HEADER^VENPCCU(+$G(DEFEF)) I $L(%) S @TMP@(1,"header")=% ; PATCHED BY GIS/OIT 10/15/05 ; PCC+ 2.5 PATCH 1
I '$G(VER25)!($D(DEMODATA)) S N=0 F S N=$O(@TMP@(9,N)) Q:'N D ; NO NEED TO DEFINE DELIMITED POSITIONS (SS=8) IN VER 2.5
. S NAME=@TMP@(9,N)
. S @TMP@(8,N)=$G(@TMP@(1,NAME))
. S @TMP@(8,N)=$P(@TMP@(8,N),U)
. I $G(SPECHOLD(NAME))'="" S SPECHOLD(8,N)=SPECHOLD(NAME) K SPECHOLD(NAME)
. Q
TCP ; EP-FROM VENPCC2 ; ENTRY POINT FOR HS
; PATCHED BY GIS/OIT 11/11/07 TO PREVENT MAXSTG ERROR ON HEALTH SUMMARY
N XREC,REC,REC1
I $G(CFIGIEN),$G(DFN),$G(DEPTIEN)
E S ERR="REQUIRED PCC+ VARIABLE IS UNDEFINED" D ERR(ERR) Q
N N,SOCKET,IP,REC,ERR,%,IPA,A,B,PATH,FILE,POP,TOT,DPATH,PSTUFF,PGRP
I $D(DEMODATA) S PATH=$G(^VEN(7.5,+$G(CFIGIEN),3)) ; CREATING A DEMO FILE
E S PATH=$G(^VEN(7.5,+$G(CFIGIEN),1))
I '$L(PATH) S ERR="MISSING PATH TO PRINT QUEUE" D ERR(ERR) Q
; S %=$G(^VEN(7.99,+$O(^VEN(7.99,"AB",+$G(DEPTIEN),0)),1)) I $L(%) S PATH=% ; STUB FOR ENTERPRISE PCC+
I $D(DEMODATA) S FILE=DEMODATA_".txt" ; THIS IS A TEST DATA FILE FOR VER 2.5
E S FILE=$S($G(HSFLAG):"h",$G(OGONLY):"g",1:"e")_VISIT_".txt"
S REC="",TOT=0,PSTUFF=$$VNUM($G(VISIT),FILE,DEPTIEN)_";"_DUZ_";"_DUZ(2)_";"_DFN_";"_DUZ(0)_";"_$G(VENDEV)
S PGRP=$$PG(DEPTIEN,FILE)
I '$L(PGRP) S ERR="UNDEFINED PRINT GROUP" D ERR(ERR) Q ; IF NO PRINT GROUP IS DEFINED, STOP NOW!
25 I $G(VER25),'$D(DEMODATA) D V25 Q ; BRANCH TO VER 2.5 DATA FILE MAKER
HS I $G(HSFLAG) D
. S @TMP@(2,"PRINTER")=PSTUFF,@TMP@(2,"GROUP")=PGRP,LNO=0,XREC="REC"
. F S LNO=$O(@TMP@(3,LNO)) Q:'LNO S NAME=@TMP@(3,LNO) D I $G(RMAX) K RMAX Q
.. S LINE=$G(@TMP@(2,NAME)) S LINE=$TR(LINE,U,"")
.. I LNO>1 S @XREC=@XREC_U
.. S @XREC=@XREC_LINE
.. I XREC="REC1" Q
.. I $L(REC)>16000 S XREC="REC1",REC1="" ; SPLT ANY HS > 16000K ; PATCHED BY GIS/OIT 6/3/2008 2.6*1
.. Q
. Q
EFOG I '$G(HSFLAG) D
. S @TMP@(8,4)=PSTUFF,@TMP@(8,3)=PGRP
. I $G(OGONLY) S @TMP@(8,2)="og",%=$$MRP^VENPCCU I $L(%) S @TMP@(8,3)=%
. F N=1:1 Q:'$D(@TMP@(8,N)) D
.. I N'=1 S REC=REC_U
.. I $D(SPECHOLD(8,N)) S REC=REC_SPECHOLD(8,N) K SPECHOLD(8,N) Q
.. S REC=REC_@TMP@(8,N)
.. Q
. Q
F %=10,13,31,34,39 I REC[$C(%) S REC=$TR(REC,$C(%),"") ; STRIP OFF BAD CHARACTERS
I $D(REC1) F %=10,13,31,34,39 I REC1[$C(%) S REC1=$TR(REC1,$C(%),"") ; STRIP OFF BAD CHARACTERS
OPEN I $E(FILE)'="h" K REC1
S POP=$$OPN^VENPCCP(PATH,FILE,"W","W REC W:$D(REC1) REC1")
S TOT=TOT+1 I TOT>10 S ERR="UNABLE TO SEND FILE TO THE PRINT QUEUE" D ERR(ERR) Q
I POP H 3 G OPEN
I $E(FILE)="g" H 1
S %=$E(FILE)
I $D(DEMODATA) S MSG="Test file '"_DEMODATA_".txt' sent to TEMP folder" Q
I %="e",'$G(TRT),$P($G(^VEN(7.95,+$G(DEPTIEN),2)),U,11) S FILE="tt"_VISIT_".txt",TRT=1,$P(REC,U,3)=$$MRP^VENPCCU G OPEN
S MSG=$S(%="e":"Encounter form",%="h":"Health summary",%="l":"Label",1:"OutGuide")_" sent to print queue"
I $G(JOB) S MGBL=$NA(^TMP("VEN MON")),@MGBL@(JOB)=MSG H 2
E W !,MSG
I $G(LPFLAG) S LOK=0 D LABEL(LPFLAG) K LPFLAG I LOK G OPEN ; PATCHED BY GIS/OIT 03/28/06 ; PCC+ 2.5 PATCH 4 ; LABEL CYCLE
I '$G(OGFLAG)!($E(FILE)="g") K OGFLAG Q
PULL S $P(REC,U,2)="og"
S $P(REC,U,1)=25
S FILE="g"_VISIT_".txt"
S $P(REC,U,3)=$$MRP^VENPCCU
S PSTUFF=$P(REC,U,4),%=+PSTUFF
I % S %=$$VNUM(%,FILE,DEPTIEN)
I % S $P(PSTUFF,";",1)=%,$P(REC,U,4)=PSTUFF
G OPEN ; PRINT OUTGUIDE ; PATCHED BY GIS/OIT 4/15/08 ; PCC+ 2.6 PATCH 1 ; FIX OUTGUIDE PRINTING PROBLEM
;
LABEL(LPFLAG) ; EP - CONFIG OUTPUT FOR LABEL PRINTER ; PCC+ 2.5 PATCH 4
N LPG,LEF,TMN,HMN,X,Y,%
S LPG=$P($G(^VEN(7.4,+$G(LPFLAG),0)),U) I '$L(LPG) Q
S X=$G(^VEN(7.41,+$P($G(LPFLAG),U,2),0)) I '$L(X) Q
S HMN=$P(X,U,2) I '$L(HMN) Q ; HEADER MNEMONIC
S TMN=$P(X,U,3) I '$L(TMN) Q ; TEMPLATE MNEMONIC
S $P(REC,U,2)=TMN
S $P(REC,U,1)=HMN
S FILE="l"_(VISIT+3000)_".txt",LOK=1
S $P(REC,U,3)=LPG
S PSTUFF=$P(REC,U,4),%=+PSTUFF
I % S $P(PSTUFF,";",1)=(%+3000),$P(REC,U,4)=PSTUFF ; FORCE THE PRINT SERVICE TO USE THE CORRECT PRINTER
Q
;
V25 ; EP - FORMAT OUTPUT AND CREATE A DATA FILE FOR VER 2.5 PRINT SERVICE
I $G(HSFLAG) D HS25 ; MAKE HEADER FILE
I '$G(HSFLAG) D EFOG25 ; MAKE DATA FILE AND OG FILE
Q
;
HS25 ; EP - BUILD HEALTH SUMMARY DATA FILE
N HFIEN,POP,TOT,MMF,%,CNT
S @TMP@(2,"PRINTER")=PSTUFF,@TMP@(2,"GROUP")=PGRP
S HFIEN=$O(^VEN(7.49,"B","hs",0)) I 'HFIEN Q
S MMF="",TOT=0
HSOPN25 S POP=$$OPN^VENPCCP(PATH,FILE,"W","D MMF25^VENPCC1(2)")
S TOT=TOT+1
I TOT>10 S ERR="UNABLE TO SEND FILE TO THE PRINT QUEUE" D ERR(ERR) Q
I POP H 3 G HSOPN25 ; KEEP CYCLING UNTIL YOU CAN OPEN THE FILE
D MSG25(FILE) ; TELL USER WHAT IS HAPPENING
Q
;
EFOG25 ; EP - BUILD EF OR OG DATA FILE FOR VER 2.5
N HF,HFIEN,POP,TOT,MMF,%
S @TMP@(1,"printer")=PSTUFF,@TMP@(1,"group")=PGRP
I $G(OGONLY) S @TMP@(1,"template")="og",%=$$MRP^VENPCCU I $L(%) S @TMP@(1,"group")=%
S MMF="",TOT=0
I $E(FILE)="g" S HFIEN=$O(^VEN(7.49,"B","ef",0)) Q:'HFIEN G OPN25
S HF=$P($G(^VEN(7.41,+$G(DEFEF),0)),U,2) I '$L(HF) Q
S HFIEN=$O(^VEN(7.49,"B",HF,0)) I 'HFIEN Q
OPN25 S POP=$$OPN^VENPCCP(PATH,FILE,"W","D MMF25^VENPCC1(1)")
S TOT=TOT+1
I TOT>10 S ERR="UNABLE TO SEND FILE TO THE PRINT QUEUE" D ERR(ERR) Q
I POP H 3 G OPN25 ; KEEP CYCLING UNTIL YOU CAN OPEN THE FILE
D MSG25(FILE) ; TELL USER WHAT IS HAPPENING
I '$G(OGFLAG)!($E(FILE)="g") K OGFLAG,OGONLY K @TMP@(1) Q ; CLEANUP AND QUIT
S @TMP@(1,"template")="og"
S %=$$MRP^VENPCCU I $L(%) S @TMP@(1,"group")=%
S FILE="g"_VISIT_".txt"
S PSTUFF=@TMP@(1,"printer"),%=+PSTUFF
I % S %=$$VNUM(%,FILE,DEPTIEN)
I % S $P(PSTUFF,";",1)=%,@TMP@(1,"printer")=PSTUFF
G OPN25 ; REPEAT THE PROCESS TO CREATE THE OUTGUIDE FILE
;
MMF25(SS) ; EP - NEW WAY TO POPULATE THE DATA FILE
N MMF,VAL,CNT,REC,%
S MMF="",CNT=0,REC=""
M1 S MMF=$O(^VEN(7.49,HFIEN,1,"B",MMF))
I MMF="" W:$L(REC) !,REC W ! Q
S VAL=$G(@TMP@(SS,MMF))
I $D(SPECHOLD(MMF)) S VAL=SPECHOLD(MMF) K SPECHOLD(MMF)
I $L(VAL) F %=10,13,30,31,34,39 I VAL[$C(%) S VAL=$TR(VAL,$C(%),"") ; STRIP OFF BAD CHARACTERS
I $L(REC) S REC=REC_U
S REC=REC_MMF_$C(30)_VAL
F Q:$L(REC)<501 D ; DIVIDE THE FILE INTO 500 CHARACTER CHUNKS
. I CNT W !
. W $E(REC,1,500)
. S REC=$E(REC,501,999999)
. S CNT=CNT+1
. Q
G M1
;
MSG25(FILE) ; EP - REPORT STATUS
N %,MSG,MGBL
S %=$E(FILE)
S MSG=$S(%="e":"Encounter form",%="h":"Health summary",1:"OutGuide")_" sent to print queue"
I $G(JOB) S MGBL=$NA(^TMP("VEN MON")),@MGBL@(JOB)=MSG H 2
E W !,MSG
Q
;
; -----------------------
;
PG(DEPTIEN,FILE) ; EP-GIVEN A DATA FILE AND DEPT, RETURN THE PRINT GROUP ; USED BY PRINT DEAMON
I $G(SPGRP) Q $P($G(^VEN(7.4,SPGRP,0)),U) ; DIRECT ENTRY OF PRINT GROUP (LEGACY)
N TYPE,PG,%,X,Y
S TYPE=$E(FILE)
I TYPE="g" Q $$MRP^VENPCCU
I TYPE'="h" D Q PG ; ENCOUNTER FROM
. S %=$P($G(^VEN(7.95,DEPTIEN,2)),U,3),X=""
. I % S X=$P($G(^VEN(7.95,DEPTIEN,2)),U,8) ; TRIAGE
. I X="" S X=$P($G(^VEN(7.95,DEPTIEN,2)),U) ; STANDARD
. I X="" S X=0
. S PG=$P($G(^VEN(7.4,X,0)),U)
. Q
S %=$P($G(^VEN(7.95,DEPTIEN,2)),U,9),X="" ; HEALTH SUMMARY
I % S X=% ; CLINIC OVERRIDE FOR HS PG
I 'X,$P($G(^VEN(7.5,CFIGIEN,0)),U,10) Q $$MRP^VENPCCU ; ALWAYS PRINT HS IN MR
I 'X S X=$P($G(^VEN(7.95,DEPTIEN,2)),U) ; USE EF PG FOR HS
S PG=$P($G(^VEN(7.4,X,0)),U)
Q PG
;
VNUM(VISIT,FILE,DEPTIEN) ; EP - MODIFY VISIT NUMBER TO ASSURE DOCUMENT PRINTS ON THE CORRECT PRINTER
I $G(VISIT),$L(FILE),$G(DEPTIEN)
E Q $G(VISIT)
I $E(FILE)="e",$P($G(^VEN(7.95,DEPTIEN,2)),U,3) Q (VISIT+1500)
I $E(FILE)="h",'$D(HSONLY),$$PG(DEPTIEN,"e")'=$$PG(DEPTIEN,"h") Q (VISIT+1000)
I $E(FILE)="g",'$D(OGONLY),$$PG(DEPTIEN,"e")'=$$PG(DEPTIEN,"g") Q (VISIT+2000)
Q VISIT
;
VENPCC1 ; IHS/OIT/GIS - CREATE THE PCC+ ENCOUNTER FORM AND HEALTH SUMMARY ;
+1 ;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
+2 ;
+3 ; MAIN DATA EXRACTOR IS ^VENPCC10 IN 2.2
+4 ; THIS ROUTINE DOES ERROR PROCESSING, PRINT SERVICE CONNECTION/PACKAGING, AND EXTENDED PRINT GRP MGMT
+5 ; IN VER 2.5 IT MANAGES ALTERNAT OUTPUT PACKAGING FOR THE NEW PRINT SERVICE
+6 ; PATCH 4 ADD SUPPORT FOR AN INTEGRATED LABEL PRINTER CYCLE
+7 ;
+8 ; ---------------------------------------
+9 ;
MERR ; EP-M ERROR TRAP
+1 ; SET MUMPS ERROR TRAP AT THIS LEVEL
SET X="ERRQ^VENPCC1"
SET @^%ZOSF("TRAP")
+2 IF $GET(ERRSTOP)
QUIT
+3 SET ERRSTOP=1
+4 SET DFN=$PIECE($GET(^AUPNVSIT(+$GET(VISIT),0)),"^",5)
+5 XECUTE ("S %=$"_"ZE")
+6 SET ERR="MUMPS OS reports error: "_%
+7 DO ERR(ERR)
+8 QUIT
+9 ;
ERR1 ; EP-FROM VENPCC10
SET ERR="Missing or invalid visit IEN"
DO ERR(ERR)
QUIT
ERR2 ; EP-FROM SEVERAL VEN ROUTINES
SET ERR="Undefined print group"
DO ERR(ERR)
QUIT
ERR3 ; EP-FROM VENPCC2
SET ERR="Missing or invalid patient DFN"
DO ERR(ERR)
QUIT
ERR4 ; EP-FROM VENPCC10
SET ERR="Unable to open a temporary DOS file"
DO ERR(ERR)
QUIT
ERR5 ; EP-FROM VENPCC10
SET ERR="Unable to generate demographic data"
DO ERR(ERR)
QUIT
ERR6 ; EP-FROM VENPCC10
SET ERR="Missing preference table for provider #"_PRV
DO ERR(ERR)
QUIT
ERR7 ; EP-FROM VENPCC2
SET ERR="Missing path for configuration #"_CFIGIEN
DO ERR(ERR)
QUIT
ERR8 ; EP-FROM VENPCC10
SET ERR="Missing or invalid configuration"
DO ERR(ERR)
QUIT
ERR9 ; EP-FROM VENPCC10
SET ERR="Missing or invalid template"
DO ERR(ERR)
QUIT
ERR10 ; EP-FROM VENPCC10
SET ERR="Unable to access header file data"
DO ERR(ERR)
QUIT
ERR11 ; EP-FROM VENPCC10
SET ERR="Requested encounter form not available at this time"
DO ERR(ERR)
+1 QUIT
+2 ;
ERR(ERR) ; EP-FROM SEVERAL VEN CHECK-IN ROUTINES ; MAKE AN ENTRY IN THE ERROR LOG
+1 IF $GET(ERR)=""
QUIT
+2 NEW %,%DT,%H,%I,%Q,%Y,D,D0,DA,DI,DIC,DIE,DQ,DR,X,Y,DLAYGO,GBL,MGBL
+3 SET GBL="^TMP("_"""BSDX"","""_$JOB_""",1)"
SET MGBL=$NAME(^TMP("VEN MON"))
+4 DO NOW^%DTC
SET X=%
+5 SET DIC="^VEN(7.7,"
SET DIC(0)="L"
SET DLAYGO=19707.7
DO ^DIC
+6 IF Y=-1
QUIT
+7 SET DIE=DIC
SET DA=+Y
+8 SET DR=".02////^S X=$G(VISIT);.03////^S X=$G(DUZ);.04////^S X=$G(DUZ(2));.05////^S X=$G(VENDEV);.07////^S X=$G(DFN);1////^S X=$G(ERR)"
+9 ; S %=$C(68,85,90),@%(0)=$C(64)
+10 LOCK +^VEN(7.7,DA):1
IF $TEST
DO ^DIE
LOCK -^VEN(7.7,DA)
+11 IF $GET(MOJOFLAG)
SET @GBL="1^"_ERR_U_$CHAR(30)
+12 IF $GET(JOB)
IF $GET(MGBL)'=""
IF $DATA(@MGBL@(JOB))
SET @MGBL@(JOB)=ERR
HANG 2
+13 QUIT
+14 ;
ERRQ QUIT
+1 ;
+2 ; ----------------------------------------------------
+3 ;
TXT(DFN) ; EP - MAKE THE DATA FILE ; MOJO CODE HAS BRANCHED OFF BEFORE THIS EP
+1 ; CONTAINS CODE TO SUPPRT VER 2.5 PRINT SERVICE
+2 NEW N,NAME,%,LOK,MGBL
+3 ; PATCHED BY GIS/OIT 10/15/05 ; PCC+ 2.5 PATCH 1
SET %=$$HEADER^VENPCCU(+$GET(DEFEF))
IF $LENGTH(%)
SET @TMP@(1,"header")=%
+4 ; NO NEED TO DEFINE DELIMITED POSITIONS (SS=8) IN VER 2.5
IF '$GET(VER25)!($DATA(DEMODATA))
SET N=0
FOR
SET N=$ORDER(@TMP@(9,N))
IF 'N
QUIT
Begin DoDot:1
+5 SET NAME=@TMP@(9,N)
+6 SET @TMP@(8,N)=$GET(@TMP@(1,NAME))
+7 SET @TMP@(8,N)=$PIECE(@TMP@(8,N),U)
+8 IF $GET(SPECHOLD(NAME))'=""
SET SPECHOLD(8,N)=SPECHOLD(NAME)
KILL SPECHOLD(NAME)
+9 QUIT
End DoDot:1
TCP ; EP-FROM VENPCC2 ; ENTRY POINT FOR HS
+1 ; PATCHED BY GIS/OIT 11/11/07 TO PREVENT MAXSTG ERROR ON HEALTH SUMMARY
+2 NEW XREC,REC,REC1
+3 IF $GET(CFIGIEN)
IF $GET(DFN)
IF $GET(DEPTIEN)
+4 IF '$TEST
SET ERR="REQUIRED PCC+ VARIABLE IS UNDEFINED"
DO ERR(ERR)
QUIT
+5 NEW N,SOCKET,IP,REC,ERR,%,IPA,A,B,PATH,FILE,POP,TOT,DPATH,PSTUFF,PGRP
+6 ; CREATING A DEMO FILE
IF $DATA(DEMODATA)
SET PATH=$GET(^VEN(7.5,+$GET(CFIGIEN),3))
+7 IF '$TEST
SET PATH=$GET(^VEN(7.5,+$GET(CFIGIEN),1))
+8 IF '$LENGTH(PATH)
SET ERR="MISSING PATH TO PRINT QUEUE"
DO ERR(ERR)
QUIT
+9 ; S %=$G(^VEN(7.99,+$O(^VEN(7.99,"AB",+$G(DEPTIEN),0)),1)) I $L(%) S PATH=% ; STUB FOR ENTERPRISE PCC+
+10 ; THIS IS A TEST DATA FILE FOR VER 2.5
IF $DATA(DEMODATA)
SET FILE=DEMODATA_".txt"
+11 IF '$TEST
SET FILE=$SELECT($GET(HSFLAG):"h",$GET(OGONLY):"g",1:"e")_VISIT_".txt"
+12 SET REC=""
SET TOT=0
SET PSTUFF=$$VNUM($GET(VISIT),FILE,DEPTIEN)_";"_DUZ_";"_DUZ(2)_";"_DFN_";"_DUZ(0)_";"_$GET(VENDEV)
+13 SET PGRP=$$PG(DEPTIEN,FILE)
+14 ; IF NO PRINT GROUP IS DEFINED, STOP NOW!
IF '$LENGTH(PGRP)
SET ERR="UNDEFINED PRINT GROUP"
DO ERR(ERR)
QUIT
25 ; BRANCH TO VER 2.5 DATA FILE MAKER
IF $GET(VER25)
IF '$DATA(DEMODATA)
DO V25
QUIT
HS IF $GET(HSFLAG)
Begin DoDot:1
+1 SET @TMP@(2,"PRINTER")=PSTUFF
SET @TMP@(2,"GROUP")=PGRP
SET LNO=0
SET XREC="REC"
+2 FOR
SET LNO=$ORDER(@TMP@(3,LNO))
IF 'LNO
QUIT
SET NAME=@TMP@(3,LNO)
Begin DoDot:2
+3 SET LINE=$GET(@TMP@(2,NAME))
SET LINE=$TRANSLATE(LINE,U,"")
+4 IF LNO>1
SET @XREC=@XREC_U
+5 SET @XREC=@XREC_LINE
+6 IF XREC="REC1"
QUIT
+7 ; SPLT ANY HS > 16000K ; PATCHED BY GIS/OIT 6/3/2008 2.6*1
IF $LENGTH(REC)>16000
SET XREC="REC1"
SET REC1=""
+8 QUIT
End DoDot:2
IF $GET(RMAX)
KILL RMAX
QUIT
+9 QUIT
End DoDot:1
EFOG IF '$GET(HSFLAG)
Begin DoDot:1
+1 SET @TMP@(8,4)=PSTUFF
SET @TMP@(8,3)=PGRP
+2 IF $GET(OGONLY)
SET @TMP@(8,2)="og"
SET %=$$MRP^VENPCCU
IF $LENGTH(%)
SET @TMP@(8,3)=%
+3 FOR N=1:1
IF '$DATA(@TMP@(8,N))
QUIT
Begin DoDot:2
+4 IF N'=1
SET REC=REC_U
+5 IF $DATA(SPECHOLD(8,N))
SET REC=REC_SPECHOLD(8,N)
KILL SPECHOLD(8,N)
QUIT
+6 SET REC=REC_@TMP@(8,N)
+7 QUIT
End DoDot:2
+8 QUIT
End DoDot:1
+9 ; STRIP OFF BAD CHARACTERS
FOR %=10,13,31,34,39
IF REC[$CHAR(%)
SET REC=$TRANSLATE(REC,$CHAR(%),"")
+10 ; STRIP OFF BAD CHARACTERS
IF $DATA(REC1)
FOR %=10,13,31,34,39
IF REC1[$CHAR(%)
SET REC1=$TRANSLATE(REC1,$CHAR(%),"")
OPEN IF $EXTRACT(FILE)'="h"
KILL REC1
+1 SET POP=$$OPN^VENPCCP(PATH,FILE,"W","W REC W:$D(REC1) REC1")
+2 SET TOT=TOT+1
IF TOT>10
SET ERR="UNABLE TO SEND FILE TO THE PRINT QUEUE"
DO ERR(ERR)
QUIT
+3 IF POP
HANG 3
GOTO OPEN
+4 IF $EXTRACT(FILE)="g"
HANG 1
+5 SET %=$EXTRACT(FILE)
+6 IF $DATA(DEMODATA)
SET MSG="Test file '"_DEMODATA_".txt' sent to TEMP folder"
QUIT
+7 IF %="e"
IF '$GET(TRT)
IF $PIECE($GET(^VEN(7.95,+$GET(DEPTIEN),2)),U,11)
SET FILE="tt"_VISIT_".txt"
SET TRT=1
SET $PIECE(REC,U,3)=$$MRP^VENPCCU
GOTO OPEN
+8 SET MSG=$SELECT(%="e":"Encounter form",%="h":"Health summary",%="l":"Label",1:"OutGuide")_" sent to print queue"
+9 IF $GET(JOB)
SET MGBL=$NAME(^TMP("VEN MON"))
SET @MGBL@(JOB)=MSG
HANG 2
+10 IF '$TEST
WRITE !,MSG
+11 ; PATCHED BY GIS/OIT 03/28/06 ; PCC+ 2.5 PATCH 4 ; LABEL CYCLE
IF $GET(LPFLAG)
SET LOK=0
DO LABEL(LPFLAG)
KILL LPFLAG
IF LOK
GOTO OPEN
+12 IF '$GET(OGFLAG)!($EXTRACT(FILE)="g")
KILL OGFLAG
QUIT
PULL SET $PIECE(REC,U,2)="og"
+1 SET $PIECE(REC,U,1)=25
+2 SET FILE="g"_VISIT_".txt"
+3 SET $PIECE(REC,U,3)=$$MRP^VENPCCU
+4 SET PSTUFF=$PIECE(REC,U,4)
SET %=+PSTUFF
+5 IF %
SET %=$$VNUM(%,FILE,DEPTIEN)
+6 IF %
SET $PIECE(PSTUFF,";",1)=%
SET $PIECE(REC,U,4)=PSTUFF
+7 ; PRINT OUTGUIDE ; PATCHED BY GIS/OIT 4/15/08 ; PCC+ 2.6 PATCH 1 ; FIX OUTGUIDE PRINTING PROBLEM
GOTO OPEN
+8 ;
LABEL(LPFLAG) ; EP - CONFIG OUTPUT FOR LABEL PRINTER ; PCC+ 2.5 PATCH 4
+1 NEW LPG,LEF,TMN,HMN,X,Y,%
+2 SET LPG=$PIECE($GET(^VEN(7.4,+$GET(LPFLAG),0)),U)
IF '$LENGTH(LPG)
QUIT
+3 SET X=$GET(^VEN(7.41,+$PIECE($GET(LPFLAG),U,2),0))
IF '$LENGTH(X)
QUIT
+4 ; HEADER MNEMONIC
SET HMN=$PIECE(X,U,2)
IF '$LENGTH(HMN)
QUIT
+5 ; TEMPLATE MNEMONIC
SET TMN=$PIECE(X,U,3)
IF '$LENGTH(TMN)
QUIT
+6 SET $PIECE(REC,U,2)=TMN
+7 SET $PIECE(REC,U,1)=HMN
+8 SET FILE="l"_(VISIT+3000)_".txt"
SET LOK=1
+9 SET $PIECE(REC,U,3)=LPG
+10 SET PSTUFF=$PIECE(REC,U,4)
SET %=+PSTUFF
+11 ; FORCE THE PRINT SERVICE TO USE THE CORRECT PRINTER
IF %
SET $PIECE(PSTUFF,";",1)=(%+3000)
SET $PIECE(REC,U,4)=PSTUFF
+12 QUIT
+13 ;
V25 ; EP - FORMAT OUTPUT AND CREATE A DATA FILE FOR VER 2.5 PRINT SERVICE
+1 ; MAKE HEADER FILE
IF $GET(HSFLAG)
DO HS25
+2 ; MAKE DATA FILE AND OG FILE
IF '$GET(HSFLAG)
DO EFOG25
+3 QUIT
+4 ;
HS25 ; EP - BUILD HEALTH SUMMARY DATA FILE
+1 NEW HFIEN,POP,TOT,MMF,%,CNT
+2 SET @TMP@(2,"PRINTER")=PSTUFF
SET @TMP@(2,"GROUP")=PGRP
+3 SET HFIEN=$ORDER(^VEN(7.49,"B","hs",0))
IF 'HFIEN
QUIT
+4 SET MMF=""
SET TOT=0
HSOPN25 SET POP=$$OPN^VENPCCP(PATH,FILE,"W","D MMF25^VENPCC1(2)")
+1 SET TOT=TOT+1
+2 IF TOT>10
SET ERR="UNABLE TO SEND FILE TO THE PRINT QUEUE"
DO ERR(ERR)
QUIT
+3 ; KEEP CYCLING UNTIL YOU CAN OPEN THE FILE
IF POP
HANG 3
GOTO HSOPN25
+4 ; TELL USER WHAT IS HAPPENING
DO MSG25(FILE)
+5 QUIT
+6 ;
EFOG25 ; EP - BUILD EF OR OG DATA FILE FOR VER 2.5
+1 NEW HF,HFIEN,POP,TOT,MMF,%
+2 SET @TMP@(1,"printer")=PSTUFF
SET @TMP@(1,"group")=PGRP
+3 IF $GET(OGONLY)
SET @TMP@(1,"template")="og"
SET %=$$MRP^VENPCCU
IF $LENGTH(%)
SET @TMP@(1,"group")=%
+4 SET MMF=""
SET TOT=0
+5 IF $EXTRACT(FILE)="g"
SET HFIEN=$ORDER(^VEN(7.49,"B","ef",0))
IF 'HFIEN
QUIT
GOTO OPN25
+6 SET HF=$PIECE($GET(^VEN(7.41,+$GET(DEFEF),0)),U,2)
IF '$LENGTH(HF)
QUIT
+7 SET HFIEN=$ORDER(^VEN(7.49,"B",HF,0))
IF 'HFIEN
QUIT
OPN25 SET POP=$$OPN^VENPCCP(PATH,FILE,"W","D MMF25^VENPCC1(1)")
+1 SET TOT=TOT+1
+2 IF TOT>10
SET ERR="UNABLE TO SEND FILE TO THE PRINT QUEUE"
DO ERR(ERR)
QUIT
+3 ; KEEP CYCLING UNTIL YOU CAN OPEN THE FILE
IF POP
HANG 3
GOTO OPN25
+4 ; TELL USER WHAT IS HAPPENING
DO MSG25(FILE)
+5 ; CLEANUP AND QUIT
IF '$GET(OGFLAG)!($EXTRACT(FILE)="g")
KILL OGFLAG,OGONLY
KILL @TMP@(1)
QUIT
+6 SET @TMP@(1,"template")="og"
+7 SET %=$$MRP^VENPCCU
IF $LENGTH(%)
SET @TMP@(1,"group")=%
+8 SET FILE="g"_VISIT_".txt"
+9 SET PSTUFF=@TMP@(1,"printer")
SET %=+PSTUFF
+10 IF %
SET %=$$VNUM(%,FILE,DEPTIEN)
+11 IF %
SET $PIECE(PSTUFF,";",1)=%
SET @TMP@(1,"printer")=PSTUFF
+12 ; REPEAT THE PROCESS TO CREATE THE OUTGUIDE FILE
GOTO OPN25
+13 ;
MMF25(SS) ; EP - NEW WAY TO POPULATE THE DATA FILE
+1 NEW MMF,VAL,CNT,REC,%
+2 SET MMF=""
SET CNT=0
SET REC=""
M1 SET MMF=$ORDER(^VEN(7.49,HFIEN,1,"B",MMF))
+1 IF MMF=""
IF $LENGTH(REC)
WRITE !,REC
WRITE !
QUIT
+2 SET VAL=$GET(@TMP@(SS,MMF))
+3 IF $DATA(SPECHOLD(MMF))
SET VAL=SPECHOLD(MMF)
KILL SPECHOLD(MMF)
+4 ; STRIP OFF BAD CHARACTERS
IF $LENGTH(VAL)
FOR %=10,13,30,31,34,39
IF VAL[$CHAR(%)
SET VAL=$TRANSLATE(VAL,$CHAR(%),"")
+5 IF $LENGTH(REC)
SET REC=REC_U
+6 SET REC=REC_MMF_$CHAR(30)_VAL
+7 ; DIVIDE THE FILE INTO 500 CHARACTER CHUNKS
FOR
IF $LENGTH(REC)<501
QUIT
Begin DoDot:1
+8 IF CNT
WRITE !
+9 WRITE $EXTRACT(REC,1,500)
+10 SET REC=$EXTRACT(REC,501,999999)
+11 SET CNT=CNT+1
+12 QUIT
End DoDot:1
+13 GOTO M1
+14 ;
MSG25(FILE) ; EP - REPORT STATUS
+1 NEW %,MSG,MGBL
+2 SET %=$EXTRACT(FILE)
+3 SET MSG=$SELECT(%="e":"Encounter form",%="h":"Health summary",1:"OutGuide")_" sent to print queue"
+4 IF $GET(JOB)
SET MGBL=$NAME(^TMP("VEN MON"))
SET @MGBL@(JOB)=MSG
HANG 2
+5 IF '$TEST
WRITE !,MSG
+6 QUIT
+7 ;
+8 ; -----------------------
+9 ;
PG(DEPTIEN,FILE) ; EP-GIVEN A DATA FILE AND DEPT, RETURN THE PRINT GROUP ; USED BY PRINT DEAMON
+1 ; DIRECT ENTRY OF PRINT GROUP (LEGACY)
IF $GET(SPGRP)
QUIT $PIECE($GET(^VEN(7.4,SPGRP,0)),U)
+2 NEW TYPE,PG,%,X,Y
+3 SET TYPE=$EXTRACT(FILE)
+4 IF TYPE="g"
QUIT $$MRP^VENPCCU
+5 ; ENCOUNTER FROM
IF TYPE'="h"
Begin DoDot:1
+6 SET %=$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U,3)
SET X=""
+7 ; TRIAGE
IF %
SET X=$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U,8)
+8 ; STANDARD
IF X=""
SET X=$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U)
+9 IF X=""
SET X=0
+10 SET PG=$PIECE($GET(^VEN(7.4,X,0)),U)
+11 QUIT
End DoDot:1
QUIT PG
+12 ; HEALTH SUMMARY
SET %=$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U,9)
SET X=""
+13 ; CLINIC OVERRIDE FOR HS PG
IF %
SET X=%
+14 ; ALWAYS PRINT HS IN MR
IF 'X
IF $PIECE($GET(^VEN(7.5,CFIGIEN,0)),U,10)
QUIT $$MRP^VENPCCU
+15 ; USE EF PG FOR HS
IF 'X
SET X=$PIECE($GET(^VEN(7.95,DEPTIEN,2)),U)
+16 SET PG=$PIECE($GET(^VEN(7.4,X,0)),U)
+17 QUIT PG
+18 ;
VNUM(VISIT,FILE,DEPTIEN) ; EP - MODIFY VISIT NUMBER TO ASSURE DOCUMENT PRINTS ON THE CORRECT PRINTER
+1 IF $GET(VISIT)
IF $LENGTH(FILE)
IF $GET(DEPTIEN)
+2 IF '$TEST
QUIT $GET(VISIT)
+3 IF $EXTRACT(FILE)="e"
IF $PIECE($GET(^VEN(7.95,DEPTIEN,2)),U,3)
QUIT (VISIT+1500)
+4 IF $EXTRACT(FILE)="h"
IF '$DATA(HSONLY)
IF $$PG(DEPTIEN,"e")'=$$PG(DEPTIEN,"h")
QUIT (VISIT+1000)
+5 IF $EXTRACT(FILE)="g"
IF '$DATA(OGONLY)
IF $$PG(DEPTIEN,"e")'=$$PG(DEPTIEN,"g")
QUIT (VISIT+2000)
+6 QUIT VISIT
+7 ;