SDESGETMHCODE ;ALB/CGP - VISTA SCHEDULING CHECKING MENTAL HEALTH STOP CODE ;Jan 12,2023@09:53
;;5.3;Scheduling;**835**;Aug 13, 1993;Build 4
;;Per VHA Directive 6402, this routine should not be modified
Q
;
STOPCODE(MHCDJSON,SPIEN) ;check if IEN is a Mental Health Stop Code from CLINIC STOP file #40.7
; INPUT:
; SPIEN - Clinic Stop Code
;
N AMISCODE,ERRFLG,RETURN
S (AMISCODE,ERRFLG,RETURN)=""
;
D VALIDATE(.RETURN,.SPIEN,.AMISCODE,.ERRFLG)
I ERRFLG'="" S RETURN("Flag")=0 D BLDJSON(.MHCDJSON,.RETURN) Q
;
D MENTALHEALTHCHK(.RETURN,.AMISCODE)
;
D BLDJSON(.MHCDJSON,.RETURN)
Q
;
VALIDATE(RETURN,SPIEN,AMISCODE,ERRFLG) ;
N INACTIVE
S INACTIVE=""
I SPIEN="" S ERRFLG=1 D ERRLOG^SDESJSON(.RETURN,413) Q
I $G(^DIC(40.7,SPIEN,0))="" S ERRFLG=1 D ERRLOG^SDESJSON(.RETURN,414) Q
;
S INACTIVE=$$GET1^DIQ(40.7,SPIEN,2)
I INACTIVE'="",INACTIVE<DT S ERRFLG=1 D ERRLOG^SDESJSON(.RETURN,415) Q
;
S AMISCODE=$$GET1^DIQ(40.7,SPIEN,1)
I AMISCODE="" S ERRFLG=1 D ERRLOG^SDESJSON(.RETURN,416) Q
Q
;
MENTALHEALTHCHK(RETURN,AMISCODE) ;
I AMISCODE>599 S RETURN("Flag")=0
I AMISCODE<500 S RETURN("Flag")=0
I AMISCODE>500,AMISCODE<599 S RETURN("Flag")=1
Q
;
BLDJSON(MHCDJSON,RETURN) ; Build JSON format
D BUILDJSON^SDESBUILDJSON(.MHCDJSON,.RETURN)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETMHCODE 1311 printed Dec 13, 2024@02:56:58 Page 2
SDESGETMHCODE ;ALB/CGP - VISTA SCHEDULING CHECKING MENTAL HEALTH STOP CODE ;Jan 12,2023@09:53
+1 ;;5.3;Scheduling;**835**;Aug 13, 1993;Build 4
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 QUIT
+4 ;
STOPCODE(MHCDJSON,SPIEN) ;check if IEN is a Mental Health Stop Code from CLINIC STOP file #40.7
+1 ; INPUT:
+2 ; SPIEN - Clinic Stop Code
+3 ;
+4 NEW AMISCODE,ERRFLG,RETURN
+5 SET (AMISCODE,ERRFLG,RETURN)=""
+6 ;
+7 DO VALIDATE(.RETURN,.SPIEN,.AMISCODE,.ERRFLG)
+8 IF ERRFLG'=""
SET RETURN("Flag")=0
DO BLDJSON(.MHCDJSON,.RETURN)
QUIT
+9 ;
+10 DO MENTALHEALTHCHK(.RETURN,.AMISCODE)
+11 ;
+12 DO BLDJSON(.MHCDJSON,.RETURN)
+13 QUIT
+14 ;
VALIDATE(RETURN,SPIEN,AMISCODE,ERRFLG) ;
+1 NEW INACTIVE
+2 SET INACTIVE=""
+3 IF SPIEN=""
SET ERRFLG=1
DO ERRLOG^SDESJSON(.RETURN,413)
QUIT
+4 IF $GET(^DIC(40.7,SPIEN,0))=""
SET ERRFLG=1
DO ERRLOG^SDESJSON(.RETURN,414)
QUIT
+5 ;
+6 SET INACTIVE=$$GET1^DIQ(40.7,SPIEN,2)
+7 IF INACTIVE'=""
IF INACTIVE<DT
SET ERRFLG=1
DO ERRLOG^SDESJSON(.RETURN,415)
QUIT
+8 ;
+9 SET AMISCODE=$$GET1^DIQ(40.7,SPIEN,1)
+10 IF AMISCODE=""
SET ERRFLG=1
DO ERRLOG^SDESJSON(.RETURN,416)
QUIT
+11 QUIT
+12 ;
MENTALHEALTHCHK(RETURN,AMISCODE) ;
+1 IF AMISCODE>599
SET RETURN("Flag")=0
+2 IF AMISCODE<500
SET RETURN("Flag")=0
+3 IF AMISCODE>500
IF AMISCODE<599
SET RETURN("Flag")=1
+4 QUIT
+5 ;
BLDJSON(MHCDJSON,RETURN) ; Build JSON format
+1 DO BUILDJSON^SDESBUILDJSON(.MHCDJSON,.RETURN)
+2 QUIT
+3 ;