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

VENPCC1.m

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