SDESNEEDSPREFS ;ALB/BLB - SDES SPECIAL NEEDS PREFS; Feb 13, 2023@6:10pm
;;5.3;Scheduling;**842**;Aug 13, 1993;Build 17
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
GETNEEDSPREFS(JSONRETURN,DFN) ;
N RETURN,ERRORS,NEEDSANDPREFS
;
I '$$VALIDATEDFN(.ERRORS,$G(DFN)) M RETURN=ERRORS D BUILDJSON(.JSONRETURN,.RETURN) Q
;
D BUILD(.NEEDSANDPREFS,DFN)
I '$D(NEEDSANDPREFS) S NEEDSANDPREFS("Patient",1)=""
;
M RETURN=NEEDSANDPREFS D BUILDJSON^SDESBUILDJSON(.JSONRETURN,.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 NEEDSANDPREFS("Patient",1,"PatientName")=$$GET1^DIQ(409.845,NEEDSPREFSIEN,.01,"E")
;
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
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"Preference")=$$GET1^DIQ(409.8451,IENS,.01,"E")
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"DateTimeAdded")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8451,IENS,2,"I"))
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"EnteredByName")=$$GET1^DIQ(409.8451,IENS,3,"E")
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"EnteredByIEN")=$$GET1^DIQ(409.8451,IENS,3,"I")
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"InactiveDate")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8451,IENS,4,"I"))
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"InactivatedBy")=$$GET1^DIQ(409.8451,IENS,5,"E")
.S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"InactivatedByIEN")=$$GET1^DIQ(409.8451,IENS,5,"I")
.S REMARKSIEN=0,NUM=0
.F S REMARKSIEN=$O(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN,1,REMARKSIEN)) Q:'REMARKSIEN D
..S NUM=NUM+1
..S NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"Remarks",NUM)=$$GET1^DIQ(409.84516,REMARKSIEN_","_IENS,.01,"E")
Q
;
VALIDATEDFN(ERRORS,DFN) ;
I DFN="" D ERRLOG^SDESJSON(.ERRORS,1) Q 0
I DFN'="",'$D(^DPT(DFN,0)) D ERRLOG^SDESJSON(.ERRORS,2) Q 0
Q 1
;
BUILDJSON(JSONRETURN,RETURN) ;
N JSONERROR
D ENCODE^XLFJSON("RETURN","JSONRETURN")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESNEEDSPREFS 2381 printed Nov 22, 2024@18:07:15 Page 2
SDESNEEDSPREFS ;ALB/BLB - SDES SPECIAL NEEDS PREFS; Feb 13, 2023@6:10pm
+1 ;;5.3;Scheduling;**842**;Aug 13, 1993;Build 17
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
GETNEEDSPREFS(JSONRETURN,DFN) ;
+1 NEW RETURN,ERRORS,NEEDSANDPREFS
+2 ;
+3 IF '$$VALIDATEDFN(.ERRORS,$GET(DFN))
MERGE RETURN=ERRORS
DO BUILDJSON(.JSONRETURN,.RETURN)
QUIT
+4 ;
+5 DO BUILD(.NEEDSANDPREFS,DFN)
+6 IF '$DATA(NEEDSANDPREFS)
SET NEEDSANDPREFS("Patient",1)=""
+7 ;
+8 MERGE RETURN=NEEDSANDPREFS
DO BUILDJSON^SDESBUILDJSON(.JSONRETURN,.RETURN)
+9 QUIT
+10 ;
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 SET NEEDSANDPREFS("Patient",1,"PatientName")=$$GET1^DIQ(409.845,NEEDSPREFSIEN,.01,"E")
+7 ;
+8 SET NEEDSPREFSSUBIEN=0
SET COUNT=0
+9 FOR
SET NEEDSPREFSSUBIEN=$ORDER(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN))
if 'NEEDSPREFSSUBIEN
QUIT
Begin DoDot:1
+10 SET IENS=NEEDSPREFSSUBIEN_","_NEEDSPREFSIEN_","
SET COUNT=COUNT+1
+11 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"Preference")=$$GET1^DIQ(409.8451,IENS,.01,"E")
+12 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"DateTimeAdded")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8451,IENS,2,"I"))
+13 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"EnteredByName")=$$GET1^DIQ(409.8451,IENS,3,"E")
+14 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"EnteredByIEN")=$$GET1^DIQ(409.8451,IENS,3,"I")
+15 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"InactiveDate")=$$FMTISO^SDAMUTDT($$GET1^DIQ(409.8451,IENS,4,"I"))
+16 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"InactivatedBy")=$$GET1^DIQ(409.8451,IENS,5,"E")
+17 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"InactivatedByIEN")=$$GET1^DIQ(409.8451,IENS,5,"I")
+18 SET REMARKSIEN=0
SET NUM=0
+19 FOR
SET REMARKSIEN=$ORDER(^SDEC(409.845,NEEDSPREFSIEN,1,NEEDSPREFSSUBIEN,1,REMARKSIEN))
if 'REMARKSIEN
QUIT
Begin DoDot:2
+20 SET NUM=NUM+1
+21 SET NEEDSANDPREFS("Patient",1,"SpecialNeedsAndPreferences",COUNT,"Remarks",NUM)=$$GET1^DIQ(409.84516,REMARKSIEN_","_IENS,.01,"E")
End DoDot:2
End DoDot:1
+22 QUIT
+23 ;
VALIDATEDFN(ERRORS,DFN) ;
+1 IF DFN=""
DO ERRLOG^SDESJSON(.ERRORS,1)
QUIT 0
+2 IF DFN'=""
IF '$DATA(^DPT(DFN,0))
DO ERRLOG^SDESJSON(.ERRORS,2)
QUIT 0
+3 QUIT 1
+4 ;
BUILDJSON(JSONRETURN,RETURN) ;
+1 NEW JSONERROR
+2 DO ENCODE^XLFJSON("RETURN","JSONRETURN")
+3 QUIT
+4 ;