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

AGRHI1.m

Go to the documentation of this file.
AGRHI1 ; IHS/ASDS/EFG - RESTRICTED HEALTH REPORT ;   
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 ;
 ;THIS ROUTINE WILL CREATE A REPORT BASED ON THE RESTIRCTED
 ;HEALTH INFORMATION FILE
 ;
 Q
EN ;EP
 K AG("F1")
 D BEGDT
 Q:$D(DTOUT)!$D(DUOUT)
 S AGQ("RC")="PROCESS^AGRHI1"
 S AGQ("RP")="PRINT^AGRHI1"
 S AGQ("RX")="EXIT^AGRHI1"
 S AGQ("NS")="AG"
 D ^AGDBQUE
 Q
BEGDT ;PROMPT FOR BEGINNING DATE OF ENTRY
 S AG("PAGE")=0
 K DIR,X,Y
 S DIR(0)="D"
 S DIR("A")="Please enter a beginning Date Of Entry. "
 D ^DIR
 Q:$D(DTOUT)!$D(DUOUT)
 S X=Y S BDT=+Y D DD^%DT S AG("BEGDT")=Y
ENDDT ;PROMPT FOR ENDING DATE OF ENTRY
 K DIR,X,Y
 S DIR(0)="D"
 S DIR("A")="Please enter an ending Date Of Entry. "
 D ^DIR
 Q:$D(DTOUT)!$D(DUOUT)
 S X=Y S EDT=+Y D DD^%DT S AG("ENDDT")=Y
 Q
HDR ;PRINT THE PAGE HEADER
 W @IOF
 S AG("PAGE")=AG("PAGE")+1
 W !,?19,"*** RESTRICTED HEALTH INFORMATION REPORT ***"
 W ?70,"Page ",AG("PAGE")
 S AG("RHIDT")=$$NOW^XLFDT
 S AG("DSPDAT")=$E(AG("RHIDT"),4,5)_"/"_$E(AG("RHIDT"),6,7)_"/"_($E(AG("RHIDT"),1,3)+1700)_"  "_$E(AG("RHIDT"),9,10)_":"_$E(AG("RHIDT"),11,12)
 S AG("DSPDAT")="RUN DATE/TIME : "_AG("DSPDAT")
 W !,?(80-$L(AG("DSPDAT"))/2),AG("DSPDAT")
 W !!,"BEGINNING ENTRY DATE: ",AG("BEGDT")
 W !,"ENDING ENTRY DATE:    ",AG("ENDDT")
 W !!,"PERSON",?18,"DATE OF"
 W !,"ENTERING",?19,"ENTRY",?30,"MR#",?38,"STATUS",?46,"REQUEST INFO"
 W !,"--------",?18,"-----",?30,"---",?38,"------",?46,"------------",!
 Q
PROCESS ;PROCESS LOOP FOR REPORT RECORDS
 ;DO SCREENING LOGIC - BUILD XTMP GLOBAL
 S ENTDAT=0
 F  S ENTDAT=$O(^AUPNRHI("G",ENTDAT)) Q:'+ENTDAT  D
 . Q:$P(ENTDAT,".",1)<BDT!($P(ENTDAT,".",1)>EDT)
 . S RHISTAT=""
 . F  S RHISTAT=$O(^AUPNRHI("G",ENTDAT,RHISTAT)) Q:RHISTAT=""  D
 .. S RHIREC=0
 .. F  S RHIREC=$O(^AUPNRHI("G",ENTDAT,RHISTAT,RHIREC)) Q:'+RHIREC  D
 ... S RECORD=$G(^AUPNRHI(RHIREC,0))
 ... S DFN=$P(RECORD,U)
 ... S MR=$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2)
 ... S RHI=$P(RECORD,U,2)
 ... S STREC=$S(RHISTAT="A":2,RHISTAT="P":1,RHISTAT="N":3,RHISTAT="R":4,RHISTAT="E":5)
 ... S USER=$S(STREC=1:$P($G(^AUPNRHI(RHIREC,STREC)),U,2),STREC=5:$P($G(^AUPNRHI(RHIREC,STREC)),U),1:$P($G(^AUPNRHI(RHIREC,STREC)),U,3))
 ... S ^XTMP("AGRHI",$J,ENTDAT,USER)=MR_U_RHISTAT_U_RHI
 K ENTDAT,RHIREC,RECORD,DFN,MR,RHISTAT,RHI,USER,STREC,BDT,EDT
 Q
PRINT ;DO HEADER AND DETAIL PRINTING HERE
 D HDR
 S (ENTDAT,USER,CNT)=0,RHIREC=""
 F  S ENTDAT=$O(^XTMP("AGRHI",$J,ENTDAT)) Q:'ENTDAT  D  Q:$G(AG("F1"))
 . F  S USER=$O(^XTMP("AGRHI",$J,ENTDAT,USER)) Q:'USER  D  Q:$G(AG("F1"))
 .. S RHIREC=$G(^XTMP("AGRHI",$J,ENTDAT,USER))
 .. S USERNAM=$P($G(^VA(200,USER,0)),U)
 .. S EDATE=$E(ENTDAT,4,5)_"/"_$E(ENTDAT,6,7)_"/"_($E(ENTDAT,1,3)+1700)
 .. S MR=$P(RHIREC,U)
 .. S STATUS=$P(RHIREC,U,2)
 .. S RHI=$P(RHIREC,U,3)
 .. I $Y>(IOSL-5) D HD Q:$G(AG("F1"))
 .. W !,USERNAM,?18,EDATE,?30,$$RJ^XLFSTR(MR,6),?40,STATUS
 .. S CNT=CNT+1
 .. S AG("Y")=$L(RHI)
 .. F  S AG("K")=$E(RHI,1,34) Q:$L(AG("K"))=0  S RHI=$E(RHI,35,AG("Y")) W ?46,AG("K"),!
 W !!,CNT," Records found from ",AG("BEGDT")," TO ",AG("ENDDT")
 Q
HD ;
 I '$D(IO("Q")),$E(IOST)="C",'$D(IO("S")) D
 . F  W ! Q:$Y+3>IOSL
 . K DIR S DIR(0)="E" D ^DIR K DIR
 I $D(DTOUT)!$D(DUOUT)!$D(DIROUT) S AG("F1")=1
 D HDR
 Q
EXIT ;
 K ^XTMP("AGRHI",$J)
 Q