Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDESNEEDSPREFS

SDESNEEDSPREFS.m

Go to the documentation of this file.
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
 ;