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

ECCLIPRO.m

Go to the documentation of this file.
ECCLIPRO ;ALB/CMD - Event Capture Procedure by Clinic Report ;Nov 16, 2022@13:39:46
 ;;2.0;EVENT CAPTURE;**159**;8 May 96;Build 61
 ;
 ; Reference to ^TMP supported by SACC 2.3.2.5.1
 ; Reference to ^%DTC in ICR #10000
 ; Reference to ^XLFDT in ICR #10103
 ; Reference to GETS^DIQ in ICR #2056
 ; Reference to $$LJ^XLFSTR in ICR #10104
 ;
EN ;Main entry point for report
 N %H,ECRDT,Y
 S %H=$H D YX^%DTC S ECRDT=Y
 K ^TMP($J,"ECCLIPRO"),^TMP($J,"ECRPT")
 D PROCESS
 D PRINT K ^TMP($J,"ECCLIPRO")
 I ECPTYP="E" D  Q
 .S ^TMP($J,"ECRPT",1)="LOCATION^DSS UNIT(IEN #)^CLINIC^PATIENT^SSN^DATE OF PROCEDURE^PROCEDURE CODE^PROCEDURE NAME^VOLUME^PROVIDER NAME"
 .K ^TMP($J,"ECCLIPRO")
 Q
 ;
PROCESS  ;Loop through "AC1" xref of EVENT CAPTURE PATIENT (#721) file and find records to put on report
 N ECCLIN,ECPA,ECR,ECRL,ECREC,ECRN,ECSSN,ECLOCNM
 N ECUNIT,ECFILE,ECPRV,ECPRVN,ECDFN,ECDT,ECEDT,ECIEN,ECLOCF
 N NUNIT,JJ,ECRSNUM,ECPI,ECPROCNM
 S JJ="" F  S JJ=$O(ECDSSU(JJ)) Q:JJ=""  D
 .S NUNIT($P(ECDSSU(JJ),U))=$P(ECDSSU(JJ),U,2)
 S ECDT=ECSD-.0001,ECEDT=ECED+.9999
 F  S ECDT=$O(^ECH("AC1",ECLOC,ECDT)) Q:'ECDT  Q:ECDT>ECEDT  D
 .S ECIEN="" F  S ECIEN=$O(^ECH("AC1",ECLOC,ECDT,ECIEN)) Q:'ECIEN  D
 ..S ECREC=$G(^ECH(ECIEN,0))
 ..S ECCLIN=$P(ECREC,U,19),ECLOCF=$P(ECREC,U,4),ECDSSF=$P(ECREC,U,7)
 ..I ECLOCF'=ECLOC Q
 ..I '$D(NUNIT(ECDSSF)) Q
 ..I ECCLIN'=ECCLI Q
 ..D BLDTMP(ECIEN,ECSORT)
 Q
 ;
BLDTMP(IEN,SORT) ; Add record to the list
 N ECDSS,ECIENS,ECPRCDT,ECPROCDT,ECPROCN,ECUSER,ECDT,ECPAT,ECERR,ECPROC,ECPROV,ECSSN,ECVOL
 N ECREC,SRTKEY
 I +$G(IEN)>0 D
 .S ECIENS=IEN_","
 .S ECREC=""
 .D GETS^DIQ(721,ECIENS,"1;2;6;8;9;10","IE","ECREC","ECERR")
 .S ECDSS=+$G(ECREC(721,ECIENS,6,"I")) ;DSS unit
 .S ECPRCDT=+$G(ECREC(721,ECIENS,2,"I")) ;procedure date/time
 .S ECPROCDT=$$FMTE^XLFDT(ECPRCDT,"5DZ") ;Procedure date
 .S ECPAT=$E($G(ECREC(721,ECIENS,1,"E")),1,30) ;patient name
 .S ECSSN=$E($$GETSSN^ECRDSSA(IEN),1,10) ;ssn
 .S ECVOL=+$G(ECREC(721,ECIENS,9,"I")) ;Volume
 .S ECPROC=$G(ECREC(721,ECIENS,8,"I")) ;Procedure Code
 .S ECPROC=$E($$GETPROC^ECRDSSA($G(ECREC(721,ECIENS,8,"I"))),1,5) ;proc.code
 .S ECPROCN=$$GETPRNM^ECRDSSA($G(ECREC(721,ECIENS,8,"I")),ECPROCDT) ;Procedure Name
 .S ECPROCN=$E(ECPROCN,1,25)
 .S ECPROV=$E($$GETPROV^ECRDSSA(IEN),1,30) ;provider
 .S ECREC=ECPAT_U_ECSSN_U_$$FMTE^XLFDT(ECPRCDT,"2MZ")_U_ECPROC_U_ECPROCN_U_ECVOL_U_ECPROV
 .S SRTKEY=$S(SORT="P":ECPAT,1:ECPRCDT)
 .S ^TMP($J,"ECCLIPRO",ECLOC,ECDSS,SRTKEY,ECPROC,IEN)=ECREC
 Q
 ;
PRINT ;loop the temp global and format output
 N ECSRTBY,ECSKEY,ECREC,ECRDT,ECFDT,ECTDT,ECDAT,ECPRCDT,ECKEY,ECDSS,ECPDSS,ECPROC
 N CNT,PAGE,LOCNM,LIEN,PROC,PROCDT,CLIEN,CLINM,ECIEN
 S LIEN=ECLOC_","
 S CLIEN=ECCLI_","
 S ECRDT=$$FMTE^XLFDT($$NOW^XLFDT,"5DZ")
 S ECFDT=$$FMTE^XLFDT($P(ECSD+.0001,"."),"5DZ")
 S ECTDT=$$FMTE^XLFDT($P(ECED,"."),"5DZ")
 S ECSRTBY=$S(ECSORT="D":"Procedure Date",1:"Patient Name")
 S LOCNM=$$GET1^DIQ(4,LIEN,.01) ;Location Name
 S CLINM=$$GET1^DIQ(44,CLIEN,.01) ;Clinic Name
 U IO
 I '$D(^TMP($J,"ECCLIPRO")) D  Q
 .I ECPTYP'="E" D HDR W !!,?12,"No data to report for the date range selected.",!!
 D HDR
 S ECDSS="",ECPDSS="",CNT=1
 F  S ECDSS=$O(^TMP($J,"ECCLIPRO",ECLOC,ECDSS)) Q:ECDSS=""  D
 .I $Y>(IOSL-8) D HDR
 .I ECDSS'=ECPDSS D DSSHDR(ECDSS) S ECPDSS=ECDSS
 .S ECSKEY="" F  S ECSKEY=$O(^TMP($J,"ECCLIPRO",ECLOC,ECDSS,ECSKEY)) Q:ECSKEY=""  D
 ..S ECPROC="" F  S ECPROC=$O(^TMP($J,"ECCLIPRO",ECLOC,ECDSS,ECSKEY,ECPROC)) Q:ECPROC=""  D
 ...S ECIEN="" F  S ECIEN=$O(^TMP($J,"ECCLIPRO",ECLOC,ECDSS,ECSKEY,ECPROC,ECIEN)) Q:ECIEN=""  D
 ....S ECREC=^TMP($J,"ECCLIPRO",ECLOC,ECDSS,ECSKEY,ECPROC,ECIEN)
 ....I ECPTYP="E" S ^TMP($J,"ECRPT",CNT+1)=LOCNM_U_$$GETDSSN^ECRDSSA(ECDSS,.ECDSSU)_"(IEN #"_ECDSS_")"_U_CLINM_U_ECREC,CNT=CNT+1 Q  ;Exported fields
 ....W !,$P(ECREC,U),?32,$P(ECREC,U,2),?38,$TR($P(ECREC,U,3),":"),?53,ECPROC,?59,$P(ECREC,U,5),?88,$J($P(ECREC,U,6),4),?98,$P(ECREC,U,7)
 Q
 ;
HDR ; Print the header
 Q:ECPTYP="E"
 W @IOF W:$G(PAGE) !
 S PAGE=$G(PAGE)+1
 W !?30,"EVENT CAPTURE PROCEDURES BY CLINIC REPORT",?80,"Run Date: ",ECRDT,?122,"Page:",PAGE
 W !!,?35,"For Location: ",LOCNM
 W !,?35,"Date Range: ",ECFDT," - ",ECTDT
 W !,?35,"Clinic: ",CLINM
 W !,?35,"Sorted By: ",ECSRTBY
 W !!,"Patient",?32,"SSN",?38,"Procedure",?53,"Procedure",?86,"Procedure",?98,"Provider",!
 W ?38,"Date/Time",?53,"Code",?59,"Name",?88,"Volume",!
 W !,$$REPEAT^XLFSTR("-",132)
 Q
 ;
DSSHDR(ECDSS) ; Print DSS Line
 N DSSNM
 Q:ECPTYP="E"
 S DSSNM=$$GETDSSN^ECRDSSA(ECDSS,.ECDSSU)
 I $Y>(IOSL-8) D HDR
 D DSSHDR^ECRDSSA(ECDSS,DSSNM)
 W !
 Q