SDES2GETSNAPS ;ALB/BLB - GET SPECIAL NEEDS PREFS; Feb 13, 2023@6:10pm
;;5.3;Scheduling;**864,877**;Aug 13, 1993;Build 14
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
GETNEEDSPREFS(JSON,SDCONTEXT,NEEDSPREFS) ;
N RETURN,ERRORS,NEEDSANDPREFS,VALRETURN
;
D VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,2,$G(NEEDSPREFS("PATIENT DFN")),1,,1,2)
D VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
I $D(ERRORS) S ERRORS("SpecialNeedsAndPreferences",1)="" M RETURN=ERRORS D BUILDJSON^SDES2JSON(.JSON,.RETURN) Q
;
D BUILD(.NEEDSANDPREFS,NEEDSPREFS("PATIENT DFN"))
I '$D(NEEDSANDPREFS) S NEEDSANDPREFS("SpecialNeedsAndPreferences",1)=""
;
M RETURN=NEEDSANDPREFS D BUILDJSON^SDES2JSON(.JSON,.RETURN)
Q
;
BUILD(NEEDSANDPREFS,DFN) ;
N NEEDSPREFSIEN,COUNT,IENS,NUM,NEEDSPREFSSUBIEN,REMARKSIEN
;
I '$D(^SDEC(409.845,"B",DFN)) Q
;
S NEEDSPREFSIEN=0,NEEDSPREFSIEN=$O(^SDEC(409.845,"B",DFN,NEEDSPREFSIEN))
;
S NEEDSPREFSSUBIEN=0,COUNT=0
F S NEEDSPREFSSUBIEN=$O(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN)) Q:'NEEDSPREFSSUBIEN D
.S IENS=NEEDSPREFSSUBIEN_","_NEEDSPREFSIEN_",",COUNT=COUNT+1
.I $$GET1^DIQ(409.8451,NEEDSPREFSSUBIEN_","_NEEDSPREFSIEN_",",5,"I") Q
.S NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"Preference")=$$GET1^DIQ(409.8451,IENS,.01,"E")
.S NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"DateTimeAdded")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8451,IENS,2,"I"))
.S NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"EnteredByName")=$$GET1^DIQ(409.8451,IENS,3,"E")
.S NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"EnteredByIEN")=$$GET1^DIQ(409.8451,IENS,3,"I")
.;
.S REMARKSIEN=0
.F S REMARKSIEN=$O(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN,1,REMARKSIEN)) Q:'REMARKSIEN D
..S NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"Remarks",REMARKSIEN)=$$GET1^DIQ(409.84516,REMARKSIEN_","_IENS,.01,"E")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2GETSNAPS 1911 printed Dec 13, 2024@02:54:13 Page 2
SDES2GETSNAPS ;ALB/BLB - GET SPECIAL NEEDS PREFS; Feb 13, 2023@6:10pm
+1 ;;5.3;Scheduling;**864,877**;Aug 13, 1993;Build 14
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
GETNEEDSPREFS(JSON,SDCONTEXT,NEEDSPREFS) ;
+1 NEW RETURN,ERRORS,NEEDSANDPREFS,VALRETURN
+2 ;
+3 DO VALFILEIEN^SDES2VALUTIL(.VALRETURN,.ERRORS,2,$GET(NEEDSPREFS("PATIENT DFN")),1,,1,2)
+4 DO VALCONTEXT^SDES2VALCONTEXT(.ERRORS,.SDCONTEXT)
+5 IF $DATA(ERRORS)
SET ERRORS("SpecialNeedsAndPreferences",1)=""
MERGE RETURN=ERRORS
DO BUILDJSON^SDES2JSON(.JSON,.RETURN)
QUIT
+6 ;
+7 DO BUILD(.NEEDSANDPREFS,NEEDSPREFS("PATIENT DFN"))
+8 IF '$DATA(NEEDSANDPREFS)
SET NEEDSANDPREFS("SpecialNeedsAndPreferences",1)=""
+9 ;
+10 MERGE RETURN=NEEDSANDPREFS
DO BUILDJSON^SDES2JSON(.JSON,.RETURN)
+11 QUIT
+12 ;
BUILD(NEEDSANDPREFS,DFN) ;
+1 NEW NEEDSPREFSIEN,COUNT,IENS,NUM,NEEDSPREFSSUBIEN,REMARKSIEN
+2 ;
+3 IF '$DATA(^SDEC(409.845,"B",DFN))
QUIT
+4 ;
+5 SET NEEDSPREFSIEN=0
SET NEEDSPREFSIEN=$ORDER(^SDEC(409.845,"B",DFN,NEEDSPREFSIEN))
+6 ;
+7 SET NEEDSPREFSSUBIEN=0
SET COUNT=0
+8 FOR
SET NEEDSPREFSSUBIEN=$ORDER(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN))
if 'NEEDSPREFSSUBIEN
QUIT
Begin DoDot:1
+9 SET IENS=NEEDSPREFSSUBIEN_","_NEEDSPREFSIEN_","
SET COUNT=COUNT+1
+10 IF $$GET1^DIQ(409.8451,NEEDSPREFSSUBIEN_","_NEEDSPREFSIEN_",",5,"I")
QUIT
+11 SET NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"Preference")=$$GET1^DIQ(409.8451,IENS,.01,"E")
+12 SET NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"DateTimeAdded")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8451,IENS,2,"I"))
+13 SET NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"EnteredByName")=$$GET1^DIQ(409.8451,IENS,3,"E")
+14 SET NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"EnteredByIEN")=$$GET1^DIQ(409.8451,IENS,3,"I")
+15 ;
+16 SET REMARKSIEN=0
+17 FOR
SET REMARKSIEN=$ORDER(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN,1,REMARKSIEN))
if 'REMARKSIEN
QUIT
Begin DoDot:2
+18 SET NEEDSANDPREFS("SpecialNeedsAndPreferences",COUNT,"Remarks",REMARKSIEN)=$$GET1^DIQ(409.84516,REMARKSIEN_","_IENS,.01,"E")
End DoDot:2
End DoDot:1
+19 QUIT
+20 ;