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

DVBCAMI2.m

Go to the documentation of this file.
DVBCAMI2 ;ALB/GTS-557/THM-HOSPITAL AMIS 290 ; 7/1/91  9:48 AM
 ;;2.7;AMIE;**149,184**;Apr 10, 1995;Build 10
 ;Per VHA Directive 2004-038, this routine should not be modified.
 ;
 ;** Version Changes
 ;   2.7 - GTS/Coded to adjust 35 day clock calc  (Enhc 13)
 ;
DAY30 ;exam completion
 N DVBADTS,DVBAPPTS,DVBACNT,DVBADTM,DVBAPT,DVBANDE,X,X1,X2
 K ^TMP("DVBC",$J),^TMP($J,"SDAMA301")
 ;DES Type exams required to be completed in 45 days, all others 30
 S DVBADTS=$S(((";IDES;")[(";"_DVBAPREXM_";")):45,1:30)
 ;setup call to scheduling API (date inclusive)
 S DVBAPPTS(1)=DTRPT_";"_EDATE,DVBAPPTS(4)=PNAM,DVBAPPTS(3)="R;I"
 S DVBAPPTS("SORT")="P",DVBAPPTS("FLDS")="10"
 S DVBACNT=$$SDAPI^SDAMA301(.DVBAPPTS)
 I (DVBACNT'>0) K ^TMP($J,"SDAMA301") Q
 S DVBADTM=""
 F  S DVBADTM=$O(^TMP($J,"SDAMA301",PNAM,DVBADTM)) Q:('+DVBADTM)  D
 .S DVBAPT=$G(^TMP($J,"SDAMA301",PNAM,DVBADTM))
 .Q:(+$P(DVBAPT,"^",10)'=1)  ;quit if not C&P Appointment
 .S ^TMP("DVBC",$J,9999999-DVBADTM,DVBADTM)=""
 I ('$D(^TMP("DVBC",$J))) K ^TMP($J,"SDAMA301") Q
 S DVBANDE=$O(^TMP("DVBC",$J,0)),DVBADTM=$O(^TMP("DVBC",$J,DVBANDE,0))
 D:(DVBADTM]"")
 .S X1=DVBADTM,X2=$S(DTRPT]"":DTRPT,1:DVBCNOW)
 .D ^%DTC  ;calculate date diff
 .S:(X>DVBADTS) TOT(DVBAPREXM,"30DAYEX")=TOT(DVBAPREXM,"30DAYEX")+1
 K ^TMP($J,"SDAMA301")
 Q
 ;
GO1 ;  ** TFIND=1 If any exams have not been transferred. **
 K TFIND F XI=0:0 S XI=$O(^DVB(396.4,"C",REQDA,XI)) Q:XI=""  I $P(^DVB(396.4,XI,0),U,4)'="T" S TFIND=1
 Q
 ;if $D(TFIND) at least one exam to be done locally
 ;
PENDCNT I X'<0&(X'>90) S TOT(DVBAPREXM,"P90")=TOT(DVBAPREXM,"P90")+1
 I X>90&(X'>120) S TOT(DVBAPREXM,"P121")=TOT(DVBAPREXM,"P121")+1
 I X>120&(X'>150) S TOT(DVBAPREXM,"P151")=TOT(DVBAPREXM,"P151")+1
 I X>150&(X'>180) S TOT(DVBAPREXM,"P181")=TOT(DVBAPREXM,"P181")+1
 I X>180&(X'>365) S TOT(DVBAPREXM,"P365")=TOT(DVBAPREXM,"P365")+1
 I X>365 S TOT(DVBAPREXM,"P366")=TOT(DVBAPREXM,"P366")+1
 Q
 ;
SET ;
 N DVBAPREXM
 S DTA=^DVB(396.3,REQDA,0),DFN=$P(DTA,U,1),DTREQ=$P(DTA,U,2),DTRPT=$P(DTA,U,5),DTSCHEDC=$P(DTA,U,6),DTRQCMP=$P(DTA,U,7),PRIO=$P(DTA,U,10),DTTRANS=$P(DTA,U,12),OWNDOM=$P(DTA,U,22)
 S DTREL=$P(DTA,U,14),RQSTAT=$P(DTA,U,18),DTCAN=$P(DTA,U,19) K DTA
 S DTA=$S($D(^DVB(396.3,REQDA,4)):^(4),1:""),TROUT=$P(DTA,U,1),DTTROUT=$P(DTA,U,3),DTTRIN=$P(DTA,U,4),DTTRET=$P(DTA,U,5)
 I DTCAN]"",DTCAN<DTRPT,DTRPT]"" S DTRPT=DTCAN ;cancelled last day of month
 Q:DTRPT=""  ;never reported to MAS
 ;check for Parent Request (retrieve current/parent Priority of Exam)
 S DVBAPREXM=$$CHKREQ^DVBCIRP1(REQDA)
 ;original report run (Exclude new priorities)
 Q:((DVBAEXMP']"")&((";BDD;QS;IDES;AO;")[(";"_DVBAPREXM_";")))
 ;report for specific priority
 Q:((DVBAEXMP]"")&(DVBAEXMP'[(";"_DVBAPREXM_";")))
 S:(DVBAEXMP']"") DVBAPREXM="ALL"  ;identifier for totals
 I DTTRIN'<BDATE,DTTRIN'>EDATE S TOT(DVBAPREXM,"TRANSIN")=TOT(DVBAPREXM,"TRANSIN")+1 ;transfers in
 I RQSTAT="CT",DTREL'<BDATE,DTREL'>EDATE S TOT(DVBAPREXM,"TRNRETTO")=TOT(DVBAPREXM,"TRNRETTO")+1 ;transfers returned to owners
 I "^N^NT^P^S^T^"[RQSTAT,OWNDOM]"" S TOT(DVBAPREXM,"TRNPNDTO")=TOT(DVBAPREXM,"TRNPNDTO")+1 ;transfers pending return to others
 Q:DTTRIN]""  ;** A transfer in (not counted further)
 I DTREL'<BDATE,DTREL'>EDATE D DAY30
 I DTTROUT'<BDATE,DTTROUT'>EDATE,TROUT="y" S TOT(DVBAPREXM,"TRANSOUT")=TOT(DVBAPREXM,"TRANSOUT")+1 ;transfers to other sites, not returns
 I TROUT="",DTTRET'<BDATE,DTTRET'>EDATE S TOT(DVBAPREXM,"TRNRETFR")=TOT(DVBAPREXM,"TRNRETFR")+1 ;transfers returned from other sites
 I TROUT="y",RQSTAT="P" S TOT(DVBAPREXM,"TRNPNDFR")=TOT(DVBAPREXM,"TRNPNDFR")+1 ;transfers pending return from other sites
 I DTRPT'<BDATE,DTRPT'>EDATE,PRIO'="E" S TOT(DVBAPREXM,"RECEIVED")=TOT(DVBAPREXM,"RECEIVED")+1
 I DTRPT'<BDATE,DTRPT'>EDATE,PRIO="E" S TOT(DVBAPREXM,"INSUFF")=TOT(DVBAPREXM,"INSUFF")+1
 I DTRPT'<BDATE,DTRPT'>EDATE,RQSTAT'["X" D GO1 I $D(TFIND) S X1=$S(DTSCHEDC]"":DTSCHEDC,1:DVBCNOW),X2=DTRPT D ^%DTC I X>3 S TOT(DVBAPREXM,"3DAYSCH")=TOT(DVBAPREXM,"3DAYSCH")+1
 I DTREL'<BDATE&(DTREL'>EDATE),RQSTAT="C"!(RQSTAT="R") S:PRIO'="E" DVBCPCTM=$$PROCDAY^DVBCUTL2(REQDA) S:PRIO="E" DVBCPCTM=$$INSFTME^DVBCUTA1(REQDA) S TOT(DVBAPREXM,"DAYS")=TOT(DVBAPREXM,"DAYS")+DVBCPCTM K DVBCPCTM
 I DTRPT'>EDATE,"^N^NT^P^S^T^"[RQSTAT S X1=EDATE,X2=DTRPT D ^%DTC,PENDCNT
 I DTRPT'>EDATE,"^C^CT^R^RX^X^"[RQSTAT,(+DTREL>EDATE)!(+DTCAN>EDATE) S X1=EDATE,X2=DTRPT D ^%DTC,PENDCNT
 I DTREL'<BDATE&(DTREL'>EDATE),RQSTAT="C"!(RQSTAT="R") S TOT(DVBAPREXM,"COMPLETED")=TOT(DVBAPREXM,"COMPLETED")+1
 I DTCAN'<BDATE,DTCAN'>EDATE,RQSTAT["X" S TOT(DVBAPREXM,"INCOMPLETE")=TOT(DVBAPREXM,"INCOMPLETE")+1
 K DTRPT Q
 ;
GO ;
 N DVBAEXMP,DVBAP,DVBAPREXM,DVBATOT
 S DVBAEXMP=$S($G(DVBAPRTY)["BDD":";BDD;QS;",($G(DVBAPRTY)["IDES"):";IDES;",($G(DVBAPRTY)["AO"):";AO;",1:"")
 U IO K ^TMP($J) S PG=0,%DT="TS",X="NOW" D ^%DT S DVBCNOW=Y
 S PNAM="" F JJ=0:0 S PNAM=$O(^DVB(396.3,"B",PNAM)) Q:PNAM=""  F REQDA=0:0 S REQDA=$O(^DVB(396.3,"B",PNAM,REQDA)) Q:REQDA=""  D SET
 ;
 S DVBAEXMP=$S($G(DVBAPRTY)["BDD":"BDD,QS",($G(DVBAPRTY)["IDES"):"IDES",($G(DVBAPRTY)["AO"):"AO",1:"ALL")
 M DVBATOT=TOT  ;save totals for all priorities into new array
 F DVBAP=1:1:$L(DVBAEXMP,",") D
 .S DVBAPREXM=$P(DVBAEXMP,",",DVBAP)
 .;re-create TOT array for each priority of exam
 .D CRTOT(DVBAPREXM,.DVBATOT,.TOT)
 .S:($L(DVBAEXMP,",")>1) PREVMO=PREVMO(DVBAPREXM)
 .S TOT("AVGDAYS")=0
 .I TOT("COMPLETED")>0 S TOT("AVGDAYS")=TOT("DAYS")/TOT("COMPLETED"),TOT("AVGDAYS")=$J(TOT("AVGDAYS"),5,1)
 .S TOT("PENDADJ")=PREVMO+TOT("RECEIVED")+TOT("INSUFF")-TOT("COMPLETED")-TOT("INCOMPLETE")
 .D BULLTXT^DVBCAMI1(DVBAPREXM) D EN^DVBCAMI3((DVBAP=$L(DVBAEXMP,",")),DVBAPREXM)
 Q
 ;
 ;Input : DVBACDE - Priority of Exam code to get Totals for
 ;      : DVBATOT - Array holding total values for each specific priority
 ;                  (By Ref)
 ;      : TOT     - array to hold totals for requested priority (By Ref)
 ;Output: TOT array with totals for requested priority
CRTOT(DVBACDE,DVBATOT,TOT) ;create total array for specific priority exam report
 N JI K TOT
 F JI="3DAYSCH","30DAYEX","PENDADJ","TRANSIN","TRNRETTO","TRNPNDTO","TRANSOUT","TRNRETFR","TRNPNDFR","INSUFF" D
 .S TOT(JI)=$G(DVBATOT(DVBACDE,JI))
 F JI="RECEIVED","INCOMPLETE","DAYS","COMPLETED" D
 .S TOT(JI)=$G(DVBATOT(DVBACDE,JI))
 F JI="P90","P121","P151","P181","P365","P366" D
 .S TOT(JI)=$G(DVBATOT(DVBACDE,JI))
 Q