SDESGETSTOPCODE ;ALB/ANU - VISTA SCHEDULING READ STOP CODE DETAILS ;Jan 25,2022@15:01
;;5.3;Scheduling;**807**;Aug 13, 1993;Build 5
;;Per VHA Directive 6402, this routine should not be modified
Q
;
GETSTCDDTL(SDSTCDJSON,SDSTCD) ;get all details of Stop Code from CLINIC STOP file #40.7
; INPUT:
; SDSTCD - Clinic Stop Code
;
N ERRPOP,ERR,ERRMSG,SDECI,SDSTCDREC,SDSTCDIEN
D INIT
D VALIDATE
I ERRPOP D BLDJSON Q
D GETSTCDINF
D BLDJSON
Q
;
INIT ; initialize values needed
S SDECI=0,SDSTCDIEN=""
S ERR=""
S ERRPOP=0,ERRMSG=""
Q
;
VALIDATE ;Validate required fields are sent
I $G(SDSTCD)="" D ERRLOG^SDESJSON(.SDSTCDREC,98) S ERRPOP=1 Q
S SDSTCDIEN=$$FIND1^DIC(40.7,,"X",$G(SDSTCD),"C",,"SDERR")
I $G(SDSTCDIEN)=""!$G(SDSTCDIEN)=0 D ERRLOG^SDESJSON(.SDSTCDREC,99) S ERRPOP=1 Q
Q
;
GETSTCDINF ; Get Stop Code Information
N SDFIELDS,SDDATA,SDMSG
S SDFIELDS=".01;2;3;4;5;6"
D GETS^DIQ(40.7,SDSTCDIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
S SDSTCDREC("Stop Code","Name")=$G(SDDATA(40.7,SDSTCDIEN_",",.01,"E")) ;Stop Code Name
S SDSTCDREC("Stop Code","IEN")=SDSTCDIEN ;Stop Code IEN
S SDSTCDREC("Stop Code","Inactive Date")=$$FMTISO^SDAMUTDT($G(SDDATA(40.7,SDSTCDIEN_",",2,"I"))) ;Inactive Date
S SDSTCDREC("Stop Code","Cost Distribution Center")=$G(SDDATA(40.7,SDSTCDIEN_",",4,"E")) ;Cost Distribution Center
S SDSTCDREC("Stop Code","Restriction Type")=$G(SDDATA(40.7,SDSTCDIEN_",",5,"E")) ;Restrication Type
S SDSTCDREC("Stop Code","Restriction Date")=$$FMTISO^SDAMUTDT($G(SDDATA(40.7,SDSTCDIEN_",",6,"I"))) ;Restriction Date
Q
;
BLDJSON ; Build JSON format
D ENCODE^SDESJSON(.SDSTCDREC,.SDSTCDJSON,.ERR)
K SDUSRSREC
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESGETSTOPCODE 1698 printed Nov 22, 2024@18:07:01 Page 2
SDESGETSTOPCODE ;ALB/ANU - VISTA SCHEDULING READ STOP CODE DETAILS ;Jan 25,2022@15:01
+1 ;;5.3;Scheduling;**807**;Aug 13, 1993;Build 5
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 QUIT
+4 ;
GETSTCDDTL(SDSTCDJSON,SDSTCD) ;get all details of Stop Code from CLINIC STOP file #40.7
+1 ; INPUT:
+2 ; SDSTCD - Clinic Stop Code
+3 ;
+4 NEW ERRPOP,ERR,ERRMSG,SDECI,SDSTCDREC,SDSTCDIEN
+5 DO INIT
+6 DO VALIDATE
+7 IF ERRPOP
DO BLDJSON
QUIT
+8 DO GETSTCDINF
+9 DO BLDJSON
+10 QUIT
+11 ;
INIT ; initialize values needed
+1 SET SDECI=0
SET SDSTCDIEN=""
+2 SET ERR=""
+3 SET ERRPOP=0
SET ERRMSG=""
+4 QUIT
+5 ;
VALIDATE ;Validate required fields are sent
+1 IF $GET(SDSTCD)=""
DO ERRLOG^SDESJSON(.SDSTCDREC,98)
SET ERRPOP=1
QUIT
+2 SET SDSTCDIEN=$$FIND1^DIC(40.7,,"X",$GET(SDSTCD),"C",,"SDERR")
+3 IF $GET(SDSTCDIEN)=""!$GET(SDSTCDIEN)=0
DO ERRLOG^SDESJSON(.SDSTCDREC,99)
SET ERRPOP=1
QUIT
+4 QUIT
+5 ;
GETSTCDINF ; Get Stop Code Information
+1 NEW SDFIELDS,SDDATA,SDMSG
+2 SET SDFIELDS=".01;2;3;4;5;6"
+3 DO GETS^DIQ(40.7,SDSTCDIEN_",",SDFIELDS,"IE","SDDATA","SDMSG")
+4 ;Stop Code Name
SET SDSTCDREC("Stop Code","Name")=$GET(SDDATA(40.7,SDSTCDIEN_",",.01,"E"))
+5 ;Stop Code IEN
SET SDSTCDREC("Stop Code","IEN")=SDSTCDIEN
+6 ;Inactive Date
SET SDSTCDREC("Stop Code","Inactive Date")=$$FMTISO^SDAMUTDT($GET(SDDATA(40.7,SDSTCDIEN_",",2,"I")))
+7 ;Cost Distribution Center
SET SDSTCDREC("Stop Code","Cost Distribution Center")=$GET(SDDATA(40.7,SDSTCDIEN_",",4,"E"))
+8 ;Restrication Type
SET SDSTCDREC("Stop Code","Restriction Type")=$GET(SDDATA(40.7,SDSTCDIEN_",",5,"E"))
+9 ;Restriction Date
SET SDSTCDREC("Stop Code","Restriction Date")=$$FMTISO^SDAMUTDT($GET(SDDATA(40.7,SDSTCDIEN_",",6,"I")))
+10 QUIT
+11 ;
BLDJSON ; Build JSON format
+1 DO ENCODE^SDESJSON(.SDSTCDREC,.SDSTCDJSON,.ERR)
+2 KILL SDUSRSREC
+3 QUIT
+4 ;