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

DGPFAPI1.m

Go to the documentation of this file.
  1. DGPFAPI1 ;ALB/RBS - PRF EXTERNAL API'S ; 9/27/06 3:00pm
  1. ;;5.3;Registration;**554,650,1015**;Aug 13, 1993;Build 21
  1. ;
  1. Q ;no direct entry
  1. ;
  1. GETHTIU(DGDFN,DGTITLE,DGHTIU) ;retrieve PRF/TIU PN link Assignment data
  1. ;This function is used to return a patient's ASSIGNMENT (active or
  1. ;inactive) based on the TIU PN title. If an ASSIGNMENT is found
  1. ;then all ASSIGNMENT HISTORY records will be returned.
  1. ;If the request is not from the Owner Site of the PRF Assignment,
  1. ;no data is returned.
  1. ;The TIU Progress Note Title IEN will be used to search for the
  1. ;patient assignment that is linked to the associated record flag.
  1. ;
  1. ; Associated DBIA: #4383 - DGPF ASSIGNMENT LINK TIU PN
  1. ;
  1. ; Input:
  1. ; DGDFN - [Required] IEN of PATIENT (#2) file
  1. ; DGTITLE - [Required] IEN of TIU DOCUMENT DEFINITION (#8925.1) file
  1. ; DGHTIU - [Optional] - default name is "DGPFHTIU"
  1. ; (Closed Root (local or global) array of return values)
  1. ;
  1. ; Output:
  1. ; Function result - returns 1 on success
  1. ; - returns two piece string on failure
  1. ; Format: 0^error text generated from EZBLD^DIALOG
  1. ;
  1. ; DGHTIU() - Array, passed by closed root reference.
  1. ; If this function is successful, this array will
  1. ; contain the PRF/TIU PN link Assignment data where
  1. ; the Subscript field value equals:
  1. ; Internal Value^External Value
  1. ; Note: The "HISTORY" subscript level will contain a
  1. ; unique node for each PRF Assignment History record
  1. ; associated with the Assignment where nn = a unique
  1. ; number for each History record.
  1. ;
  1. ; Subscript Field Name Field #/File #
  1. ; ----------------------- ----------- ------------
  1. ; "ASSIGNIEN" NUMBER (.001)/(#26.13)
  1. ; "FLAG" FLAG NAME (.02)/(#26.13)
  1. ; "HISTORY" # OF HISTORY RECORDS N/A
  1. ; "HISTORY",nn,"ACTION" ACTION (.03)/(#26.14)
  1. ; "HISTORY",nn,"DATETIME") DATE/TIME (.02)/(#26.14)
  1. ; "HISTORY",nn,"HISTIEN") NUMBER (.001)/(#26.14)
  1. ; "HISTORY",nn,"TIUIEN") TIU PN LINK (.06)/(#26.14)
  1. ;
  1. N DGAIEN ;ien of record flag assignment in (#26.13) file
  1. N DGDIALOG ;failure reason generated from EZBLD^DIALOG
  1. N DGFIEN ;variable pointer to #26.11 or #26.15 ie. "1;DGPF(26.15,"
  1. N DGFLAG ;flag name
  1. N DGHIEN ;ien of history record in (#26.14) file
  1. N DGHIENS ;array of all assignment history IEN's
  1. N DGPFA ;flag assignment array
  1. N DGPFAH ;flag assignment history array
  1. N DGRSLT ;function result
  1. N DGTHCNT ;"nn"=number of history records returned
  1. ;
  1. S DGDFN=+$G(DGDFN)
  1. S DGTITLE=+$G(DGTITLE)
  1. ;
  1. ;setup return array
  1. S DGHTIU=$G(DGHTIU)
  1. I DGHTIU']"" S DGHTIU="DGPFHTIU" ;setup default array name
  1. K @DGHTIU ;Kill/initialize work array
  1. ;
  1. S DGRSLT=0
  1. ;
  1. ;get IEN variable pointer of National or Local flag
  1. S DGFIEN=$P($$FNDTITLE(DGTITLE),U,1) ;strip off flag name
  1. ;
  1. I '$G(DGFIEN) S DGDIALOG=$$EZBLD^DIALOG(261107) ;no flag link
  1. ;
  1. ;if flag is assoc with TIU Progres Note Title (quit on failure)
  1. I $G(DGFIEN) D
  1. . ;
  1. . ;get IEN of assignment linked to flag linked to TIU PN Title
  1. . S DGAIEN=$$FNDASGN^DGPFAA(DGDFN,DGFIEN)
  1. . I '$G(DGAIEN) S DGDIALOG=$$EZBLD^DIALOG(261108) Q
  1. . ;
  1. . ;get all assignment data for patient
  1. . I '$$GETASGN^DGPFAA(DGAIEN,.DGPFA) S DGDIALOG=$$EZBLD^DIALOG(261102) Q
  1. . ;
  1. . ;check for owner site of assignment
  1. . I '$$ISDIV^DGPFUT($P(DGPFA("OWNER"),U)) S DGDIALOG=$$EZBLD^DIALOG(261103) Q
  1. . ;
  1. . ;get all history ien's
  1. . I '$$GETALL^DGPFAAH(DGAIEN,.DGHIENS) S DGDIALOG=$$EZBLD^DIALOG(261101) Q
  1. . ;
  1. . S DGHIEN="",DGTHCNT=0
  1. . ;
  1. . ;loop all assignment history ien's
  1. . F S DGHIEN=$O(DGHIENS(DGHIEN)) Q:DGHIEN="" D Q:$D(DGDIALOG)
  1. . . K DGPFAH
  1. . . ;get assignment history record
  1. . . I '$$GETHIST^DGPFAAH(DGHIEN,.DGPFAH) S DGDIALOG=$$EZBLD^DIALOG(261101),DGTHCNT=0 Q
  1. . . ;
  1. . . S DGTHCNT=DGTHCNT+1
  1. . . S @DGHTIU@("HISTORY",DGTHCNT,"ACTION")=$G(DGPFAH("ACTION"))
  1. . . S @DGHTIU@("HISTORY",DGTHCNT,"DATETIME")=$G(DGPFAH("ASSIGNDT"))
  1. . . S @DGHTIU@("HISTORY",DGTHCNT,"HISTIEN")=DGHIEN_U_DGHIEN
  1. . . S @DGHTIU@("HISTORY",DGTHCNT,"TIUIEN")=$G(DGPFAH("TIULINK"))
  1. . ;
  1. . Q:$D(DGDIALOG) ;stop on error
  1. . ;
  1. . I DGTHCNT D
  1. . . S @DGHTIU@("ASSIGNIEN")=DGAIEN_U_$P($G(DGPFA("DFN")),U,2)
  1. . . S @DGHTIU@("FLAG")=$G(DGPFA("FLAG"))
  1. . . S @DGHTIU@("HISTORY")=DGTHCNT
  1. . ;
  1. . S DGRSLT=1 ;success
  1. ;
  1. ;if failure delete return array
  1. I $D(DGDIALOG) K @DGHTIU
  1. ;
  1. Q $S(DGRSLT:1,1:DGRSLT_"^"_$G(DGDIALOG))
  1. ;
  1. FNDTITLE(DGTITLE) ;retrieve IEN of associated PRF (National or Local) Flag
  1. ;This function returns the IEN and Name of the National or Local flag
  1. ;that is associated with the TIU Progress Note Title.
  1. ;
  1. ; Input:
  1. ; DGTITLE - [Required] IEN of TIU DOCUMENT DEFINITION (#8925.1) file
  1. ;
  1. ; Output:
  1. ; Function Value - returns two piece ^ string on failure or success
  1. ; On Failure - 0^error text generated from EZBLD^DIALOG
  1. ; On Success - IEN^External Flag Name
  1. ; [example: 1;DGPF(26.15,^BEHAVIORAL]
  1. ; [Note: "1;DGPF(26.15," is a variable pointer]
  1. ;
  1. S DGTITLE=+$G(DGTITLE)
  1. ;
  1. N DGDIALOG ;failure reason
  1. N DGFLAG ;flag name
  1. N DGIEN ;ien of flag
  1. ;
  1. ; search for Local Flag
  1. I $D(^DGPF(26.11,"ATIU",DGTITLE)) D
  1. . S DGFLAG=$O(^DGPF(26.11,"ATIU",DGTITLE,""))
  1. . I DGFLAG]"" D
  1. . . S DGIEN=$O(^DGPF(26.11,"ATIU",DGTITLE,DGFLAG,0))
  1. . . I '$D(^DGPF(26.11,DGIEN,0)) K DGIEN Q
  1. . . S:$G(DGIEN) DGIEN=DGIEN_";DGPF(26.11,^"_DGFLAG ;add flag name
  1. ;
  1. ; search for National Flag - (if Title not found in Local Flag file)
  1. I '$G(DGIEN),$D(^DGPF(26.15,"ATIU",DGTITLE)) D
  1. . S DGFLAG=$O(^DGPF(26.15,"ATIU",DGTITLE,""))
  1. . I DGFLAG]"" D
  1. . . S DGIEN=$O(^DGPF(26.15,"ATIU",DGTITLE,DGFLAG,0))
  1. . . I '$D(^DGPF(26.15,DGIEN,0)) K DGIEN Q
  1. . . S:$G(DGIEN) DGIEN=DGIEN_";DGPF(26.15,^"_DGFLAG ;add flag name
  1. ;
  1. I '$G(DGIEN) S DGDIALOG=$$EZBLD^DIALOG(261107)
  1. ;
  1. Q $S($G(DGIEN)>0:DGIEN,1:"0^"_$G(DGDIALOG))
  1. ;
  1. ;This function returns the IEN of a patient's record flag assignment
  1. ;history record that is linked to a specific TIU Progress Note.
  1. ;
  1. ; Associated DBIA: #4383 - DGPF ASSIGNMENT LINK TIU PN
  1. ;
  1. ; Input:
  1. ; DGTIUIEN - [Required] IEN of TIU DOCUMENT (#8925) file
  1. ;
  1. ; Output:
  1. ; Function result - returns IEN of linked history record on success
  1. ; - "0" if no link found
  1. ;
  1. Q +$O(^DGPF(26.14,"ATIUPN",+$G(DGTIUIEN),0))