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

SDESPATFLAGS.m

Go to the documentation of this file.
SDESPATFLAGS ;ALB/BWF,DJS,ANU - PATIENT FLAGS RPC ;MAR 20, 2023
 ;;5.3;Scheduling;**818,831,843,844**;DEC 1997;Build 12
 ;;Per VHA Directive 6402, this routine should not be modified
 ;
 Q
 ; Reference to PATIENT in ICR #7029
 ; Reference to DGPFAPIU in ICR #4903
 ; Reference to PRF NATIONAL FLAG in ICR #7021
 ; Reference to LOCAL FLAG in ICR #7020
 ; Reference to Patient Flag Asignment in ICR #7022
 ;
 ; RPC: SDES GET PATIENT FLAGS
 ; INPUT:
 ;       DFN - Patient IEN (required)
 ;       SDEAS - EAS Tracking number (optional)
 ;
GETFLAGS(RES,DFN,SDEAS) ;
 N PRFDATA,DFNERROR,DFNERRORS,FN,RESNUM,PRFCNT,FIEN,FPTR,PRFARRY,NARR,FDATA,PRF
 S DFNERROR=$$VALIDATEDFN^SDESPATRPC(.DFNERRORS,DFN)
 I DFNERROR S DFNERRORS("Flag",1)="" D BUILDJSON(.RES,.DFNERRORS) Q
 ;
 S FN=26.13
 S PRFARRY("FugitiveFelonFlag")=$S($$GET1^DIQ(2,DFN,1100.01,"I"):"YES",1:"NO")
 I '$D(^DGPF(FN,"C",DFN)) S PRFARRY("Flag",1)="" D BUILDJSON(.RES,.PRFARRY) Q
 S PRFCNT=0
 D LIST^DIC(26.15,,,"E",,,,,,,"FDATA","ERR"),BUILD(.PRFARRY,.FDATA,26.15,.PRFCNT) K FDATA
 D LIST^DIC(26.11,,,"E",,,,,,,"FDATA","ERR"),BUILD(.PRFARRY,.FDATA,26.11,.PRFCNT) K FDATA
 I '$D(PRFARRY("Flag")) S PRFARRY("Flag",1)=""
 D BUILDJSON(.RES,.PRFARRY)
 Q
 ;
BUILD(PRFARRY,FDATA,FN,PRFCNT) ;
 N RESNUM,FIEN,FPTR,PRFIEN,SDZ,SDFILE,SDX
 S RESNUM=0
 F  S RESNUM=$O(FDATA("DILIST",2,RESNUM)) Q:'RESNUM  D
 .S FIEN=$G(FDATA("DILIST",2,RESNUM))
 .S FPTR=FIEN_";"_$P($$ROOT^DILFD(FN),U,2)
 .;ANU - BEGIN - Quit if Status in PRF Assignment file (#26.13) is inactive
 .;Check for the patient and PRF in the PRF Assignment File.  Quit if there is no match.
 .I '$D(^DGPF(26.13,"C",DFN,FPTR)) Q
 .; Get PRF Assignment Information
 .S PRFIEN=0
 .S PRFIEN=$O(^DGPF(26.13,"C",DFN,FPTR,0))
 .I 'PRFIEN Q
 .I '$$GET1^DIQ(26.13,PRFIEN_",",.03,"I") Q
 .;Quit if Status in PRF National flag(#26.15)/PRG local flag(#26.11) file is inactive
 .S SDX=$P($G(FPTR),";",1),SDFILE=$S($G(FPTR)["26.15":26.15,1:26.11)
 .I 'SDX Q
 .I '$$GET1^DIQ(SDFILE,SDX_",",.02,"I") Q
 .;ANU - END
 .K PRFDATA
 .D GETINF^DGPFAPIH(DFN,FPTR,,,"PRFDATA") Q:'$D(PRFDATA)
 .S PRFCNT=PRFCNT+1
 .S PRFARRY("Flag",PRFCNT,"ApprovedBy")=$P($G(PRFDATA("HIST",1,"APPRVBY")),U,2)
 .S PRFARRY("Flag",PRFCNT,"Name")=$P($G(PRFDATA("FLAG")),U,2)
 .S PRFARRY("Flag",PRFCNT,"Type")=$P($G(PRFDATA("FLAGTYPE")),U,2)
 .S PRFARRY("Flag",PRFCNT,"Category")=$P($G(PRFDATA("CATEGORY")),U)
 .S PRFARRY("Flag",PRFCNT,"AssignedDate")=$$FMTISO^SDAMUTDT($P($G(PRFDATA("ASSIGNDT")),U,1))
 .S PRFARRY("Flag",PRFCNT,"OwnerSiteID")=$P($G(PRFDATA("OWNER")),U)
 .S PRFARRY("Flag",PRFCNT,"OwnerSiteName")=$P($G(PRFDATA("OWNER")),U,2)
 .S PRFARRY("Flag",PRFCNT,"OriginatingSiteID")=$P($G(PRFDATA("ORIGSITE")),U)
 .S PRFARRY("Flag",PRFCNT,"OriginatingSiteName")=$P($G(PRFDATA("ORIGSITE")),U,2)
 .S PRFARRY("Flag",PRFCNT,"ReviewDate")=$$FMTISO^SDAMUTDT($P($G(PRFDATA("REVIEWDT")),U))
 .S NARR=0 F  S NARR=$O(PRFDATA("NARR",NARR)) Q:'NARR  D
 ..S PRFARRY("Flag",PRFCNT,"Narrative",NARR)=$G(PRFDATA("NARR",NARR,0))
 Q
BUILDJSON(APPTLISTJSON,APPTLISTARRAY) ;Convert data to JSON
 N JSONERR
 S JSONERR=""
 D ENCODE^SDESJSON(.APPTLISTARRAY,.APPTLISTJSON,.JSONERR)
 Q