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

ECRDSSU2.m

Go to the documentation of this file.
ECRDSSU2 ;ALB/DAN - DSS Unit Workload Summary Report (CONT) ;10/31/12  12:09
 ;;2.0;EVENT CAPTURE;**119**;8 May 96;Build 12
 ;Routine added in patch 119 to support exporting report
EXPORT ;
 N CNT
 K ^TMP("ECRPT",$J) ; delete temporary storage global
 S CNT=1
 S ^TMP($J,"ECRPT",CNT)="LOCATION^DSS UNIT^CATEGORY^CPT CODE^PROCEDURE CODE^PROCEDURE NAME^PROCEDURE VOLUME^SYNONYM^CPT MOD 1^MOD 1 VOL^CPT MOD 2^MOD 2 VOL^CPT MOD 3^MOD 3 VOL"
 D GETINFO
 D STORE
 K ^TMP("ECRPT",$J)
 Q
 ;
GETINFO ;Use "ADT" x-ref of file 721 to get information for report
 ;
 N ECD,ECDFN,ECIEN,ECL,ECNT,I,J,ECREC,ECST
 N ECTC,ECTP,ECMOD,ECMODS,ECMODF,SEQ
 S ECNT=0
 F I=0:0 S I=$O(ECLOC(I)) Q:'I  S ECL=+$P(ECLOC(I),U) D
 . S ECDFN=0
 . F  S ECDFN=+$O(^ECH("ADT",ECL,ECDFN)) Q:'ECDFN  F J=0:0 S J=$O(ECDSSU(J)) Q:'J  S ECD=+$P(ECDSSU(J),U) D
 .. S ECIEN=0
 .. S ECST=ECSTDT
 .. F  S ECST=+$O(^ECH("ADT",ECL,ECDFN,ECD,ECST)) Q:'ECST!(ECST>ECENDDT)  F  S ECIEN=+$O(^ECH("ADT",ECL,ECDFN,ECD,ECST,ECIEN)) Q:'ECIEN  D
 ... S ECREC=$G(^ECH(ECIEN,0))
 ... I ECD=+$P(ECREC,"^",7) D CRETMP
 Q
 ;
CRETMP ;- Create ^TMP("ECRPT" array w/format:
 ;    ^TMP("ECRPT",$J,location,DSS Unit,category,count)=procedure^volume^
 ;     CPT modifiers
 ;
 S ECTC=$S(+$P(ECREC,"^",8)=0:-1,1:+$P(ECREC,"^",8)),ECTP=$P($G(ECREC),"^",9)
 S ECNT=ECNT+1,ECTP=$P(ECTP,";")_";"_$E($P(ECTP,";",2),1)
 S ECMODS="" I $O(^ECH(ECIEN,"MOD",0))'="" D
 . K ECMOD S ECMODF=$$MOD^ECUTL(ECIEN,"I",.ECMOD) I 'ECMODF Q
 . S SEQ="" F  S SEQ=$O(ECMOD(SEQ)) Q:SEQ=""  D
 . . S ECMODS=ECMODS_$S(ECMODS="":"",1:";")_SEQ
 S ^TMP("ECRPT",$J,+$P(ECREC,"^",4),+$P(ECREC,"^",7),ECTC,ECNT)=ECTP_"^"_+$P(ECREC,"^",10)_"^"_ECMODS
 Q
 ;
STORE ;Put data into ^TMP($J,"ECRPT")
 N ECCAT,ECNT,ECOCAT,ECDSS,ECLOCAT,ECPR,ECVOL,ECMOD,ECSYI,ECLOCNM,ECDSSNM,ECCNAM,ECPRCODE,ECPNAM,ECPRN
 N MOD1,VOL1,MOD2,VOL2,MOD3,VOL3
 S (ECNT,ECDSS,ECLOCAT)=0,(ECCAT,ECOCAT)=""
 I '$D(^TMP("ECRPT",$J)) Q
 F  S ECLOCAT=$O(^TMP("ECRPT",$J,ECLOCAT)) Q:'ECLOCAT  D
 . F  S ECDSS=$O(^TMP("ECRPT",$J,ECLOCAT,ECDSS)) Q:'ECDSS  D
 .. S ECOCAT=0
 .. D LOCNAM,DSSUNAM
 .. F  S ECCAT=$O(^TMP("ECRPT",$J,ECLOCAT,ECDSS,ECCAT)) Q:ECCAT=""  K ECTMP D
 ... F  S ECNT=$O(^TMP("ECRPT",$J,ECLOCAT,ECDSS,ECCAT,ECNT)) Q:'ECNT  D
 .... S (ECPR,ECVOL)=0
 .... S ECPR=$P($G(^TMP("ECRPT",$J,ECLOCAT,ECDSS,ECCAT,ECNT)),"^")
 .... S ECVOL=$P($G(^TMP("ECRPT",$J,ECLOCAT,ECDSS,ECCAT,ECNT)),"^",2)
 .... S ECMOD=$P($G(^TMP("ECRPT",$J,ECLOCAT,ECDSS,ECCAT,ECNT)),"^",3)
 .... S ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR)=$G(ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR))+ECVOL D:ECMOD'="" SETMOD Q
 ... S ECPR="" F  S ECPR=$O(ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR)) Q:ECPR=""  D
 .... S ECCNAM=$S($P($G(^EC(726,$S(ECCAT<1:0,1:+ECCAT),0)),"^")'="":$P($G(^EC(726,$S(ECCAT<1:0,1:+ECCAT),0)),"^"),1:"None")
 .... S ECPRN=$S($P(ECPR,";",2)="E":ECPR_"C(725,",1:ECPR_"CPT(")
 .... S ECSYI=+$O(^ECJ("AP",ECLOCAT,ECDSS,$S(ECCAT<1:0,1:+ECCAT),ECPRN,0)),ECSYN=$P($G(^ECJ(ECSYI,"PRO")),"^",2)
 .... S ECPI="",ECPRCODE=""
 .... S ECCPT=$S($P(ECPR,";",2)="I":+ECPR,1:$P($G(^EC(725,+ECPR,0)),"^",5))
 .... I ECCPT'="" S ECPI=$$CPT^ICPTCOD(ECCPT,$P(ECENDDT,".")),ECCPT=$P(ECPI,"^",2)
 .... S ECPNAM=$S($P(ECPR,";",2)="E":$G(^EC(725,+$P(ECPR,";"),0)),$P(ECPR,";",2)="I":$P(ECPI,"^",3),1:"") I $P(ECPR,";",2)="E" S ECPRCODE=$P(ECPNAM,U,2),ECPNAM=$P(ECPNAM,U)
 .... S CNT=CNT+1 S ^TMP($J,"ECRPT",CNT)=ECLOCNM_U_ECDSSNM_U_ECCNAM_U_ECCPT_U_ECPRCODE_U_ECPNAM_U_$G(ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR))_U_ECSYN
 .... D ORDMODS ;Get top 3 mods by volume
 .... S ^TMP($J,"ECRPT",CNT)=^TMP($J,"ECRPT",CNT)_U_MOD1_U_VOL1_U_MOD2_U_VOL2_U_MOD3_U_VOL3
 Q
 ;
SETMOD ;Set CPT modifiers in ECTMP array
 N MOD,I
 F I=1:1 S MOD=$P(ECMOD,";",I) Q:MOD=""  D
 . S ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR,MOD)=$G(ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR,MOD))+ECVOL
 Q
LOCNAM ;- Get location name
 ;
 N I
 F I=0:0 S I=$O(ECLOC(I)) Q:'I  I $P($G(ECLOC(I)),"^")=ECLOCAT S ECLOCNM=$P(ECLOC(I),"^",2)
 Q
 ;
DSSUNAM ;- Get DSS Unit name
 ;
 N I
 F I=0:0 S I=$O(ECDSSU(I)) Q:'I  I $P($G(ECDSSU(I)),"^")=ECDSS S ECDSSNM=$P(ECDSSU(I),"^",2)
 Q
 ;
ORDMODS ;Find first three mods by volume
 N MOD,ORD,VOL,NUM
 S (MOD1,VOL1,MOD2,VOL2,MOD3,VOL3)="",NUM=0
 S MOD="" F  S MOD=$O(ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR,MOD)) Q:'+MOD  S ORD(-ECTMP(ECLOCAT,ECDSS,ECCAT,ECPR,MOD),MOD)=""
 I $D(ORD) S VOL="" F  S VOL=$O(ORD(VOL)) Q:VOL=""!(NUM=3)  S MOD="" F  S MOD=$O(ORD(VOL,MOD)) Q:MOD=""!(NUM=3)   S NUM=NUM+1 S @("MOD"_NUM)=$$MODNM(MOD),@("VOL"_NUM)=-VOL
 Q
 ;
MODNM(IEN) ;Get modifier name
 N MOD,MODI,MODESC
 S MODI=$$MOD^ICPTMOD(IEN,"I",$P(ECENDDT,"."))
 S MOD=$P(MODI,U,2) I MOD="" Q MOD
 S MODESC=$S($P(MODI,U,3)'="":$P(MODI,U,3),1:"Unknown")
 Q MOD_" "_MODESC