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

ECXDVSN.m

Go to the documentation of this file.
  1. ECXDVSN ;ALB/JAP - Division selection utility ; 8/13/07 1:11pm
  1. ;;3.0;DSS EXTRACTS;**8,105**;Dec 22, 1997;Build 70
  1. ADM(ECXDIV,ECXALL,ECXSTART,ECXEND,ECXERR) ;division information for ADM extract audit report
  1. ;selected inpatient divisions from medical center division file (#40.8)
  1. ; input
  1. ; ECXDIV = array of inpatient divisions selected (required)
  1. ; passed by reference array containing
  1. ; selected divisions;
  1. ; ECXALL = 1/0 (optional)
  1. ; 1==> user wants all inpatient divisions OR
  1. ; facility is non-divisional
  1. ; 0==> user wants to select some divisions
  1. ; if ECXALL not defined, then assume 1
  1. ; ECXSTART = start date of date range (optional)
  1. ; ECXEND = end date of date range (optional)
  1. ; ECXERR = passed by reference for error return (required)
  1. ; output
  1. ; ECXDIV = array of divisions selected from file #40.8;
  1. ; if ECXALL=1, then array contains all divisions
  1. ; if ECXALL=0, then array contains user-selected divisions
  1. ; ECXDIV(ien in file #40.8) = ien in file #4^name^station number^primary indicator^active indicator^dss id
  1. ; error CODE
  1. ; ECXERR = 1, if input problem occurs
  1. ; 0, otherwise
  1. N OUT,DIC,X,Y,NM,ECXD,ECXIEN,ECXDIEN,ECXACT,ECXNAME,ECXNUM
  1. S (OUT,ECXERR)=0
  1. ;if start date or end date missing, then both default to today
  1. I '$G(ECXSTART)!('$G(ECXEND)) S (ECXSTART,ECXEND)=DT
  1. S:'$D(ECXALL) ECXALL=1 S:ECXALL="" ECXALL=1
  1. I ECXALL=1 D
  1. .S NM="" F S NM=$O(^DG(40.8,"B",NM)) Q:NM="" S ECXIEN=$O(^(NM,"")) D
  1. ..Q:+$P(^DG(40.8,ECXIEN,0),U,3)=1
  1. ..K Y S DIC="^DG(40.8,",DIC(0)="NZ",X=ECXIEN D ^DIC
  1. ..Q:Y=-1
  1. ..S ECXNAME=$P(Y(0),U,1),ECXNUM=$P(Y(0),U,2),ECXDIEN=$P(Y(0),U,7)
  1. ..S ECXDIV(ECXIEN)=ECXDIEN_U_ECXNAME_U_ECXNUM
  1. ..D ACTDIV(ECXIEN,ECXSTART,ECXEND,.ECXD,.ECXACT)
  1. ..S ECXDIV(ECXIEN)=ECXDIV(ECXIEN)_U_ECXD_U_ECXACT
  1. ..I $D(^ECX(727.3,ECXIEN)) D
  1. ...S ECXDIV(ECXIEN)=ECXDIV(ECXIEN)_U_$P($G(^ECX(727.3,ECXIEN,0)),U,2)
  1. I ECXALL=0 F Q:OUT!ECXERR D
  1. .K Y S DIC="^DG(40.8,",DIC(0)="AEMQZ",DIC("S")="I $P(^(0),U,3)'=1"
  1. .D ^DIC I $G(DUOUT)!($G(DTOUT)) S OUT=1,ECXERR=1 Q
  1. .I Y=-1,X="" S OUT=1 Q
  1. .S ECXIEN=+Y,ECXNAME=$P(Y(0),U,1),ECXNUM=$P(Y(0),U,2),ECXDIEN=$P(Y(0),U,7)
  1. .S ECXDIV(ECXIEN)=ECXDIEN_U_ECXNAME_U_ECXNUM
  1. .D ACTDIV(ECXIEN,ECXSTART,ECXEND,.ECXD,.ECXACT)
  1. .S ECXDIV(ECXIEN)=ECXDIV(ECXIEN)_U_ECXD_U_ECXACT
  1. .I $D(^ECX(727.3,ECXIEN)) D
  1. ..S ECXDIV(ECXIEN)=ECXDIV(ECXIEN)_U_$P($G(^ECX(727.3,ECXIEN,0)),U,2)
  1. .I 'ECXACT W !!,?5,"Please note: Division "_ECXNUM_" was not active during",!,?5," selected date range.",!
  1. I ECXERR=1 K ECXDIV
  1. I '$D(ECXDIV) S ECXERR=1
  1. Q
  1. ACTDIV(ECXIEN,ECXSTART,ECXEND,ECXD,ECXACT) ;determine if division active at anytime during date range
  1. ;to be called by ADM^ECXDVSN
  1. ; input
  1. ; ECXIEN = ien in file #40.8; required
  1. ; ECXSTART = start of date range; FM format; required
  1. ; ECXEND = end of date range; FM format; required
  1. ; output
  1. ; ECXD = 1/0; passed by reference
  1. ; 1 indicates primary division
  1. ; ECXACT = 1/0; passed by reference
  1. ; returns 0, if division not active during date range;
  1. ; note: only start date and end date are checked; if division
  1. ; inactive on both dates, then division assumed inactive
  1. ; for entire date range
  1. ;assume division active; set ecxact=1
  1. S ECXACT=1
  1. ;check if division active on start date or end date;
  1. ;these dates are normally within the same month
  1. F ECXDATE=ECXSTART,ECXEND D
  1. .S DATE(ECXDATE)=$$SITE^VASITE(ECXDATE,ECXIEN)
  1. .S ECXD=0
  1. .I ECXIEN=$$PRIM^VASITE(ECXDATE) S ECXD=1
  1. ;if not active on start date and not active on end date, reset ecxact=0
  1. I DATE(ECXSTART)=-1,DATE(ECXEND)=-1 S ECXACT=0
  1. Q
  1. MOV(ECXDIV,ECXALL,ECXSTART,ECXEND,ECXERR) ;division information for MOV extract audit report
  1. ;selected divisions from medical center division file (#40.8)
  1. ; input
  1. ; (see ADM)
  1. ; output
  1. ; (see ADM)
  1. D ADM^ECXDVSN(.ECXDIV,ECXALL,ECXSTART,ECXEND,.ECXERR)
  1. Q
  1. PAS(ECXDIV,ECXALL,ECXERR) ;setup division/site information for PAS extract audit report
  1. ; input
  1. ; ECXDIV = passed by reference array variable
  1. ; ECXALL = 1
  1. ; output
  1. ; ECXDIV = data for default division/site;
  1. ; ECXDIV(1)=ien in file #4^name^station number
  1. ; where the INSTITUTION file pointer is obtained from file #728
  1. S ECXALL=1 D DEFAULT^ECXDVSN(.ECXDIV,ECXALL,.ECXERR)
  1. Q
  1. TRT(ECXDIV,ECXALL,ECXERR) ;setup division/site information for TRT extract audit report
  1. ; input
  1. ; ECXDIV = passed by reference array variable
  1. ; ECXALL = 1
  1. ; output
  1. ; ECXDIV = data for default division/site;
  1. ; ECXDIV(1)=ien in file #4^name^station number
  1. ; where the INSTITUTION file pointer is obtained from file #728
  1. S ECXALL=1 D DEFAULT^ECXDVSN(.ECXDIV,ECXALL,.ECXERR)
  1. Q
  1. DEFAULT(ECXDIV,ECXALL,ECXERR) ;default division/site information for audit report
  1. ; input
  1. ; ECXDIV = passed by reference array variable
  1. ; ECXALL = 1
  1. ; output
  1. ; ECXDIV = data for default division/site;
  1. ; ECXDIV(1)=ien in file #4^name^station number
  1. ; where the INSTITUTION file pointer is obtained from file #728
  1. N DIV,ECX
  1. S ECXERR=0
  1. S DIV=$P($G(^ECX(728,1,0)),U,1)
  1. I DIV="" S ECXERR=1 Q
  1. K ECX S DIC="^DIC(4,",DIQ(0)="I",DIQ="ECX",DA=DIV,DR=".01;99" D EN^DIQ1
  1. I $D(ECX) S ECXDIV(1)=DIV_U_ECX(4,DIV,.01,"I")_U_ECX(4,DIV,99,"I")
  1. I '$D(ECX) S ECXERR=1
  1. I '$D(ECXDIV) S ECXERR=1
  1. Q
  1. DEN(ECXDIV,ECXALL,ECXERR) ;setup division/site information for DEN extract audit report
  1. ; input
  1. ; ECXDIV = passed by reference array variable (required)
  1. ; ECXALL = 0/1 (optional)
  1. ; '0' indicates user to select dental division;
  1. ; '1' indicates 'all' dental divisions or only one division
  1. ; exists in file #225; default is '1'
  1. ; output
  1. ; ECXDIV = data for dental division/site;
  1. ; ECXDIV(ien in file #225)=ien in file #4^name^station number
  1. ; ECXERR = 0/1
  1. ; if input problem, then '1' returned
  1. N X,Y,DIC,DTOUT,DUOUT,DIRUT,OUT,ECXD,ECXIEN
  1. S:'$D(ECXALL) ECXALL=1 S:ECXALL="" ECXALL=1
  1. S ECXERR=0,ECXD=""
  1. ;if ecxall=1, then all dental divisions/sites
  1. I ECXALL=1 D
  1. .F S ECXD=$O(^DENT(225,"B",ECXD)) Q:ECXD="" S ECXIEN=$O(^(ECXD,"")) D
  1. ..S $P(ECXDIV(ECXIEN),U,3)=ECXD S DIC="^DIC(4,",DIC(0)="MX",X=ECXD D ^DIC
  1. ..S:+Y>0 ECXDIV(ECXIEN)=Y S:+Y=-1 ECXDIV(ECXIEN)=U
  1. ..S ECXDIV(ECXIEN)=ECXDIV(ECXIEN)_U_ECXD
  1. ;if ecxall=0, user selects some/all dental divisions/sites
  1. I ECXALL=0 S OUT=0 D
  1. .F Q:OUT!ECXERR D
  1. ..S DIC="^DENT(225,",DIC(0)="AEMQ" K X,Y D ^DIC
  1. ..I $G(DUOUT)!($G(DTOUT)) S OUT=1,ECXERR=1 Q
  1. ..I Y=-1,X="" S OUT=1 Q
  1. ..S ECXIEN=+Y,ECXD=$P(Y,U,2) K X,Y
  1. ..S DIC="^DIC(4,",DIC(0)="MX",X=ECXD D ^DIC
  1. ..S:+Y>0 ECXDIV(ECXIEN)=Y S:+Y=-1 ECXDIV(ECXIEN)=U
  1. ..S ECXDIV(ECXIEN)=ECXDIV(ECXIEN)_U_ECXD
  1. I ECXERR=1 K ECXDIV
  1. I '$D(ECXDIV) S ECXERR=1
  1. Q
  1. ECS(ECXDIV,ECXALL,ECXERR) ;setup division/location information for ECS extract audit report
  1. ; input
  1. ; ECXDIV = passed by reference array variable (required)
  1. ; ECXALL = 0/1 (optional)
  1. ; '0' indicates user to select EC location(s);
  1. ; '1' indicates 'all' locations or only one location
  1. ; exists in file #4 "LOC" index;
  1. ; default is '1'
  1. ; output
  1. ; ECXDIV = data for EC location;
  1. ; ECXDIV(ien in file #4)=ien in file #4^name^station number
  1. ; where the INSTITUTION file pointer is obtained from
  1. ; "LOC" index in file #4
  1. ; ECXERR = 0/1
  1. ; if input problem, then '1' returned
  1. ;
  1. N X,Y,I,DIC,DIR,DIRUT,DTOUT,DUOUT,NM,OUT,ECXD,ECXIEN,ECXLOC
  1. S:'$D(ECXALL) ECXALL=1 S:ECXALL="" ECXALL=1
  1. S ECXERR=0,ECXD="",I=0
  1. ;get all available ec locations in ecxloc array
  1. F S ECXD=$O(^DIC(4,"LOC",ECXD)) Q:ECXD="" S I=I+1,ECXIEN=$O(^(ECXD,"")),ECXLOC(I)=ECXD_U_ECXIEN_U_$P($G(^DIC(4,ECXIEN,99)),U,1)
  1. ;if ecxall=1, then all ec locations
  1. I ECXALL=1 S I="" D Q
  1. .F S I=$O(ECXLOC(I)) Q:I="" D
  1. ..S ECXIEN=$P(ECXLOC(I),U,2)
  1. ..S ECXDIV(ECXIEN)=ECXIEN_U_$P(ECXLOC(I),U,1)_U_$P(ECXLOC(I),U,3)
  1. I ECXALL=0 S OUT=0,I=0 D
  1. .W !!,"Event Capture Locations:",! S I=0,DIR(0)="SXO^"
  1. .;spaces are embedded in dir(0) to prevent user from selecting by alpha characters in name
  1. .F S I=$O(ECXLOC(I)) Q:I="" S NM=$P(ECXLOC(I),U,1) W !,?10,I_" ",NM S DIR(0)=DIR(0)_I_":"_"- "_NM_";"
  1. .W !
  1. .F Q:OUT!ECXERR D
  1. ..S DIR("A")="Select Event Capture Location",DIR("S")="I +Y=Y"
  1. ..D ^DIR
  1. ..I $G(DTOUT)!($G(DUOUT)) S ECXERR=1 Q
  1. ..I X="" D Q
  1. ...I '$D(ECXDIV) W !!,"No Location selected...exiting.",! S OUT=1 Q
  1. ...W !!,"You have selected the following Location(s):",!
  1. ...S I=0 F S I=$O(ECXDIV(I)) Q:I="" W !,?10,$P(ECXDIV(I),U,2)_" ("_$P(ECXDIV(I),U,3)_")"
  1. ...W ! K X,Y,DIR S DIR(0)="Y",DIR("A")="Is that ok",DIR("B")="YES" D ^DIR
  1. ...I $D(DIRUT) S ECXERR=1
  1. ...I Y=0 S ECXERR=1
  1. ...S OUT=1
  1. ..S ECXIEN=$P(ECXLOC(X),U,2)
  1. ..S ECXDIV(ECXIEN)=ECXIEN_U_$P(ECXLOC(X),U,1)_U_$P(ECXLOC(X),U,3)
  1. ;exit
  1. I ECXERR=1 K ECXDIV
  1. I '$D(ECXDIV) S ECXERR=1
  1. Q
  1. NUT() ; Set Divisions into screen array (prompt is one/many/all)
  1. ;Input : SCRNARR - Screen array full global reference
  1. ;Output : 1 = OK 0 = User abort/timeout
  1. ; @SCRNARR@("DIVISION") = User pick all divisions ?
  1. ; 1 = Yes (all) 0 = No
  1. ; @SCRNARR@("DIVISION",PtrDiv) = Division name
  1. ;Note : @SCRNARR@("DIVISION") is initialized (KILLed) on input
  1. ; : @SCRNARR@("DIVISION",PtrDiv) is only set when the user
  1. ; picked individual divisions (i.e. didn't pick all)
  1. ;
  1. ;Declare variables
  1. N VAUTD,Y,SCANARR
  1. ;Get division selection
  1. S DIC="^DIC(4,"
  1. S VAUTSTR="PATIENT DIVISION"
  1. S VAUTVB="SCANARR"
  1. S VAUTNI=2
  1. D FIRST^VAUTOMA
  1. I Y<0 Q 1
  1. M @SCRNARR@("DIVISION")=SCANARR
  1. Q 0