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

PXVDIS.m

Go to the documentation of this file.
PXVDIS ;BPFO/LMT - Imm Disclosure Report ;06/22/16  17:04
 ;;1.0;PCE PATIENT CARE ENCOUNTER;**216**;Aug 12, 1996;Build 11
 ;
 ;
MAIN ;
 N PXAG,PXEXIT,PXFROM,PXPROMPT,PXPT,PXTO
 ;
 S PXEXIT=$$PROMPTDT(.PXFROM,.PXTO)
 I PXEXIT Q
 ;
 ; - Selection of AGENCY to print on the Report
 S PXPROMPT(1)="AGENCIES"
 S PXPROMPT(2)="AGENCY"
 S PXEXIT=$$PROMPT(920.71,.PXPROMPT,.PXAG)
 I PXEXIT Q
 K PXPROMPT
 ;
 ; - Selection of PATIENTS to print on the Report
 S PXPROMPT(1)="PATIENTS"
 S PXPROMPT(2)="PATIENT"
 S PXEXIT=$$PROMPT(2,.PXPROMPT,.PXPT)
 I PXEXIT Q
 ;
 D ASKDVC
 ;
 Q
 ;
PROMPTDT(PXFROM,PXTO) ;
 ;
 N %DT,DTOUT,X,Y
 ;
 ; - Ask for FROM DATE
 S %DT(0)=-DT
 S %DT="AEP"
 S %DT("A")="     BEGIN DATE: "
 W !
 D ^%DT
 I Y<0!($D(DTOUT)) Q 1
 S PXFROM=$P(Y,".",1)
 ;
 ; - Ask for TO DATE
 K %DT,X,Y
 S %DT(0)=PXFROM
 S %DT="AEP"
 S %DT("B")="TODAY"
 S %DT("A")="     END DATE: "
 W !
 D ^%DT
 I Y<0!($D(DTOUT)) Q 1
 S PXTO=$P(Y,".",1)+.24
 ;
 Q 0
 ;
PROMPT(PXFILE,PXPROMPT,PXRESP) ;
 ;
 N DIC,DLAYGO,DTOUT,DUOUT,X,Y
 ;
 W !!,?5,"You may select a single or multiple "_PXPROMPT(1)_","
 W !,?5,"or enter ^ALL to select all "_PXPROMPT(1)_".",!
 ;
 S DIC=PXFILE
 S DIC(0)="QEAM"
 S DIC("A")="     Select "_PXPROMPT(2)_": "
 F  D ^DIC Q:Y<0  S PXRESP(+Y)="" S DIC("A")="     Another "_PXPROMPT(2)_": "
 I X="^ALL" S PXRESP="ALL" Q 0
 I $D(DUOUT)!($D(DTOUT)) Q 1
 I '$O(PXRESP(0)) Q 1
 Q 0
 ;
MAIN2 ;
 ;
 N PXI,PXINDEX
 ;
 D CLEAN
 ;
 S PXINDEX="ADA"
 I $G(PXPT)'="ALL" S PXINDEX="ADP"
 I PXINDEX="ADA" D
 . I $G(PXAG)="ALL" D FIND(PXINDEX,"",.PXFROM,.PXTO,.PXAG,.PXPT) Q
 . S PXI=0
 . F  S PXI=$O(PXAG(PXI)) Q:'PXI  D
 . . D FIND(PXINDEX,PXI,.PXFROM,.PXTO,.PXAG,.PXPT)
 I PXINDEX="ADP" D
 . I $G(PXPT)="ALL" D FIND(PXINDEX,"",.PXFROM,.PXTO,.PXAG,.PXPT) Q
 . S PXI=0
 . F  S PXI=$O(PXPT(PXI)) Q:'PXI  D
 . . D FIND(PXINDEX,PXI,.PXFROM,.PXTO,.PXAG,.PXPT)
 ;
 D PRINT
 D CLEAN
 Q
 ;
FIND(PXINDEX,PXSUB,PXFROM,PXTO,PXAG,PXPT) ;
 N PXGBL
 I PXSUB="" S PXGBL=$NA(^AUPNVIMM(PXINDEX,(PXFROM-.00001)))
 I PXSUB'="" S PXGBL=$NA(^AUPNVIMM(PXINDEX,(PXFROM-.00001),PXSUB))
 D FIND2(PXGBL,PXINDEX,.PXSUB,.PXFROM,.PXTO,.PXAG,.PXPT)
 I PXSUB="" S PXGBL=$NA(^AUPDVIMM(PXINDEX,(PXFROM-.00001)))
 I PXSUB'="" S PXGBL=$NA(^AUPDVIMM(PXINDEX,(PXFROM-.00001),PXSUB))
 D FIND2(PXGBL,PXINDEX,.PXSUB,.PXFROM,.PXTO,.PXAG,.PXPT)
 Q
 ;
FIND2(PXGBL,PXINDEX,PXSUB,PXFROM,PXTO,PXAG,PXPT) ;
 ;
 N DFN,PXADMINDT,PXAGENCY,PXDISCDT,PXDISIEN,PXGBLRT,PXIMMUN,PXNODE,PXPATNM,PXVIMMIEN,PXVISIT,VADM
 ;
 S PXGBLRT=$S(PXGBL["AUPNVIMM":"^AUPNVIMM",1:"^AUPDVIMM")
 F  S PXGBL=$Q(@PXGBL) Q:PXGBL=""  Q:($QS(PXGBL,1)'=PXINDEX)!($QS(PXGBL,2)>PXTO)!((PXSUB'="")&($QS(PXGBL,3)'=PXSUB))  D
 . S PXDISCDT=$QS(PXGBL,2)
 . S PXVIMMIEN=$QS(PXGBL,4)
 . S PXDISIEN=$QS(PXGBL,5)
 . S PXAGENCY=$P($G(@PXGBLRT@(PXVIMMIEN,820,PXDISIEN,0)),U,1)
 . I $G(PXAG)'="ALL",'$D(PXAG(PXAGENCY)) Q
 . S PXAGENCY=$E($P($G(^PXV(920.71,+PXAGENCY,0)),U,1),1,35)
 . ;
 . S PXNODE=$G(@PXGBLRT@(PXVIMMIEN,0))
 . S DFN=$P(PXNODE,U,2)
 . I $G(PXPT)'="ALL",'$D(PXPT(DFN)) Q
 . D KVA^VADPT
 . D DEM^VADPT
 . S PXPATNM=$E(VADM(1),1,24)
 . S PXPATNM=PXPATNM_"("_$E($P(VADM(2),U),6,9)_")"
 . D KVA^VADPT
 . S PXIMMUN=$P(PXNODE,U,1)
 . S PXADMINDT=$P($G(@PXGBLRT@(PXVIMMIEN,12)),U,1)
 . I PXADMINDT="" D
 . . S PXVISIT=$P(PXNODE,U,3)
 . . S PXADMINDT=$P($G(^AUPNVSIT(PXVISIT,0)),U,1)
 . S ^TMP("PXVDIS",$J,PXDISCDT,PXAGENCY,PXPATNM,PXVIMMIEN)=PXIMMUN_U_PXADMINDT
 ;
 Q
 ;
PRINT ;
 ;
 N PXAGENCY,PXDISCDT,PXEND,PXGBL,PXIMM,PXLINE,PXNODE,PXNOW,PXNUMLN,PXPAGE,PXPATNM,PXVIMM
 ;
 S PXEND=0
 S PXNOW=$$NOW^XLFDT
 S PXLINE=$$REPEAT^XLFSTR("-",131)
 S PXPAGE=0
 S PXNUMLN=$S($E(IOST,1,2)="C-":5,1:2)
 ;
 D PRINTHDR(PXNOW,.PXPAGE,PXLINE)
 ;
 S PXGBL=$NA(^TMP("PXVDIS",$J))
 F  S PXGBL=$Q(@PXGBL) Q:PXGBL=""!($G(PXEND))  Q:($QS(PXGBL,1)'="PXVDIS")!($QS(PXGBL,2)'=$J)  D
 . S PXDISCDT=$QS(PXGBL,3)
 . S PXAGENCY=$QS(PXGBL,4)
 . S PXPATNM=$QS(PXGBL,5)
 . S PXVIMM=$QS(PXGBL,6)
 . S PXNODE=$G(@PXGBL)
 . S PXIMM=$P(PXNODE,U,1)
 . W !,$$FMTE^XLFDT(PXDISCDT,"2M"),?16,PXAGENCY,?53,PXPATNM,?85,$E($P($G(^AUTTIMM(+PXIMM,0)),U,1),1,30)
 . W ?117,$$FMTE^XLFDT($P(PXNODE,U,2),"2M")
 . I $Y+PXNUMLN>IOSL D PRINTHDR(PXNOW,.PXPAGE,PXLINE)
 I '$G(PXEND) D PAUSE
 Q
 ;
PRINTHDR(PXNOW,PXPAGE,PXLINE) ;
 ;
 I PXPAGE>0 D PAUSE
 I $G(PXEND) Q
 W @IOF
 S PXPAGE=PXPAGE+1
 W ?13,"ACCOUNTING OF DISCLOSURES REPORT"
 W !,?13,"Report printed on: ",$$FMTE^XLFDT(PXNOW),?88,"Page: ",PXPAGE
 W !,?13,"Date Range: "_$$FMTE^XLFDT(PXFROM,2)_" - "_$$FMTE^XLFDT($P(PXTO,".",1),2)
 W ?48,"Agency(ies): "_$S($G(PXAG)="ALL":"ALL",$O(PXAG($O(PXAG(0)))):"Multiple",1:$E($P($G(^PXV(920.71,+$O(PXAG(0)),0)),U,1),1,25))
 W ?88,"Patient(s): "_$S($G(PXPT)="ALL":"ALL",$O(PXPT($O(PXPT(0)))):"Multiple",1:$$GET1^DIQ(2,+$O(PXPT(0)),.01))
 W !!,"Info Disclosed: Name, DOB, Sex, Race, Ethnicity, Mother Maiden Name, Place of Birth, Address, Phone Number, NOK, Immunization Data"
 W !,"Purpose: Record and track a complete immunization history for the purpose of public health care coordination"
 W !!,"DT DISCLOSED",?16,"DISCLOSED TO",?53,"PATIENT",?85,"IMMUNIZATION",?117,"ADMIN DT"
 W !,PXLINE
 Q
 ;
PAUSE ;
 N DIR,DIRUT,X,Y
 I $E(IOST,1,2)'="C-" Q
 W !
 S DIR(0)="E" D ^DIR
 I $D(DIRUT) S PXEND=1
 Q
 ;
CLEAN ;
 K ^TMP("PXVDIS",$J)
 Q
 ;
ASKDVC ;Prompts user for device of output (allows queuing)
 N PXVAR,ZTSK
 W !!!,"This report is designed for a 132 column format (compressed).",!
 S PXVAR("PXFROM")=""
 S PXVAR("PXTO")=""
 S PXVAR("PXAG(")=""
 S PXVAR("PXPT(")=""
 D EN^XUTMDEVQ("MAIN2^PXVDIS","Print Immunization Disclosure Report",.PXVAR,"QM",1)
 W:$D(ZTSK) !,"Report Queued to Print ("_ZTSK_").",!
 Q