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

AGSSLPRT.m

Go to the documentation of this file.
AGSSLPRT ; IHS/ASDS/EFG - PRINT INDIVIDUAL PATIENT LETTER ;   
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 ;
S ;needs DFN
 ;returns AGSST=1 if address incomplete
 ;prints context from the REG Parameters file IEN=site from
 ;^AUTTSITE
 ;pull letter text
 U IO
 I '$D(AGSS(9009061)) S DIC="^AGFAC(",(AGSITE,DA)=$P(^AUTTSITE(1,0),U),DR="200",DIQ="AGSS" D EN^DIQ1
 Q:'$G(DFN)
 ;pull patient information
 S AGIN=$G(^AGFAC(AGSITE,2)),AGBOT=IOSL-$P(AGIN,":",2),AGIN=$P(AGIN,":")
 K DR,AGSS(2),AGSS(900001.41)
 S DA=DFN,DIC="^DPT(",DR=".01;.09;.111;.112;.113;.114;.115;.116;.351",DIQ="AGSS(",DIQ(0)="N" D EN^DIQ1
 K DR S DA=DFN,DIC="^AUPNPAT(",DR="4101",DIQ="AGSS(",DIQ(0)="N",DR(9000001.41)=".02;.04;.05",DA(9000001.41)=AGSITE D EN^DIQ1
 K AGSST
 I ($G(AGSS(2,DFN,.111))]""),($G(AGSS(2,DFN,.115))]""),($G(AGSS(2,DFN,.116))]"") ;test address
 E  S AGSST="A" ;mark if bad address
 I ($G(AGSS(2,DFN,.351))]"") S AGSST=$G(AGSST)_"D" ;mark if date of death
 I ($G(AGSS(9000001.41,AGSITE,.04))]"") S AGSST=$G(AGSST)_"R" ;mark if record disposition is Invalid
 I ($G(AGSS(9000001.41,AGSITE,.05))]"") S AGSST=$G(AGSST)_"S" ;mark if patient status is invalid
 I $G(AGSST)]"" K AGSS(2,DFN),AGSS(9000001.41,AGSITE) Q  ;exit
 W:$Y>1 @IOF
 F I=1:1:5 W !
 W ?5,AGSS(2,DFN,.01),!!,?5,$G(AGSS(9000001.41,AGSITE,.02)),!!
 ;print body of letter
T S DIWL=5,DIWR=75,DIWF="W" K ^TMP($J,"W")
 F AGI=1:1 Q:'$D(AGSS(9009061,AGSITE,200,AGI))  S X=AGSS(9009061,AGSITE,200,AGI) D ^DIWP D  Q:($G(DIROUT)!$G(DUOUT)!$G(DTOUT)!$G(DIRUT))
 .Q:($Y<(IOSL-4))!($G(DUOUT)!$G(DFOUT))  I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR W @IOF
 Q:($G(DIROUT)!$G(DUOUT)!$G(DTOUT)!$G(DIRUT))
 D ^DIWW
 S AGSSN=$G(AGSS(2,DFN,.09)) I $L(AGSSN)=9 S AGSSN=$E(AGSSN,1,3)_"-"_$E(AGSSN,4,5)_"-"_$E(AGSSN,6,9)
 S X="Social Security Number that is matched   "_AGSSN D ^DIWP,^DIWW K AGSSN
 F AGI=$Y:1:AGBOT W !
A S DIWF="WNI"_AGIN K ^TMP($J,"W")
 S X=AGSS(2,DFN,.01) D ^DIWP
 F AGI=.111:.001:.114 I $D(AGSS(2,DFN,AGI)) S X=AGSS(2,DFN,AGI) D ^DIWP
 S X=$G(AGSS(2,DFN,.115))_"    "_$G(AGSS(2,DFN,.116)) D ^DIWP
 D ^DIWW
 I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR W @IOF
 K AGSS(2,DFN),DIWF,DIWL,DIWR,DIQ
 Q
INDIV ;EP select and print individual Patient SSN letters
 K AGSS
IND F  S DIC="^AUPNPAT(",DIC(0)="AEQ" D ^DIC Q:Y'>0  S AGSS("INDV",+Y)=""
 S XBRP="INDPRT^AGSSLPRT",XBRX="EX2^AGSSLPRT",XBNS="AGSS" D ^XBDBQUE
 Q
INDPRT ;
 S DFN=0 F  S DFN=$O(AGSS("INDV",DFN)) Q:DFN'>0  D ^AGSSLPRT I $G(AGSST)]"" S AGSS("INDV",DFN)=AGSST K AGSST
 U IO W:$Y>1 @IOF
 D RPTPRT
 U IO W:$Y>1 @IOF
 Q
EX2 ;EP
 K AGSS(2),AGSS(900001.41)
 K AGSS,AGBOT,AGI,AGIN,AGSITE,AGSSPG,AGSSC,AGSSCL,AGSSIEN,AGSSNM,AGSHRN
 Q
RPTPRT ;print summary report
 ;uses AGSS("INDV",DFN)
 S AGSSPG("PG")=1,AGSSPG("HDR")="Report of 'SSN ADDED' Patient Leters "  D AGSSHDR ;print header
 S AGSSC=0,AGSSIEN=0 F  S AGSSIEN=$O(AGSS("INDV",AGSSIEN)) Q:'AGSSIEN  S AGSSNM=$P(^DPT(AGSSIEN,0),U) D
 .S AGSSCL=5+35*(AGSSC#2),AGSHRN=$P($G(^AUPNPAT(AGSSIEN,41,AGSITE,0)),"^",2) W ?AGSSCL,$J(AGSHRN,6)," ",AGSSNM W:(AGSS("INDV",AGSSIEN)]"") " *"_AGSS("INDV",AGSSIEN) I AGSSCL>10 W ! D AGSSPG
 .S AGSSC=AGSSC+1
 W !!,"TOTAL = ",AGSSC H 3
 I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR W @IOF
 Q
END ;
 K AGSS,AGBOT,AGI,AGIN,AGSITE,AGSSPG,AGSSC,AGSSCL,AGSSIEN,AGSSNM,AGSHRN
 Q
AGSSPG ;EP PAGE CONTROLLER
 ;this utility uses variables AGSSPG("HDR"),AGSSPG("DT"),AGSSPG("LINE"),AGSSPG("PG") ; kill variables by D EAGSSPG
 Q:($Y<(IOSL-4))!($G(DUOUT)!$G(DFOUT))  S:'$D(AGSSPG("PG")) AGSSPG("PG")=0 S AGSSPG("PG")=AGSSPG("PG")+1 I $E(IOST)="C" K DIR S DIR(0)="E" D ^DIR Q:($G(DIROUT)!$G(DUOUT)!$G(DTOUT)!$G(DIRUT))
AGSSHDR ;EP write page header
 W:$Y @IOF W ! Q:'$D(AGSSPG("HDR"))  S:'$D(AGSSPG("LINE")) $P(AGSSPG("LINE"),"-",IOM-2)="" S:'$D(AGSSPG("PG")) AGSSPG("PG")=1 I '$D(AGSSPG("DT")) S %H=$H D YX^%DTC S AGSSPG("DT")=Y
 U IO W ?(IOM-40-$L(AGSSPG("HDR"))/2),AGSSPG("HDR"),?(IOM-40),AGSSPG("DT"),?(IOM-10),"PAGE: ",AGSSPG("PG"),!,AGSSPG("LINE")
AGSSHD ;EP Write column header / message
 W !!,"   * DENOTES INCOMPLETE ADDRESS -- LETTER NOT PRINTED",!!
 Q:($G(DIROUT)!$G(DUOUT)!$G(DTOUT)!$G(DIRUT))
EAGSSPG K AGSSPG("LINE"),AGSSPG("PG"),AGSSPG("HDR"),AGSSPG("DT") Q