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

PXRMCCHT.m

Go to the documentation of this file.
PXRMCCHT ;BP/WAT; Report patients with Previous Enroll health factor ;06/03/16  08:14
 ;;2.0;CLINICAL REMINDERS;**19**;Feb 04, 2005;Build 187
 ;
 ;^VADPT - 10061 ;^XLFDT - 10103 ;^XLFSTR - 10104 ;^%ZTLOAD - 10063  ;XUTMDEVQ - 1519
 ;^DIR - 10026 ;^AUTTHF - 3083
 ;
EN  ;start
 N BDT,POP,DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,PXRMTOT,PXRMSAVE
 K ^TMP("PXRMPATS",$J)
 S DIR(0)="D^2991231:DT"
 S DIR("A")="Start date"
 S DIR("A",1)="This report will try to find all patients that have the"
 S DIR("A",2)="HT ENROLLMENT-START DATE (PREV ENROLL) Health Factor."
 S DIR("A",3)="The default start date is 12/31/1999 and the report will"
 S DIR("A",4)="search forward from that date."
 S DIR("A",5)=""
 S DIR("B")="12/31/1999"
 W @IOF
 D ^DIR
 Q:$D(DIRUT)
 S BDT=$G(Y)
 N PXRMTASK S PXRMTASK=1
 S PXRMSAVE("*")=""
 D EN^XUTMDEVQ("PRINT^PXRMCCHT","HT Previous Enrollment HF Search",.PXRMSAVE,PXRMTASK)
 W:$G(PXRMTASK)>1 "Queued successfully, task #: "_$G(PXRMTASK)
 Q
 ;
PRINT ; output
 D FINDPAT
 N DONE,HFNAME,PATNAME,PXRMPAGE,HFCOUNT,RUNDATE
 S (HFNAME,PATNAME)="",PXRMPAGE=1,RUNDATE=$$HTE^XLFDT($H,"1P")
 W:$E(IOST,1,2)="C-" @IOF
 D HEADER(PXRMPAGE) S PXRMPAGE=PXRMPAGE+1
 F HFNAME="CCHT ENROLLMENT-START DATE (PREV ENROLL)","HT ENROLLMENT-START DATE (PREV ENROLL)"  D  Q:+$G(DONE)
 . W:HFNAME["CCHT" !,HFNAME
 . W:HFNAME'["CCHT" !!,HFNAME
 . I $D(^TMP("PXRMPATS",$J,HFNAME))'>10 W !,"  No data" Q
 . I $Y>(IOSL-3) D
 .. I $E(IOST,1,2)["C-" D
 ... N DIR S DIR(0)="E" D ^DIR
 ... I 'Y S DONE=1
 .. Q:$G(DONE)
 .. D HEADER(PXRMPAGE) S PXRMPAGE=PXRMPAGE+1
 . Q:$G(DONE)
 . F  S PATNAME=$O(^TMP("PXRMPATS",$J,HFNAME,PATNAME)) Q:PATNAME=""  D  Q:$G(DONE)
 .. I $Y>(IOSL-3) D
 ... I $E(IOST,1,2)["C-" D
 .... N DIR S DIR(0)="E" D ^DIR
 .... I 'Y S DONE=1
 ... Q:$G(DONE)
 ... D HEADER(PXRMPAGE) S PXRMPAGE=PXRMPAGE+1
 .. Q:$G(DONE)
 .. W !!,^TMP("PXRMPATS",$J,HFNAME,PATNAME,0)
 .. S HFCOUNT=0
 .. F  S HFCOUNT=$O(^TMP("PXRMPATS",$J,HFNAME,PATNAME,HFCOUNT)) Q:HFCOUNT=""!($G(DONE))  D
 ... I $Y>(IOSL-3) D
 .... I $E(IOST,1,2)["C-" D
 ..... N DIR S DIR(0)="E" D ^DIR
 ..... I 'Y S DONE=1
 .... Q:$G(DONE)
 .... D HEADER(PXRMPAGE) S PXRMPAGE=PXRMPAGE+1
 ... Q:$G(DONE)
 ... W !,^TMP("PXRMPATS",$J,HFNAME,PATNAME,HFCOUNT)
 Q:$G(DONE)
 W !!,PXRMTOT
 W !,$$CJ^XLFSTR("END OF REPORT",$S(+$G(IOM)>0:(IOM-1),1:79)," "),!
 Q
 ;
 W @IOF
 W !,$$REPEAT^XLFSTR("-",IOM-2),!
 W "Patients with (CC)HT ENROLLMENT-START DATE (PREV ENROLL) Health Factor"
 W !,"DATE RANGE - FROM: "_$$FMTE^XLFDT($G(BDT))_" TO: "_$$FMTE^XLFDT(DT)
 W !,$G(RUNDATE)
 W !,$$REPEAT^XLFSTR("-",IOM-2)
 W !,"  NAME AND LAST 4 SSN"_$$REPEAT^XLFSTR(" ",28)_"ENCOUNTER DATE"
 W !,"  PAGE: "_$G(PG)
 W !,$$REPEAT^XLFSTR("=",IOM-2),!
 Q
 ;
FINDPAT ;find patients with HT ENROLLMENT-START DATE (PREV ENROLL) health factor
 ; find health factor
 ;^PXRMINDX(FILE NUMBER,"IP",ITEM,DFN,DATE,DAS)
 ;TOTPAT = total number of patients found
 N TOTPAT,FOUND,HFCOUNT,NAMEL4 S (TOTPAT,ZTSTOP)=0
 N DFN,HFIEN,HFNAME,PTDFN,VISDATE,EXVISDT,VHFIEN,PTSSN,PTNAME S (HFIEN,PTDFN,VISDATE,EXVISDT)=""
 F HFNAME="CCHT ENROLLMENT-START DATE (PREV ENROLL)","HT ENROLLMENT-START DATE (PREV ENROLL)"  D
 .S HFIEN=$O(^AUTTHF("B",HFNAME,""))
 .Q:$G(HFIEN)=""
 .S ^TMP("PXRMPATS",$J,HFNAME)=""
 .F  S PTDFN=$O(^PXRMINDX(9000010.23,"IP",HFIEN,PTDFN)) Q:PTDFN'>""!($G(ZTSTOP)=1)  D
 ..I TOTPAT#50=0,($$S^%ZTLOAD) N X S ZTSTOP=1,X=$$S^%ZTLOAD("Received shutdown request") Q
 ..S DFN=PTDFN D DEM^VADPT S PTSSN=$P(VADM(2),U,2),PTNAME=VADM(1)
 ..S PTSSN=$P($G(PTSSN),"-",3),PTSSN="("_PTSSN_")"
 ..S NAMEL4="  "_PTNAME_" "_PTSSN
 ..I $L(NAMEL4)<40 S NAMEL4=NAMEL4_($$REPEAT^XLFSTR(" ",(40-$L(NAMEL4))))
 ..S ^TMP("PXRMPATS",$J,HFNAME,VADM(1),0)=NAMEL4
 ..S HFCOUNT=0
 ..F  S VISDATE=$O(^PXRMINDX(9000010.23,"IP",HFIEN,PTDFN,VISDATE)) Q:VISDATE=""  D
 ...S FOUND=0
 ...Q:VISDATE<BDT
 ...;need to capture each visit date this HF was recorded for this patient
 ...S:$G(VISDATE)="" EXVISDT="DATE MISSING"
 ...S EXVISDT=$$FMTE^XLFDT(VISDATE,"D")
 ...I $L(EXVISDT)<12 S EXVISDT=($$REPEAT^XLFSTR(" ",(12-$L(EXVISDT))))_EXVISDT
 ...S EXVISDT=$J(EXVISDT,21)
 ...I HFCOUNT=0 D  Q
 ....S ^TMP("PXRMPATS",$J,HFNAME,VADM(1),0)=^TMP("PXRMPATS",$J,HFNAME,VADM(1),0)_EXVISDT,FOUND=1,TOTPAT=TOTPAT+1,HFCOUNT=HFCOUNT+1
 ...I HFCOUNT>0 D  Q
 ....S EXVISDT=$J(EXVISDT,61)
 ....S ^TMP("PXRMPATS",$J,HFNAME,VADM(1),HFCOUNT)=EXVISDT,FOUND=1,HFCOUNT=HFCOUNT+1
 ..I FOUND=0 D
 ...K ^TMP("PXRMPATS",$J,HFNAME,VADM(1))
 S PXRMTOT="TOTAL PATIENTS FOUND:"_$$REPEAT^XLFSTR("-",28)_TOTPAT
 D KVA^VADPT
 Q