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

ECNTPCE.m

Go to the documentation of this file.
  1. ECNTPCE ;ALB/JAM-Event Capture Records failing transmission to PCE;Sep 24, 2020@14:55:55
  1. ;;2.0;EVENT CAPTURE;**61,72,119,152**;8 May 96;Build 19
  1. EN ; entry point
  1. K %DT S %DT="AEX",%DT("A")="Start with Date: " D ^%DT I Y<0 G END
  1. S ECSD=Y,%DT("A")="End with Date: " D ^%DT G:Y<0 END S ECED=Y
  1. I ECED<ECSD W !,"End date must be after start date",! G EN
  1. S ECDATE=$$FMTE^XLFDT(ECSD)_U_$$FMTE^XLFDT(ECED)
  1. S ECSD=ECSD-.0001,ECED=ECED+.9999
  1. K IOP,%ZIS,POP,IO("Q") S %ZIS("A")="Select Device: ",%ZIS="QM"
  1. D ^%ZIS G:POP END
  1. I $D(IO("Q")) K IO("Q") D G END
  1. .S (ZTSAVE("ECDFN"),ZTSAVE("ECDATE"),ZTSAVE("ECED"),ZTSAVE("ECSD"))=""
  1. .S ZTDESC="ECS RECORDS FAILING TRANSMISSION TO PCE REPORT",ZTRTN="START^ECNTPCE"
  1. .S ZTIO=ION D ^%ZTLOAD,HOME^%ZIS
  1. W !,?5,"Please be patient, this may take a few moments..."
  1. ;
  1. START ; entry when queued
  1. N ECOUT,X,Y,DIR,LINE,ECPG,ECRDT,%H,CNT ;119
  1. S ECOUT=0,ECPG=1
  1. S %H=$H D YX^%DTC S ECRDT=Y
  1. U IO
  1. I $G(ECPTYP)="E" S CNT=1,^TMP($J,"ECRPT",CNT)="DATE/TIME^LOCATION^DSS UNIT^CATEGORY^PATIENT^SSN^PROCEDURE CODE^PROCEDURE NAME^PROV 1^PROV 2^PROV 3^PROV 4^PROV 5^PROV 6^PROV 7^REASON 1^REASON 2^REASON 3" ;119
  1. I $G(ECPTYP)="E" D GET,^ECKILL Q ;119 get data to export and stop processing.
  1. D GET
  1. D END
  1. Q
  1. GET ; start processing or records
  1. N DATE,ECL,ECNT,ECFN,ECEC,ECPX,ECSTR,ECD
  1. N NLOC,NDSSUNT,JJ ;152
  1. K ^TMP("ECNTPCE",$J)
  1. ;***152 Begins
  1. ;Set locations and dss units into ien subscripted arrays
  1. S JJ="" F S JJ=$O(ECLOC(JJ)) Q:JJ="" D
  1. .S NLOC($P(ECLOC(JJ),U,1))=$P(ECLOC(JJ),U,2)
  1. S JJ="" F S JJ=$O(ECDSSU(JJ)) Q:JJ="" D
  1. .S NDSSUNT($P(ECDSSU(JJ),U,1))=$P(ECDSSU(JJ),U,2)
  1. ;***152 Ends
  1. S DATE=ECSD,ECNT=0
  1. F S DATE=$O(^ECH("AC",DATE)) Q:('DATE)!(DATE>ECED) D
  1. .S ECFN=0 F S ECFN=$O(^ECH("AC",DATE,ECFN)) Q:'ECFN D
  1. ..Q:'$D(^ECH(ECFN,"R")) S ECEC=$G(^ECH(ECFN,0)) Q:ECEC=""
  1. ..S ECL=$P(ECEC,U,4),ECD=$P(ECEC,U,7),ECPX=$P(ECEC,U,9)
  1. ..S ECDFN=$P(ECEC,U,2)
  1. ..I (ECL="")!(ECD="")!(ECPX="")!(ECDFN="") Q
  1. ..I '$D(NLOC(ECL))!('$D(NDSSUNT(ECD))) Q ;152 - Not on Location or DSS Units selected list
  1. ..S ECSTR=ECFN_U_$P(ECEC,U,8)_U_ECPX
  1. ..S ECNT=ECNT+1,^TMP("ECNTPCE",$J,DATE,ECL,ECD,ECDFN,ECNT)=ECSTR
  1. ..K ECPRV S ECPRV=$$GETPRV^ECPRVMUT(ECFN,.ECPRV) I 'ECPRV D K ECPRV
  1. ...M ^TMP("ECNTPCE",$J,DATE,ECL,ECD,ECDFN,ECNT,"PRV")=ECPRV
  1. I $G(ECPTYP)="E" D PRT Q ;119
  1. D HDR
  1. I '$O(^TMP("ECNTPCE",$J,0)) D Q
  1. .W !!,?10,"No Data found during the time selected."
  1. D PRT
  1. Q
  1. ;
  1. END K ECSD,ECED
  1. I $D(ECGUI) D ^ECKILL Q
  1. W !
  1. I $E(IOST,1,2)="C-",$G(ECOUT)=0 W !!,"Press <RET> to continue" R X:DTIME
  1. ;W @IOF
  1. D ^%ZISC D ^ECKILL S:$D(ZTQUEUED) ZTREQ="@"
  1. Q
  1. PAGE ; end of page
  1. I $E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR I 'Y S ECOUT=1 Q
  1. I $O(^TMP("ECNTPCE",$J,ECDTE,ECL,ECD,ECDFN,ECNT))'="" D HDR ;152 to prevent printing just a header on the last page
  1. Q
  1. HDR ; print header
  1. W @IOF
  1. W ECRDT,?70,"Page: ",ECPG,!
  1. W !,?17,"ECS RECORDS FAILING TRANSMISSION TO PCE REPORT",!,?24
  1. W "FROM "_$P(ECDATE,U)_" TO "_$P(ECDATE,U,2),!!
  1. W "DATE/TIME",?16,"PATIENT",?39,"SSN",?44,"PROVIDER(S)",?61,"REASONS"
  1. W !,"LOCATION",?16,"PROCEDURE",!,"DSS UNIT",?16,"CATEGORY",!
  1. F LINE=1:1:80 W "-"
  1. W !
  1. S ECPG=ECPG+1
  1. Q
  1. ;
  1. PRT N ECLN,ECDN,ECPAT,ECEC,ECPS,ECDFN,ECUN,ECUN1,ECUN2,ECDTE,ECDT,ECRS,ECDE
  1. N ECX,ECAT,ECSSN,DFN,VA,VADM,ECEPN,ECECPT ;119
  1. S ECDTE=0 F S ECDTE=$O(^TMP("ECNTPCE",$J,ECDTE)) Q:'ECDTE D Q:ECOUT
  1. .S ECDT=$$FMTE^XLFDT(ECDTE,2),ECL=0
  1. .F S ECL=$O(^TMP("ECNTPCE",$J,ECDTE,ECL)) Q:'ECL D Q:ECOUT
  1. ..S ECLN=$P($G(^DIC(4,ECL,0)),U),ECLN=$S(ECLN="":"UNKNOWN",1:ECLN),ECD=0
  1. ..F S ECD=$O(^TMP("ECNTPCE",$J,ECDTE,ECL,ECD)) Q:'ECD D Q:ECOUT
  1. ...S ECDN=$P($G(^ECD(ECD,0)),U),ECDN=$S(ECDN="":"UNKNOWN",1:ECDN)
  1. ...S ECDFN=0
  1. ...F S ECDFN=$O(^TMP("ECNTPCE",$J,ECDTE,ECL,ECD,ECDFN)) Q:'ECDFN D Q:ECOUT
  1. ....S DFN=ECDFN D DEM^VADPT
  1. ....S ECPAT=VADM(1),ECSSN=$P($P(VADM(2),U,2),"-",3),ECNT=0
  1. ....F S ECNT=$O(^TMP("ECNTPCE",$J,ECDTE,ECL,ECD,ECDFN,ECNT)) Q:'ECNT D PR2 Q:ECOUT
  1. Q
  1. ;
  1. PR2 S ECEC=$G(^TMP("ECNTPCE",$J,ECDTE,ECL,ECD,ECDFN,ECNT))
  1. S ECPS="",ECFN=$P(ECEC,U)
  1. D PROV
  1. S ECAT=$S($P(ECEC,U,2):$P($G(^EC(726,$P(ECEC,U,2),0)),U),1:"")
  1. I $P(ECEC,U,3)'="" S ECDE=+$P(ECEC,U,3) D
  1. .I $P(ECEC,U,3)[";EC" D Q
  1. ..S ECPS=$G(^EC(725,+ECDE,0)),ECEPN=$P(ECPS,U),ECECPT=$P(ECPS,U,2),ECPS=$P(ECPS,U,2)_" "_$P(ECPS,U) ;119
  1. .S ECPS=$$CPT^ICPTCOD(ECDE,ECDTE),ECEPN=$S(+ECPS:$P(ECPS,U,3),1:"CPT NAME UNKNOWN"),ECECPT=$P(ECPS,U,2) ;119
  1. .S ECPS=$S(+ECPS>0:$P(ECPS,U,2)_" "_$P(ECPS,U,3),1:"CPT NAME UNKNOWN")
  1. S ECRS=^ECH(ECFN,"R")
  1. I $G(ECPTYP)="E" D EXPORT K ECPRV Q ;119
  1. W ECDT,?16,$E(ECPAT,1,20),?39,ECSSN,?44,$E(ECUN1,1,16),?61,$E($P(ECRS,";"),1,19),!
  1. W $E(ECLN,1,15),?16,$E(ECPS,1,27),?44,$E(ECUN2,1,16)
  1. W ?61,$E($P(ECRS,";",2),1,19),!
  1. W $E(ECDN,1,15),?16,$E(ECAT,1,27),?44,$E(ECUN3,1,16)
  1. W ?61,$E($P(ECRS,";",3),1,198)
  1. S ECUN=0 F ECX=4:1 S ECUN=$O(ECPRV(ECUN)) Q:(ECUN="")&($P(ECRS,";",ECX)="") D I ECOUT Q
  1. .W !
  1. .I ($Y+6)>IOSL D PAGE I ECOUT Q
  1. .I ECUN'="" W ?44,$E($P(ECPRV(ECUN),"^",2),1,16) K ECPRV(ECUN)
  1. .W ?61,$E($P(ECRS,";",ECX),1,19)
  1. W !!
  1. I ($Y+6)>IOSL D PAGE I ECOUT Q
  1. Q
  1. PROV ;Set provider 1-3 in variables
  1. M ECPRV=^TMP("ECNTPCE",$J,ECDTE,ECL,ECD,ECDFN,ECNT,"PRV")
  1. S ECUN=0,ECUN1="UNKNOWN",(ECUN2,ECUN3)=""
  1. F I=1:1:3 S ECUN=$O(ECPRV(ECUN)) Q:'ECUN D
  1. .S @("ECUN"_I)=$P(ECPRV(ECUN),"^",2) K ECPRV(ECUN)
  1. Q
  1. ;
  1. EXPORT ;Section added in patch 119
  1. N J
  1. S CNT=CNT+1
  1. S ^TMP($J,"ECRPT",CNT)=ECDT_U_ECLN_U_ECDN_U_ECAT_U_ECPAT_U_ECSSN_U_ECECPT_U_ECEPN_U_ECUN1_U_ECUN2_U_ECUN3
  1. F J=4:1:7 S ^TMP($J,"ECRPT",CNT)=^TMP($J,"ECRPT",CNT)_U_$P($G(ECPRV(J)),U,2) ;Set providers 4 through 7
  1. F J=1:1:3 S ^TMP($J,"ECRPT",CNT)=^TMP($J,"ECRPT",CNT)_U_$P(ECRS,";",J) ;add up to 3 reasons
  1. Q