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

ECXECMDI.m

Go to the documentation of this file.
ECXECMDI ;ALB/NCD - Event Capture Pre-Extract Missing DSS Identifier Report ;Apr 28, 2022@21:50:31
 ;;3.0;DSS EXTRACTS;**184**;Dec 22, 1997;Build 124
 ;
 ; Reference to ^ECD in ICR #1561
 ; Reference to ^ICPT in ICR #5408
 ; Reference to ^EC(725) in ICR #1874
 ; Reference to ^ECH in ICR #1873
 ; Reference to ^SC in ICR #10040
 ; Reference to ^DIC(40.7) in ICR #557
 ;
EN ; entry point
 N ECXPORT,ECSD,ECED,COUNT,CNT,ECXERR,QFLG,DIR,DTOUT,DUOUT,ZTSK,ZTQUEUED,DIC,%,X,Y,DATE
 W !!,"This report prints a list of records that are missing the DSS Identifier"
 W !,"that would be generated by the Event Capture Extract (ECS), so that corrective"
 W !,"action can be taken."
 W !,"The running of this report has no effect on the actual extracts and "
 W !,"can be run as needed.",!
 W !,"Enter the date range for which you would like to scan the Event Capture records."
 D GETDATE Q:QFLG
 S ECXPORT=$$EXPORT^ECXUTL1 Q:ECXPORT=-1  I $G(ECXPORT) D  Q
 .K ^TMP($J,"ECXPORT")
 .S ^TMP($J,"ECXPORT",0)="SSN^FACILITY^DSS UNIT^DSS UNIT IEN^DATE/TIME^PROCEDURE CODE^PROVIDER^CLINIC^CLINIC IEN^DSS IDENTIFIER",CNT=1
 .D START,PRINT
 .D EXPDISP^ECXUTL1
 .K ^TMP($J,"ECXPORT"),^TMP("ECNOSSID",$J)
 S ECXDESC="Event Capture Pre-Extract Missing DSS Identifier Report"
 S ECXSAVE("EC*")=""
 W !!,"This report is formatted for 132-column line width."
 W !!,"Enter 'Q' to queue report to TaskManager, then select printer."
 D EN^XUTMDEVQ("PROCESS^ECXECMDI",ECXDESC,.ECXSAVE,"",1)
 I $G(POP) W !!,"No device selected...exiting.",! Q
 I IO'=IO(0) D ^%ZISC
 D HOME^%ZIS
 I $D(ZTSK) W !!,"Queued as Task #"_ZTSK_"."
 Q
 ;
START ; Find EC records in the date range
 N ECLL,X,Y,ECDA,ECD,COUNT,COUNT
 S ECLL=0
 S ECED=ECED+.3,(ECDA,COUNT)=0
 K ^TMP("ECNOSSID",$J)
 F  S ECLL=$O(^ECH("AC1",ECLL)) Q:'ECLL  S ECD=ECSD-.1 D
 . F  S ECD=$O(^ECH("AC1",ECLL,ECD)) Q:(ECD>ECED)!('ECD)  D
 .. F  S ECDA=$O(^ECH("AC1",ECLL,ECD,ECDA)) Q:'ECDA  D GETREC
 Q
 ;
GETREC ;get data for report
 N ECXSSN,ECXPDIV,ECXPROV,ECXSSID,ECXCLIN,ECXDU,ECXUNIT,ECXPRCN,ECCH,ECFILE,ECXSSID,ECXCLINM,ECXASIH
 N ECDU,ECUPCE,ECUSTOP,ECAC1,ECAC2,ECAC1S,ECAC2S
 S ECCH=^ECH(ECDA,0)
 S ECL=$P(ECCH,U,4),ECXDFN=$P(ECCH,U,2)
 S ECXPDIV=$$RADDIV^ECXDEPT(ECL)  ;Get production division from file 4
 S ECDT=$P(ECCH,U,3),ECXDU=$P(ECCH,U,7),ECP=$P(ECCH,U,9)
 S ECXCLIN=$P(ECCH,U,19)
 Q:(ECP']"")
 S ECDU=$G(^ECD(ECXDU,0))
 S ECUPCE=$P(ECDU,U,14),ECUSTOP=$P(ECDU,U,10)
 Q:('$$PATDEM^ECXUTL2(ECXDFN,ECDT,"1;","13"))
 S ECFILE=$P(ECP,";",2),ECFILE=$S($E(ECFILE)="I":81,$E(ECFILE)="E":725,1:"UNKNOWN")
 S ECXDATE=$$FMTE^XLFDT(ECDT,5)
 I $G(ECXASIH) S ECXA="A"
 K ECXPRV S X=$$GETPPRV^ECPRVMUT(ECDA,.ECXPRV),ECXPROV=$E($P(ECXPRV,U,2),1,30)
 I ECXPROV]"" D
 .S N1=$$TITLE^XLFSTR($P(ECXPROV,",")),N2=$$TITLE^XLFSTR($P(ECXPROV,",",2))
 .S ECXPROV=(N1_","_N2)
 I ECFILE="UNKNOWN" S ECPN="UNKNOWN"
 S ECXPRCN=$S(ECFILE=81:$$GET1^DIQ(ECFILE,+ECP,.01),1:$$GET1^DIQ(ECFILE,+ECP,1))
 S COUNT=COUNT+1
 S ECXCLINM=$S(ECXCLIN'="":$$GET1^DIQ(44,ECXCLIN,.01),1:"")
 S (ECAC1,ECAC2,ECAC1S,ECAC2S)="000"
 I ECUPCE="A"!(ECUPCE="OOS")!(ECUPCE="O"&(ECXA="O")) D
 . I ECXCLIN'="" D
 .. S ECAC1=$$GET1^DIQ(44,ECXCLIN,8,"I"),ECAC2=$$GET1^DIQ(44,ECXCLIN,2503,"I")
 .. I ECAC2="" S ECAC2S="000"
 .. I ECAC1="" S (ECAC1S,ECAC2S)="000" Q
 .. S ECAC1S=$$GET1^DIQ(40.7,+ECAC1,1)
 .. S ECAC2S=$$GET1^DIQ(40.7,+ECAC2,1)
 .. S ECAC1S=$$RJ^XLFSTR(ECAC1S,3,0),ECAC2S=$$RJ^XLFSTR(ECAC2S,3,0)
 . I ECXCLIN="" S (ECAC1S,ECAC2S)="000"
 I ECUPCE=""!(ECUPCE="N")!(ECUPCE="O"&(ECXA="I")) D
 . S ECAC1S=$$RJ^XLFSTR($$GET1^DIQ(40.7,+ECUSTOP,1,"I"),3,0)
 . S ECAC2S=$$RJ^XLFSTR($$GET1^DIQ(40.7,+$P(ECDU,U,13),1,"I"),3,0)
 S ECDSS=ECAC1S_ECAC2S
 I "^18^23^24^41^65^94^108^"[("^"_ECXTS_"^") S ECDSS=$$TSMAP^ECXUTL4(ECXTS)
 Q:ECDSS'="000000"
 ;SSN^FACILTY^DSS UNIT IEN^DATE/TIME^PROCEDURE^PROVIDER^CLINIC IEN^CLINIC NAME^DSS ID 
 S ^TMP("ECNOSSID",$J,ECDT,COUNT)=ECXSSN_U_ECXPDIV_U_ECXDU_U_ECXDATE_U_ECXPRCN_U_ECXPROV_U_ECXCLIN_U_ECXCLINM_U_ECDSS
 Q
 ;
PRINT ; Process the TMP file and print the report
 N PG,QFLG,LN,COUNT,REC,DATE,X,Y
 N ECXSSN,ECXPDIV,ECXDATE,ECXDSSU,ECXUNIT,ECP,ECXPROV,ECXPRCN,ECXPROV,ECXCLIN,ECXCLINM,ECXSSID
 U IO
 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
 S (PG,QFLG,COUNT)=0,$P(LN,"-",130)=""
 I '$G(ECXPORT) D HEADER Q:QFLG
 S DATE=0
 F  S DATE=$O(^TMP("ECNOSSID",$J,DATE)) Q:DATE=""  D  Q:QFLG
 .F  S COUNT=$O(^TMP("ECNOSSID",$J,DATE,COUNT)) Q:COUNT=""  D
 .. S REC=^TMP("ECNOSSID",$J,DATE,COUNT)
 .. S ECXSSN=$P(REC,U),ECXPDIV=$P(REC,U,2),ECXDSSU=$P(REC,U,3)
 .. S ECXDATE=$P(REC,U,4),ECXPRCN=$P(REC,U,5),ECXPROV=$P(REC,U,6)
 .. S ECXCLIN=$P(REC,U,7),ECXCLINM=$P(REC,U,8),ECXSSID=$P(REC,U,9)
 .. I $G(ECXPORT) S ^TMP($J,"ECXPORT",CNT)=ECXSSN_U_ECXPDIV_U_$P($G(^ECD(ECXDSSU,0)),U)_U_ECXDSSU_U_ECXDATE_U_ECXPRCN_U_ECXPROV_U_ECXCLINM_U_ECXCLIN_U_ECXSSID,CNT=CNT+1 Q
 .. W !,?1,ECXSSN,?12,ECXPDIV,?25,ECXDSSU,?42,ECXDATE,?69,ECXPRCN,?83,ECXPROV,?105,ECXCLIN,?122,ECXSSID
 .. I $Y+4>IOSL D HEADER Q:QFLG
 I $G(ECXPORT) Q 
 Q:QFLG
 I COUNT=0 W !!,?8,"No Event Capture records with missing DSS Identifier to report for the date range.",!!
 D SS
 Q
 ;
PROCESS ; entry point for queued report
 N QFLG
 S ZTREQ="@"
 S ECXERR=0 D START Q:ECXERR
 S QFLG=0 D PRINT
 K ^TMP("ECNOSSID",$J) D ^ECXKILL
 Q
 ;
 D:PG SS Q:QFLG
 Q:QFLG
 W:$Y!($E(IOST)="C") @IOF S PG=PG+1
 W !,ECXDESC,?103,"Page: "_PG
 W !,"Start Date: ",ECSTART,?92,"Report Run Date: "_ECRUN
 W !,"  End Date: ",ECEND
 W !!,?1,"SSN",?12,"FACILITY",?25,"DSS UNIT IEN",?45,"DATE/TIME",?68,"PROCEDURE",?83,"PROVIDER",?105,"CLINIC IEN",?122,"DSS ID"
 W !,LN,!
 Q
 ;
SS ;SCROLL STOPS
 N JJ,SS
 I $E(IOST)="C" S SS=21-$Y F JJ=1:1:SS W !
 I $E(IOST)="C",PG>0 S DIR(0)="E" W ! D ^DIR K DIR I 'Y S QFLG=1 Q
 Q
 ;
GETDATE ;Get starting and ending date for sort
 N DONE,Y
 S QFLG=0
 D NOW^%DTC S DATE=X,Y=$E(%,1,12) D DD^%DT S ECRUN=$P(Y,"@") K %DT
 S DONE=0 F  S (ECED,ECSD)="" D  Q:QFLG!DONE
 .K %DT S %DT="AEX",%DT("A")="Starting with Date: ",%DT(0)=-DATE D ^%DT
 .I Y<0 S QFLG=1 Q
 .S ECSD=Y,ECSD1=ECSD-.1
 .D DD^%DT S ECSTART=Y
 .K %DT S %DT="AEX",%DT("A")="Ending with Date: ",%DT(0)=-DATE D ^%DT
 .I Y<0 S QFLG=1 Q
 .I Y<ECSD D  Q
 ..W !!,"The ending date cannot be earlier than the starting date."
 ..W !,"Please try again.",!!
 .I $E(Y,1,5)'=$E(ECSD,1,5) D  Q
 ..W !!,"Beginning and ending dates must be in the same month and year"
 ..W !,"Please try again.",!!
 .S ECED=Y
 .D DD^%DT S ECEND=Y
 .S DONE=1
 Q
 ;