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

SDESEDITNEEDPREF.m

Go to the documentation of this file.
SDESEDITNEEDPREF ;ALB/BLB - SDES EDIT SPEC NEEDS PREFS; MAY 08, 2023@6:10pm
 ;;5.3;Scheduling;**845**;Aug 13, 1993;Build 8
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ;
EDITNEEDSPREFS(JSON,NEEDSPREFS) ;
 N ERRORS,RETURN
 ;
 D VALIDATEDFN^SDESCRTNEEDPREFS(.ERRORS,$G(NEEDSPREFS("PATIENT DFN")))
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSON,.RETURN) Q
 ;
 S NEEDSPREFS("IEN")=0,NEEDSPREFS("IEN")=$O(^SDEC(409.845,"B",NEEDSPREFS("PATIENT DFN"),NEEDSPREFS("IEN")))
 I '$G(NEEDSPREFS("IEN")) D ERRLOG^SDESJSON(.ERRORS,436)
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSON,.RETURN) Q
 ;
 D VALIDATENEEDPREF(.ERRORS,.NEEDSPREFS)
 I $D(ERRORS) M RETURN=ERRORS D BUILDJSON(.JSON,.RETURN) Q
 ;
 D BUILD(.NEEDSPREFS)
 S RETURN(1)=1 D BUILDJSON(.JSON,.RETURN) Q
 Q
 ;
BUILD(NEEDSPREFS) ;
 N PATIENTFDA,PATIENTFDAERR,NEEDSPREFSFDAERR,RETURNIEN,COUNT,RETURNPREFIEN,IENS,PREFNAME,NOPREF,INTERNALPREF
 S COUNT=0,NOPREF=0
 F  S COUNT=$O(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT)) Q:'COUNT  D
 .S PREFERENCE=""
 .F  S PREFERENCE=$O(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE)) Q:PREFERENCE=""  D
 ..N NEEDSPREFSFDA,RETURNPREFIEN,REMARK,SUBIEN
 ..;
 ..S INTERNALPREF=$$SOCEXT2INT^SDESUTIL(409.8451,.01,PREFERENCE)
 ..S SUBIEN=0,SUBIEN=$O(^SDEC(409.845,NEEDSPREFS("IEN"),1,"B",INTERNALPREF,SUBIEN))
 ..S IENS=SUBIEN_","_$G(NEEDSPREFS("IEN"))_","
 ..I $G(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE))="@" D
 ...S NEEDSPREFSFDA(409.8451,IENS,.01)=$G(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE))
 ...D FILE^DIE(,"NEEDSPREFSFDA","NEEDSPREFSFDAERR") K FDA
 ..;
 ..; sub level word processing entry
 ..I $D(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE,"REMARKS")) D
 ...S REMARK(COUNT)=NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE,"REMARKS")
 ...D WP^DIE(409.8451,SUBIEN_","_NEEDSPREFS("IEN")_",",6,,"REMARK")
 Q
 ;
VALIDATENEEDPREF(ERRORS,NEEDSPREFS) ;
 N COUNT,PREFERENCE,NOPREF,INTERNALPREF
 S COUNT=0,NOPREF=0,INTERNALPREF=""
 F  S COUNT=$O(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT)) Q:'COUNT!(NOPREF=1)  D
 .S PREFERENCE=""
 .F  S PREFERENCE=$O(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE)) Q:PREFERENCE=""!(NOPREF=1)  D
 ..D VALSETOFCODES^SDESCRTNEEDPREFS(.ERRORS,PREFERENCE,409.8451,.01,"Invalid special need or preference") I $D(ERRORS) S NOPREF=1 Q
 ..I $G(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE))="",'$L($G(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE,"REMARKS"))) D ERRLOG^SDESJSON(.ERRORS,439) S NOPREF=1 Q
 ..I $G(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE))'="@",'$L($G(NEEDSPREFS("SPECIAL NEEDS AND PREFERENCES",COUNT,PREFERENCE,"REMARKS"))) D ERRLOG^SDESJSON(.ERRORS,440) S NOPREF=1 Q
 ..S INTERNALPREF=$$SOCEXT2INT^SDESUTIL(409.8451,.01,PREFERENCE)
 ..I '$D(^SDEC(409.845,NEEDSPREFS("IEN"),1,"B",INTERNALPREF)) D ERRLOG^SDESJSON(.ERRORS,437) S NOPREF=1 Q
 Q
 ;
BUILDJSON(JSONRETURN,RETURN) ;
 N JSONERROR
 D ENCODE^XLFJSON("RETURN","JSONRETURN")
 Q
 ;