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

ECRECER.m

Go to the documentation of this file.
  1. ECRECER ;ALB/DAN-Event Capture Encounter Report ;Nov 04, 2020@22:42:04
  1. ;;2.0;EVENT CAPTURE;**112,122,126,139,145,152**;8 May 96;Build 19
  1. ;
  1. STRPT ;
  1. K ^TMP("ECRECER",$J),^TMP($J,"ECRPT")
  1. D GETREC
  1. I ECPTYP="E" D EXPORT Q
  1. U IO
  1. D PRINT
  1. Q
  1. ;
  1. GETREC ;Find records to put on report
  1. N ECLI,ECDFN,ECD,ECDT,ECIEN,ECPROV,ECPATN,ECSSN,ECVOL,ECARR,ECIO,CLNODE ;122,126
  1. N ECLINM ;152
  1. S ECLI=0 F S ECLI=$O(ECLOC1(ECLI)) Q:'+ECLI D
  1. .S ECDFN=0 K ^TMP("UNI",$J) ;126
  1. .F S ECDFN=+$O(^ECH("ADT",ECLI,ECDFN)) Q:'ECDFN D
  1. ..S ECD=0
  1. ..F S ECD=$O(ECDSSU(ECD)) Q:'ECD D
  1. ...S ECDT=ECSD-.1
  1. ...F S ECDT=+$O(^ECH("ADT",ECLI,ECDFN,ECD,ECDT)) Q:'ECDT!(ECDT>(ECED_.24)) D
  1. ....S ECIEN=0,ECVOL=0 ;145 Reset volume total
  1. ....F S ECIEN=+$O(^ECH("ADT",ECLI,ECDFN,ECD,ECDT,ECIEN)) Q:'ECIEN D
  1. .....I '+$G(^TMP("UNI",$J,ECDFN,ECDT,ECD)) S ^TMP("UNI",$J,ECDFN,ECDT,ECD)=ECIEN ;145 Store 1st IEN in this group
  1. .....S ECVOL=ECVOL+$$GET1^DIQ(721,ECIEN,9) ;145 add to total procedure volume
  1. ....S ECIEN=^TMP("UNI",$J,ECDFN,ECDT,ECD) ;145 Retrieve 1st record in group
  1. ....S ECPROV=$$GETPROV^ECRDSSA(ECIEN)
  1. ....K ECARR D GETS^DIQ(721,ECIEN,"1;26;29","IE","ECARR","ECERROR") ;122,145
  1. ....S ECIO=ECARR(721,ECIEN_",",29,"I")
  1. ....S ECPATN=ECARR(721,ECIEN_",",1,"E")_"~"_ECDFN
  1. ....S ECSSN=$$GETSSN^ECRDSSA(ECIEN)
  1. ....S CLNODE=$G(^ECX(728.44,+$G(ECARR(721,ECIEN_",",26,"I")),0)) ;122
  1. ....I ECSORT="C" S ECLINM=$S(ECARR(721,ECIEN_",",26,"E")'="":ECARR(721,ECIEN_",",26,"E"),1:"UNKNOWN") ;152 - Add Clinic to sort criteria
  1. ....I $G(ECSORT)="P" D
  1. .....S ^TMP("ECRECER",$J,ECLOC1(ECLI),ECPATN,ECPROV,ECIEN)=ECIO_U_ECDT_U_ECD_U_ECVOL_U_ECSSN_U_$G(ECARR(721,ECIEN_",",26,"E"))_U_$P(CLNODE,U,2)_U_$P(CLNODE,U,3)_U_$P($G(^ECX(728.441,+$P(CLNODE,U,8),0)),U)_U_$P(CLNODE,U,14) ;122,139
  1. ....I $G(ECSORT)="D" D
  1. .....S ^TMP("ECRECER",$J,ECLOC1(ECLI),ECPROV,ECPATN,ECIEN)=ECIO_U_ECDT_U_ECD_U_ECVOL_U_ECSSN_U_$G(ECARR(721,ECIEN_",",26,"E"))_U_$P(CLNODE,U,2)_U_$P(CLNODE,U,3)_U_$P($G(^ECX(728.441,+$P(CLNODE,U,8),0)),U)_U_$P(CLNODE,U,14) ;122,139
  1. ....I $G(ECSORT)="C" D ;152 - Add Clinic to sort criteria
  1. .....S ^TMP("ECRECER",$J,ECLOC1(ECLI),ECLINM,ECPROV,ECPATN,ECIEN)=ECIO_U_ECDT_U_ECD_U_ECVOL_U_ECSSN_U_$G(ECARR(721,ECIEN_",",26,"E"))_U_$P(CLNODE,U,2)_U_$P(CLNODE,U,3)_U_$P($G(^ECX(728.441,+$P(CLNODE,U,8),0)),U)_U_$P(CLNODE,U,14)
  1. Q
  1. ;
  1. EXPORT ;Put in delimited format for exporting
  1. N CNT,LOC,PATN,PROV,IEN,DATA,MCA ;139
  1. N CLINIC ;152
  1. Q:'$D(^TMP("ECRECER",$J))
  1. S CNT=1,^TMP($J,"ECRPT",CNT)="LOCATION^PATIENT^SSN^I/O^DATE/TIME^PRIMARY PROVIDER^DSS UNIT^TOTAL PROCEDURE VOLUME^CLINIC^STOP CODE^CREDIT STOP CODE^CHAR4 CODE^MCA LABOR CODE" ;122,139,145,152 - Update orivider column header
  1. I ECSORT="P" D
  1. .S LOC="" F S LOC=$O(^TMP("ECRECER",$J,LOC)) Q:LOC="" D
  1. ..S PATN="" F S PATN=$O(^TMP("ECRECER",$J,LOC,PATN)) Q:PATN="" D
  1. ...S PROV="" F S PROV=$O(^TMP("ECRECER",$J,LOC,PATN,PROV)) Q:PROV="" D
  1. ....S IEN=0 F S IEN=$O(^TMP("ECRECER",$J,LOC,PATN,PROV,IEN)) Q:'+IEN D
  1. .....S DATA=^(IEN) ;Naked reference to above line
  1. .....S MCA=$$GET1^DIQ(728.442,$P(DATA,U,10),.01) ;139
  1. .....S CNT=CNT+1 ;139
  1. .....S ^TMP($J,"ECRPT",CNT)=LOC_U_$P(PATN,"~")_U_$P(DATA,U,5)_U_$P(DATA,U,1)_U_$$FMTE^XLFDT($P(DATA,U,2),2)_U_PROV_U_ECDSSU($P(DATA,U,3))_U_$P(DATA,U,4)_U_$P(DATA,U,6)_U_$P(DATA,U,7)_U_$P(DATA,U,8)_U_$P(DATA,U,9)_U_MCA ;122,139
  1. I ECSORT="D" D
  1. .S LOC="" F S LOC=$O(^TMP("ECRECER",$J,LOC)) Q:LOC="" D
  1. ..S PROV="" F S PROV=$O(^TMP("ECRECER",$J,LOC,PROV)) Q:PROV="" D
  1. ...S PATN="" F S PATN=$O(^TMP("ECRECER",$J,LOC,PROV,PATN)) Q:PATN="" D
  1. ....S IEN=0 F S IEN=$O(^TMP("ECRECER",$J,LOC,PROV,PATN,IEN)) Q:'+IEN D
  1. .....S DATA=^(IEN) ;Naked reference to above line
  1. .....S MCA=$$GET1^DIQ(728.442,$P(DATA,U,10),.01) ;139
  1. .....S CNT=CNT+1 ;139
  1. .....S ^TMP($J,"ECRPT",CNT)=LOC_U_$P(PATN,"~")_U_$P(DATA,U,5)_U_$P(DATA,U,1)_U_$$FMTE^XLFDT($P(DATA,U,2),2)_U_PROV_U_ECDSSU($P(DATA,U,3))_U_$P(DATA,U,4)_U_$P(DATA,U,6)_U_$P(DATA,U,7)_U_$P(DATA,U,8)_U_$P(DATA,U,9)_U_MCA ;122,139
  1. I ECSORT="C" D ;152
  1. .S LOC="" F S LOC=$O(^TMP("ECRECER",$J,LOC)) Q:LOC="" D
  1. ..S CLINIC="" F S CLINIC=$O(^TMP("ECRECER",$J,LOC,CLINIC)) Q:CLINIC="" D
  1. ...S PROV="" F S PROV=$O(^TMP("ECRECER",$J,LOC,CLINIC,PROV)) Q:PROV="" D
  1. ....S PATN="" F S PATN=$O(^TMP("ECRECER",$J,LOC,CLINIC,PROV,PATN)) Q:PATN="" D
  1. .....S IEN="" F S IEN=$O(^TMP("ECRECER",$J,LOC,CLINIC,PROV,PATN,IEN)) Q:IEN="" D
  1. ......S DATA=^(IEN) ;Naked reference to above line
  1. ......S MCA=$$GET1^DIQ(728.442,$P(DATA,U,10),.01)
  1. ......S CNT=CNT+1
  1. ......S ^TMP($J,"ECRPT",CNT)=LOC_U_$P(PATN,"~")_U_$P(DATA,U,5)_U_$P(DATA,U,1)_U_$$FMTE^XLFDT($P(DATA,U,2),2)_U_PROV_U_ECDSSU($P(DATA,U,3))_U_$P(DATA,U,4)_U_$P(DATA,U,6)_U_$P(DATA,U,7)_U_$P(DATA,U,8)_U_$P(DATA,U,9)_U_MCA
  1. Q
  1. ;
  1. PRINT ;Display results
  1. N LOC,PATN,PROV,IEN,DATA,PAGE,PTOT,PROTOT
  1. N CLIN,CLINTOT ;152
  1. I '$D(^TMP("ECRECER",$J)) S LOC=$S($G(ECL0)="ALL":ECL0,1:ECLOC1(ECL0)) D HDR W !,"No Data found" Q ;152 - Added location name or "ALL" on line 2 when report has no data
  1. S PAGE=0
  1. I ECSORT="P" D
  1. .S LOC="" F S LOC=$O(^TMP("ECRECER",$J,LOC)) Q:LOC="" D HDR D
  1. ..S PATN="" F S PATN=$O(^TMP("ECRECER",$J,LOC,PATN)) Q:PATN="" K PTOT,PROTOT D D SUB
  1. ...S PROV="" F S PROV=$O(^TMP("ECRECER",$J,LOC,PATN,PROV)) Q:PROV="" D
  1. ....S IEN=0 F S IEN=$O(^TMP("ECRECER",$J,LOC,PATN,PROV,IEN)) Q:'+IEN D
  1. .....S DATA=^(IEN) ;Naked reference to above line
  1. .....D WRTLN ;152 - Added this tag to write out the report lines
  1. .....S PTOT=+$G(PTOT)+1,PROTOT(PROV)=+$G(PROTOT(PROV))+1
  1. I ECSORT="D" D
  1. .S LOC="" F S LOC=$O(^TMP("ECRECER",$J,LOC)) Q:LOC="" D HDR D
  1. ..S PROV="" F S PROV=$O(^TMP("ECRECER",$J,LOC,PROV)) Q:PROV="" K PROTOT,PTOT D D SUB
  1. ...S PATN="" F S PATN=$O(^TMP("ECRECER",$J,LOC,PROV,PATN)) Q:PATN="" D
  1. ....S IEN=0 F S IEN=$O(^TMP("ECRECER",$J,LOC,PROV,PATN,IEN)) Q:'+IEN D
  1. .....S DATA=^(IEN) ;Naked reference to above line
  1. .....D WRTLN ;152 - Added this tag to write out the report lines
  1. .....S PTOT(PATN)=+$G(PTOT(PATN))+1,PROTOT=+$G(PROTOT)+1
  1. I ECSORT="C" D ;152 - sorted by Clinic, track the total by patient, by provider and by clinic
  1. .S LOC="" F S LOC=$O(^TMP("ECRECER",$J,LOC)) Q:LOC="" D HDR D
  1. ..S CLIN="" F S CLIN=$O(^TMP("ECRECER",$J,LOC,CLIN)) Q:CLIN="" K PTOT,PROTOT,CLINTOT D D SUB
  1. ...S PROV="" F S PROV=$O(^TMP("ECRECER",$J,LOC,CLIN,PROV)) Q:PROV="" D
  1. ....S PATN="" F S PATN=$O(^TMP("ECRECER",$J,LOC,CLIN,PROV,PATN)) Q:PATN="" D
  1. .....S IEN=0 F S IEN=$O(^TMP("ECRECER",$J,LOC,CLIN,PROV,PATN,IEN)) Q:IEN="" S DATA=^(IEN) D
  1. .....D WRTLN
  1. .....S PTOT(PATN)=$G(PTOT(PATN))+1,PROTOT(PROV)=$G(PROTOT(PROV))+1,CLINTOT=$G(CLINTOT)+1
  1. Q
  1. WRTLN ;Write report line
  1. W !,$P(PATN,"~"),?32,$P(DATA,U,5),?38,$P(DATA,U,1),?43,$$FMTE^XLFDT($P(DATA,U,2),2),?59,PROV,?91,ECDSSU($P(DATA,U,3)),?123,$P(DATA,U,4)
  1. W !,?4,$P(DATA,U,6),?36,$P(DATA,U,7),?47,$P(DATA,U,8),?60,$P(DATA,U,9),?68,$$GET1^DIQ(728.442,$P(DATA,U,10),.01) ;122,139
  1. Q
  1. HDR ;Print Header
  1. N SORT
  1. W @IOF
  1. S PAGE=+$G(PAGE)+1
  1. W ?51,"Event Capture Encounters Report",?123,"Page: ",PAGE
  1. W !,?(132-(12+$L(LOC))\2),$S(LOC="ALL":"For ALL Locations",1:"For Location "_LOC) ;152
  1. W !,?47,"From ",$$FMTE^XLFDT(ECSD)," through ",$$FMTE^XLFDT(ECED)
  1. S SORT=$S(ECSORT="P":"Patient Name",ECSORT="D":"Provider",1:"Clinic") ;152 Added Clinic
  1. W !,?(132-(9+$L(SORT))\2),"Sorted by ",SORT,!
  1. W !,"Patient",?32,"SSN",?38,"I/O",?43,"Date/Time",?59," Primary Provider",?91,"DSS Unit",?123,"Total" ;145,152 - Update provider header
  1. W !,?4,"Clinic",?36,"Stop Code",?47,"Credit Stop",?60,"CHAR4",?68,"MCA Labor Code",?123,"Proc Vol" ;122,139,145
  1. W !,$$REPEAT^XLFSTR("-",132)
  1. Q
  1. SUB ;Print totals
  1. N ARR,DISP
  1. I ECSORT="P" D
  1. .W !
  1. .S ARR="" F S ARR=$O(PROTOT(ARR)) Q:ARR="" S DISP="Encounter subtotal for provider "_ARR W !,$J(DISP,128),$J(PROTOT(ARR),4) ;145
  1. .W !,?128,"===="
  1. .S DISP="Encounter total for patient "_$P(PATN,"~") W !,$J(DISP,128),$J(PTOT,4),! ;145
  1. I ECSORT="D" D
  1. .W !
  1. .S ARR="" F S ARR=$O(PTOT(ARR)) Q:ARR="" S DISP="Encounter subtotal for patient "_$P(ARR,"~") W !,$J(DISP,128),$J(PTOT(ARR),4) ;145
  1. .W !,?128,"===="
  1. .S DISP="Encounter total for provider "_PROV W !,$J(DISP,128),$J(PROTOT,4),! ;145
  1. I ECSORT="C" D ;152
  1. .W !
  1. .S ARR="" F S ARR=$O(PTOT(ARR)) Q:ARR="" S DISP="Encounter subtotal for patient "_$P(ARR,"~") W !,$J(DISP,128),$J(PTOT(ARR),4)
  1. .W !,?128,"===="
  1. .F S ARR=$O(PROTOT(ARR)) Q:ARR="" S DISP="Encounter subtotal for provider "_ARR W !,$J(DISP,128),$J(PROTOT(ARR),4)
  1. .W !,?128,"===="
  1. .S DISP="Encounter total for Clinic "_CLIN W !,$J(DISP,128),$J(CLINTOT,4),!
  1. Q