HMPRPCRC ;AFS/WPB - Check and clear the HMP resource device ;Jan 20, 2017
;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**3**;Jan 20, 2017;Build 15
;Per VA Directive 6402, this routine should not be modified.
;
Q
EN(LST) ; return the data for any jobs running in all 'busy' slots
;Input:
;RESOURCE - Name of the resource to check - required
;Returns LST array:
;$P(1) : SLOT #
;$P(2) : CPU
;$P(3) : JOB #
;$P(4) : TASK #
;$P(5) : TASK STATUS
;$P(6) : START DATE/TIME
;$P(7) : CURRENT DATE/TIME
;$P(8) : TIME DIFFERENCE BETWEEN START AND CURRENT TIME AS DAYS HR:MM:SS
;
N HMPERR,HMPIEN,HMPSLOT,MXSLOTS,SLOTS
S HMPIEN=$$FIND1^DIC(3.54,"","MX","HMP EXTRACT RESOURCE","","","HMPERR")
I $G(HMPIEN)=0!($G(HMPIEN)="") S LST="Resource doesn't exist" Q
D GETS^DIQ(3.54,HMPIEN_",","**","I","HMPSLOT","HMPERR")
I '$D(HMPSLOT) S LST="All slots are open" Q
S MXSLOTS=$G(HMPSLOT(3.54,HMPIEN_",",1,"I"))
F SLOTS=1:1:MXSLOTS+1 D
.N CDTTM,DIFF,JOB,ST,START,STATUS,ZTSK,ZTCPU,%
.S LST(SLOTS)=""
.S ZTCPU=$G(HMPSLOT(3.542,SLOTS_",1,",1,"I")),JOB=$G(HMPSLOT(3.542,SLOTS_",1,",2,"I")),ZTSK=$G(HMPSLOT(3.542,SLOTS_",1,",3,"I")),START=$$HTE^XLFDT($G(HMPSLOT(3.542,SLOTS_",1,",4,"I")))
.I $G(ZTSK)'="" D
..D NOW^%DTC S CDTTM=%
..S:$G(HMPSLOT(3.542,SLOTS_",1,",4,"I"))'="" ST=$$HTFM^XLFDT($G(HMPSLOT(3.542,SLOTS_",1,",4,"I")))
..D ISQED^%ZTLOAD S STATUS=$S(ZTSK(0)=0:"TASK IS NOT SCHEDULED",ZTSK(0)="":"TASK DOESN'T EXIST",ZTSK(0)=1:"TASK IS SCHEDULED",1:"")
..S:$G(ST)'="" DIFF=$$FMDIFF^XLFDT(CDTTM,ST,3)
.S LST(SLOTS)=$S(ZTSK="":"SLOT IS OPEN",ZTSK>0:SLOTS_"^"_$G(ZTCPU)_"^"_$G(JOB)_"^"_$G(ZTSK)_"^"_$G(STATUS)_"^"_$G(START))_"^"_$G(CDTTM)_"^"_$G(DIFF)
Q
CLEAR(RESULTS,SLOT) ; clear a resource slot
;Input:
;RESOURCE - Name of the resource to check - required
;SLOT - Slot number to clear
;Output: returns 1 if successful, otherwise returns 0^reason
S RESULTS=1
N HMPERR,HMPIEN,HMPSLOT,MXSLOTS
S HMPIEN=$$FIND1^DIC(3.54,"","MX","HMP EXTRACT RESOURCE","","","HMPERR")
I $G(HMPIEN)=0!($G(HMPIEN)="") S RESULTS="0^Resource doesn't exist" Q
D KILLRES^%ZISC(HMPIEN,SLOT)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPRPCRC 2133 printed Dec 13, 2024@01:54:35 Page 2
HMPRPCRC ;AFS/WPB - Check and clear the HMP resource device ;Jan 20, 2017
+1 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**3**;Jan 20, 2017;Build 15
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 QUIT
EN(LST) ; return the data for any jobs running in all 'busy' slots
+1 ;Input:
+2 ;RESOURCE - Name of the resource to check - required
+3 ;Returns LST array:
+4 ;$P(1) : SLOT #
+5 ;$P(2) : CPU
+6 ;$P(3) : JOB #
+7 ;$P(4) : TASK #
+8 ;$P(5) : TASK STATUS
+9 ;$P(6) : START DATE/TIME
+10 ;$P(7) : CURRENT DATE/TIME
+11 ;$P(8) : TIME DIFFERENCE BETWEEN START AND CURRENT TIME AS DAYS HR:MM:SS
+12 ;
+13 NEW HMPERR,HMPIEN,HMPSLOT,MXSLOTS,SLOTS
+14 SET HMPIEN=$$FIND1^DIC(3.54,"","MX","HMP EXTRACT RESOURCE","","","HMPERR")
+15 IF $GET(HMPIEN)=0!($GET(HMPIEN)="")
SET LST="Resource doesn't exist"
QUIT
+16 DO GETS^DIQ(3.54,HMPIEN_",","**","I","HMPSLOT","HMPERR")
+17 IF '$DATA(HMPSLOT)
SET LST="All slots are open"
QUIT
+18 SET MXSLOTS=$GET(HMPSLOT(3.54,HMPIEN_",",1,"I"))
+19 FOR SLOTS=1:1:MXSLOTS+1
Begin DoDot:1
+20 NEW CDTTM,DIFF,JOB,ST,START,STATUS,ZTSK,ZTCPU,%
+21 SET LST(SLOTS)=""
+22 SET ZTCPU=$GET(HMPSLOT(3.542,SLOTS_",1,",1,"I"))
SET JOB=$GET(HMPSLOT(3.542,SLOTS_",1,",2,"I"))
SET ZTSK=$GET(HMPSLOT(3.542,SLOTS_",1,",3,"I"))
SET START=$$HTE^XLFDT($GET(HMPSLOT(3.542,SLOTS_",1,",4,"I")))
+23 IF $GET(ZTSK)'=""
Begin DoDot:2
+24 DO NOW^%DTC
SET CDTTM=%
+25 if $GET(HMPSLOT(3.542,SLOTS_",1,",4,"I"))'=""
SET ST=$$HTFM^XLFDT($GET(HMPSLOT(3.542,SLOTS_",1,",4,"I")))
+26 DO ISQED^%ZTLOAD
SET STATUS=$SELECT(ZTSK(0)=0:"TASK IS NOT SCHEDULED",ZTSK(0)="":"TASK DOESN'T EXIST",ZTSK(0)=1:"TASK IS SCHEDULED",1:"")
+27 if $GET(ST)'=""
SET DIFF=$$FMDIFF^XLFDT(CDTTM,ST,3)
End DoDot:2
+28 SET LST(SLOTS)=$SELECT(ZTSK="":"SLOT IS OPEN",ZTSK>0:SLOTS_"^"_$GET(ZTCPU)_"^"_$GET(JOB)_"^"_$GET(ZTSK)_"^"_$GET(STATUS)_"^"_$GET(START))_"^"_$GET(CDTTM)_"^"_$GET(DIFF)
End DoDot:1
+29 QUIT
CLEAR(RESULTS,SLOT) ; clear a resource slot
+1 ;Input:
+2 ;RESOURCE - Name of the resource to check - required
+3 ;SLOT - Slot number to clear
+4 ;Output: returns 1 if successful, otherwise returns 0^reason
+5 SET RESULTS=1
+6 NEW HMPERR,HMPIEN,HMPSLOT,MXSLOTS
+7 SET HMPIEN=$$FIND1^DIC(3.54,"","MX","HMP EXTRACT RESOURCE","","","HMPERR")
+8 IF $GET(HMPIEN)=0!($GET(HMPIEN)="")
SET RESULTS="0^Resource doesn't exist"
QUIT
+9 DO KILLRES^%ZISC(HMPIEN,SLOT)
+10 QUIT