SDESINPUTVALUTL ;ALB/RRM - VISTA SCHEDULING INPUT VALIDATION UTILITY; Jun 10, 2022@15:02
;;5.3;Scheduling;**819,823,824,827,828**;Aug 13, 1993;Build 8
;;Per VHA Directive 6402, this routine should not be modified
;
;External References
;-------------------
; Reference to $$GETS^DIQ is supported by IA #2056
; Reference to GETS^DIQ is supported by IA #2056
; Reference to $$FIND1^DIC is supported by IA #2051
; Reference to ENCODE^XLFJSON is supported by IA #6682
; Reference to $$GETICN^MPIF001 is supported by IA #2701
; Reference to ^ICDEX is supported by IA #5747
;
Q ;No Direct Call
;
VALIDATEMODALITY(SDAPTREQ,MODALITY) ;Retrieve the Modality set of codes
; Input : MODALITY - The internal/external set of code value
; Output: None
;
N SDERR,I,SDMODSOC,YY,RESULT,ERROR,FOUND
S (ERROR,FOUND)=0
S SDMODSOC=$$GET1^DID(409.85,6,,"SET OF CODES",,"SDERR")
I $D(SDERR) S ERROR=1 D ERRLOG^SDESJSON(.SDAPTREQ,224) Q ERROR
;check if the modality set of code passed in are valid
F I=1:1:$L(SDMODSOC,":") D
. S YY=$P($P(SDMODSOC,";",I),":")
. I YY=MODALITY S MODALITY=YY,FOUND=1
I $G(MODALITY)'="",'FOUND S ERROR=1 D ERRLOG^SDESJSON(.SDAPTREQ,224)
Q ERROR
;
GETRES(SDCL,INACT) ;get resource for clinic - SDEC RESOURCE
N SDHLN,SDI,SDNOD,SDRES,SDRES1
S (SDRES,SDRES1)=""
S SDHLN=$P($G(^SC(SDCL,0)),U,1)
Q:SDHLN="" ""
S SDI="" F S SDI=$O(^SDEC(409.831,"ALOC",SDCL,SDI)) Q:SDI="" D Q:SDRES'=""
. S SDNOD=$G(^SDEC(409.831,SDI,0))
. I '$G(INACT) Q:$$GET1^DIQ(409.831,SDI_",",.02)="YES"
. S:SDRES1="" SDRES1=SDI
. Q:$P($P(SDNOD,U,11),";",2)'="SC("
. S SDRES=SDI
I SDRES="",SDRES1'="" S SDRES=SDRES1
Q SDRES
;
VALIDATEEAS(ERRORS,SDEAS) ;Validate SDEAS
S SDEAS=$G(SDEAS,"")
I $L(SDEAS) S SDEAS=$$EASVALIDATE^SDESUTIL(SDEAS)
I SDEAS=-1 D ERRLOG^SDESJSON(.ERRORS,142) Q
Q
;
LAST4SSN(DFN) ;Retrieve the last 4 SSN of a patient
N LAST4SSN
S LAST4SSN=$$GET1^DIQ(2,DFN_",",.09,"E")
I LAST4SSN["P" S LAST4SSN=$E(LAST4SSN,6,10) Q LAST4SSN
S LAST4SSN=$E(LAST4SSN,6,9)
Q LAST4SSN
;
GETPATICN(DFN) ;Retrieve Patient ICN
N PATIENTICN
S PATIENTICN=$$GETICN^MPIF001(DFN)
S PATIENTICN=$S(+PATIENTICN>0:PATIENTICN,1:"")
Q PATIENTICN
;
VALIDATEDFN(ERRORS,DFN) ;
I DFN="" D ERRLOG^SDESJSON(.ERRORS,1) Q
I DFN'="",'$D(^DPT(DFN,0)) D ERRLOG^SDESJSON(.ERRORS,2) Q
Q
;
GETDIAGSTAT(DIAG) ;Get the current Diagnosis status
N DIAGCODENUM,DIAGCODESTAT
S DIAGCODENUM=$$GET1^DIQ(80,$S(+DIAG:DIAG,1:+$$CODEN^ICDEX(DIAG,80)),.01)
S DIAGCODESTAT=$P($$ICDDX^ICDEX(DIAGCODENUM),"^",10)
Q +DIAGCODESTAT
;
DELDIAGNOSIS(SCIEN) ;Remove existing Diagnosis prior to updating new ones
N DIK,DA
Q:$G(SCIEN)=""
S DA(1)=SCIEN
S DIK="^SC("_DA(1)_",""DX"","
S DA=0 F S DA=$O(^SC(SCIEN,"DX",DA)) Q:'DA D ^DIK
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESINPUTVALUTL 2846 printed Dec 13, 2024@02:57:18 Page 2
SDESINPUTVALUTL ;ALB/RRM - VISTA SCHEDULING INPUT VALIDATION UTILITY; Jun 10, 2022@15:02
+1 ;;5.3;Scheduling;**819,823,824,827,828**;Aug 13, 1993;Build 8
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 ;External References
+5 ;-------------------
+6 ; Reference to $$GETS^DIQ is supported by IA #2056
+7 ; Reference to GETS^DIQ is supported by IA #2056
+8 ; Reference to $$FIND1^DIC is supported by IA #2051
+9 ; Reference to ENCODE^XLFJSON is supported by IA #6682
+10 ; Reference to $$GETICN^MPIF001 is supported by IA #2701
+11 ; Reference to ^ICDEX is supported by IA #5747
+12 ;
+13 ;No Direct Call
QUIT
+14 ;
VALIDATEMODALITY(SDAPTREQ,MODALITY) ;Retrieve the Modality set of codes
+1 ; Input : MODALITY - The internal/external set of code value
+2 ; Output: None
+3 ;
+4 NEW SDERR,I,SDMODSOC,YY,RESULT,ERROR,FOUND
+5 SET (ERROR,FOUND)=0
+6 SET SDMODSOC=$$GET1^DID(409.85,6,,"SET OF CODES",,"SDERR")
+7 IF $DATA(SDERR)
SET ERROR=1
DO ERRLOG^SDESJSON(.SDAPTREQ,224)
QUIT ERROR
+8 ;check if the modality set of code passed in are valid
+9 FOR I=1:1:$LENGTH(SDMODSOC,":")
Begin DoDot:1
+10 SET YY=$PIECE($PIECE(SDMODSOC,";",I),":")
+11 IF YY=MODALITY
SET MODALITY=YY
SET FOUND=1
End DoDot:1
+12 IF $GET(MODALITY)'=""
IF 'FOUND
SET ERROR=1
DO ERRLOG^SDESJSON(.SDAPTREQ,224)
+13 QUIT ERROR
+14 ;
GETRES(SDCL,INACT) ;get resource for clinic - SDEC RESOURCE
+1 NEW SDHLN,SDI,SDNOD,SDRES,SDRES1
+2 SET (SDRES,SDRES1)=""
+3 SET SDHLN=$PIECE($GET(^SC(SDCL,0)),U,1)
+4 if SDHLN=""
QUIT ""
+5 SET SDI=""
FOR
SET SDI=$ORDER(^SDEC(409.831,"ALOC",SDCL,SDI))
if SDI=""
QUIT
Begin DoDot:1
+6 SET SDNOD=$GET(^SDEC(409.831,SDI,0))
+7 IF '$GET(INACT)
if $$GET1^DIQ(409.831,SDI_",",.02)="YES"
QUIT
+8 if SDRES1=""
SET SDRES1=SDI
+9 if $PIECE($PIECE(SDNOD,U,11),";",2)'="SC("
QUIT
+10 SET SDRES=SDI
End DoDot:1
if SDRES'=""
QUIT
+11 IF SDRES=""
IF SDRES1'=""
SET SDRES=SDRES1
+12 QUIT SDRES
+13 ;
VALIDATEEAS(ERRORS,SDEAS) ;Validate SDEAS
+1 SET SDEAS=$GET(SDEAS,"")
+2 IF $LENGTH(SDEAS)
SET SDEAS=$$EASVALIDATE^SDESUTIL(SDEAS)
+3 IF SDEAS=-1
DO ERRLOG^SDESJSON(.ERRORS,142)
QUIT
+4 QUIT
+5 ;
LAST4SSN(DFN) ;Retrieve the last 4 SSN of a patient
+1 NEW LAST4SSN
+2 SET LAST4SSN=$$GET1^DIQ(2,DFN_",",.09,"E")
+3 IF LAST4SSN["P"
SET LAST4SSN=$EXTRACT(LAST4SSN,6,10)
QUIT LAST4SSN
+4 SET LAST4SSN=$EXTRACT(LAST4SSN,6,9)
+5 QUIT LAST4SSN
+6 ;
GETPATICN(DFN) ;Retrieve Patient ICN
+1 NEW PATIENTICN
+2 SET PATIENTICN=$$GETICN^MPIF001(DFN)
+3 SET PATIENTICN=$SELECT(+PATIENTICN>0:PATIENTICN,1:"")
+4 QUIT PATIENTICN
+5 ;
VALIDATEDFN(ERRORS,DFN) ;
+1 IF DFN=""
DO ERRLOG^SDESJSON(.ERRORS,1)
QUIT
+2 IF DFN'=""
IF '$DATA(^DPT(DFN,0))
DO ERRLOG^SDESJSON(.ERRORS,2)
QUIT
+3 QUIT
+4 ;
GETDIAGSTAT(DIAG) ;Get the current Diagnosis status
+1 NEW DIAGCODENUM,DIAGCODESTAT
+2 SET DIAGCODENUM=$$GET1^DIQ(80,$SELECT(+DIAG:DIAG,1:+$$CODEN^ICDEX(DIAG,80)),.01)
+3 SET DIAGCODESTAT=$PIECE($$ICDDX^ICDEX(DIAGCODENUM),"^",10)
+4 QUIT +DIAGCODESTAT
+5 ;
DELDIAGNOSIS(SCIEN) ;Remove existing Diagnosis prior to updating new ones
+1 NEW DIK,DA
+2 if $GET(SCIEN)=""
QUIT
+3 SET DA(1)=SCIEN
+4 SET DIK="^SC("_DA(1)_",""DX"","
+5 SET DA=0
FOR
SET DA=$ORDER(^SC(SCIEN,"DX",DA))
if 'DA
QUIT
DO ^DIK
+6 QUIT
+7 ;