1 | DGPFAPI1 ;ALB/RBS - PRF EXTERNAL API'S ; 9/27/06 3:00pm
|
---|
2 | ;;5.3;Registration;**554,650**;Aug 13, 1993;Build 3
|
---|
3 | ;
|
---|
4 | Q ;no direct entry
|
---|
5 | ;
|
---|
6 | GETHTIU(DGDFN,DGTITLE,DGHTIU) ;retrieve PRF/TIU PN link Assignment data
|
---|
7 | ;This function is used to return a patient's ASSIGNMENT (active or
|
---|
8 | ;inactive) based on the TIU PN title. If an ASSIGNMENT is found
|
---|
9 | ;then all ASSIGNMENT HISTORY records will be returned.
|
---|
10 | ;If the request is not from the Owner Site of the PRF Assignment,
|
---|
11 | ;no data is returned.
|
---|
12 | ;The TIU Progress Note Title IEN will be used to search for the
|
---|
13 | ;patient assignment that is linked to the associated record flag.
|
---|
14 | ;
|
---|
15 | ; Associated DBIA: #4383 - DGPF ASSIGNMENT LINK TIU PN
|
---|
16 | ;
|
---|
17 | ; Input:
|
---|
18 | ; DGDFN - [Required] IEN of PATIENT (#2) file
|
---|
19 | ; DGTITLE - [Required] IEN of TIU DOCUMENT DEFINITION (#8925.1) file
|
---|
20 | ; DGHTIU - [Optional] - default name is "DGPFHTIU"
|
---|
21 | ; (Closed Root (local or global) array of return values)
|
---|
22 | ;
|
---|
23 | ; Output:
|
---|
24 | ; Function result - returns 1 on success
|
---|
25 | ; - returns two piece string on failure
|
---|
26 | ; Format: 0^error text generated from EZBLD^DIALOG
|
---|
27 | ;
|
---|
28 | ; DGHTIU() - Array, passed by closed root reference.
|
---|
29 | ; If this function is successful, this array will
|
---|
30 | ; contain the PRF/TIU PN link Assignment data where
|
---|
31 | ; the Subscript field value equals:
|
---|
32 | ; Internal Value^External Value
|
---|
33 | ; Note: The "HISTORY" subscript level will contain a
|
---|
34 | ; unique node for each PRF Assignment History record
|
---|
35 | ; associated with the Assignment where nn = a unique
|
---|
36 | ; number for each History record.
|
---|
37 | ;
|
---|
38 | ; Subscript Field Name Field #/File #
|
---|
39 | ; ----------------------- ----------- ------------
|
---|
40 | ; "ASSIGNIEN" NUMBER (.001)/(#26.13)
|
---|
41 | ; "FLAG" FLAG NAME (.02)/(#26.13)
|
---|
42 | ; "HISTORY" # OF HISTORY RECORDS N/A
|
---|
43 | ; "HISTORY",nn,"ACTION" ACTION (.03)/(#26.14)
|
---|
44 | ; "HISTORY",nn,"DATETIME") DATE/TIME (.02)/(#26.14)
|
---|
45 | ; "HISTORY",nn,"HISTIEN") NUMBER (.001)/(#26.14)
|
---|
46 | ; "HISTORY",nn,"TIUIEN") TIU PN LINK (.06)/(#26.14)
|
---|
47 | ;
|
---|
48 | N DGAIEN ;ien of record flag assignment in (#26.13) file
|
---|
49 | N DGDIALOG ;failure reason generated from EZBLD^DIALOG
|
---|
50 | N DGFIEN ;variable pointer to #26.11 or #26.15 ie. "1;DGPF(26.15,"
|
---|
51 | N DGFLAG ;flag name
|
---|
52 | N DGHIEN ;ien of history record in (#26.14) file
|
---|
53 | N DGHIENS ;array of all assignment history IEN's
|
---|
54 | N DGPFA ;flag assignment array
|
---|
55 | N DGPFAH ;flag assignment history array
|
---|
56 | N DGRSLT ;function result
|
---|
57 | N DGTHCNT ;"nn"=number of history records returned
|
---|
58 | ;
|
---|
59 | S DGDFN=+$G(DGDFN)
|
---|
60 | S DGTITLE=+$G(DGTITLE)
|
---|
61 | ;
|
---|
62 | ;setup return array
|
---|
63 | S DGHTIU=$G(DGHTIU)
|
---|
64 | I DGHTIU']"" S DGHTIU="DGPFHTIU" ;setup default array name
|
---|
65 | K @DGHTIU ;Kill/initialize work array
|
---|
66 | ;
|
---|
67 | S DGRSLT=0
|
---|
68 | ;
|
---|
69 | ;get IEN variable pointer of National or Local flag
|
---|
70 | S DGFIEN=$P($$FNDTITLE(DGTITLE),U,1) ;strip off flag name
|
---|
71 | ;
|
---|
72 | I '$G(DGFIEN) S DGDIALOG=$$EZBLD^DIALOG(261107) ;no flag link
|
---|
73 | ;
|
---|
74 | ;if flag is assoc with TIU Progres Note Title (quit on failure)
|
---|
75 | I $G(DGFIEN) D
|
---|
76 | . ;
|
---|
77 | . ;get IEN of assignment linked to flag linked to TIU PN Title
|
---|
78 | . S DGAIEN=$$FNDASGN^DGPFAA(DGDFN,DGFIEN)
|
---|
79 | . I '$G(DGAIEN) S DGDIALOG=$$EZBLD^DIALOG(261108) Q
|
---|
80 | . ;
|
---|
81 | . ;get all assignment data for patient
|
---|
82 | . I '$$GETASGN^DGPFAA(DGAIEN,.DGPFA) S DGDIALOG=$$EZBLD^DIALOG(261102) Q
|
---|
83 | . ;
|
---|
84 | . ;check for owner site of assignment
|
---|
85 | . I '$$ISDIV^DGPFUT($P(DGPFA("OWNER"),U)) S DGDIALOG=$$EZBLD^DIALOG(261103) Q
|
---|
86 | . ;
|
---|
87 | . ;get all history ien's
|
---|
88 | . I '$$GETALL^DGPFAAH(DGAIEN,.DGHIENS) S DGDIALOG=$$EZBLD^DIALOG(261101) Q
|
---|
89 | . ;
|
---|
90 | . S DGHIEN="",DGTHCNT=0
|
---|
91 | . ;
|
---|
92 | . ;loop all assignment history ien's
|
---|
93 | . F S DGHIEN=$O(DGHIENS(DGHIEN)) Q:DGHIEN="" D Q:$D(DGDIALOG)
|
---|
94 | . . K DGPFAH
|
---|
95 | . . ;get assignment history record
|
---|
96 | . . I '$$GETHIST^DGPFAAH(DGHIEN,.DGPFAH) S DGDIALOG=$$EZBLD^DIALOG(261101),DGTHCNT=0 Q
|
---|
97 | . . ;
|
---|
98 | . . S DGTHCNT=DGTHCNT+1
|
---|
99 | . . S @DGHTIU@("HISTORY",DGTHCNT,"ACTION")=$G(DGPFAH("ACTION"))
|
---|
100 | . . S @DGHTIU@("HISTORY",DGTHCNT,"DATETIME")=$G(DGPFAH("ASSIGNDT"))
|
---|
101 | . . S @DGHTIU@("HISTORY",DGTHCNT,"HISTIEN")=DGHIEN_U_DGHIEN
|
---|
102 | . . S @DGHTIU@("HISTORY",DGTHCNT,"TIUIEN")=$G(DGPFAH("TIULINK"))
|
---|
103 | . ;
|
---|
104 | . Q:$D(DGDIALOG) ;stop on error
|
---|
105 | . ;
|
---|
106 | . I DGTHCNT D
|
---|
107 | . . S @DGHTIU@("ASSIGNIEN")=DGAIEN_U_$P($G(DGPFA("DFN")),U,2)
|
---|
108 | . . S @DGHTIU@("FLAG")=$G(DGPFA("FLAG"))
|
---|
109 | . . S @DGHTIU@("HISTORY")=DGTHCNT
|
---|
110 | . ;
|
---|
111 | . S DGRSLT=1 ;success
|
---|
112 | ;
|
---|
113 | ;if failure delete return array
|
---|
114 | I $D(DGDIALOG) K @DGHTIU
|
---|
115 | ;
|
---|
116 | Q $S(DGRSLT:1,1:DGRSLT_"^"_$G(DGDIALOG))
|
---|
117 | ;
|
---|
118 | FNDTITLE(DGTITLE) ;retrieve IEN of associated PRF (National or Local) Flag
|
---|
119 | ;This function returns the IEN and Name of the National or Local flag
|
---|
120 | ;that is associated with the TIU Progress Note Title.
|
---|
121 | ;
|
---|
122 | ; Input:
|
---|
123 | ; DGTITLE - [Required] IEN of TIU DOCUMENT DEFINITION (#8925.1) file
|
---|
124 | ;
|
---|
125 | ; Output:
|
---|
126 | ; Function Value - returns two piece ^ string on failure or success
|
---|
127 | ; On Failure - 0^error text generated from EZBLD^DIALOG
|
---|
128 | ; On Success - IEN^External Flag Name
|
---|
129 | ; [example: 1;DGPF(26.15,^BEHAVIORAL]
|
---|
130 | ; [Note: "1;DGPF(26.15," is a variable pointer]
|
---|
131 | ;
|
---|
132 | S DGTITLE=+$G(DGTITLE)
|
---|
133 | ;
|
---|
134 | N DGDIALOG ;failure reason
|
---|
135 | N DGFLAG ;flag name
|
---|
136 | N DGIEN ;ien of flag
|
---|
137 | ;
|
---|
138 | ; search for Local Flag
|
---|
139 | I $D(^DGPF(26.11,"ATIU",DGTITLE)) D
|
---|
140 | . S DGFLAG=$O(^DGPF(26.11,"ATIU",DGTITLE,""))
|
---|
141 | . I DGFLAG]"" D
|
---|
142 | . . S DGIEN=$O(^DGPF(26.11,"ATIU",DGTITLE,DGFLAG,0))
|
---|
143 | . . I '$D(^DGPF(26.11,DGIEN,0)) K DGIEN Q
|
---|
144 | . . S:$G(DGIEN) DGIEN=DGIEN_";DGPF(26.11,^"_DGFLAG ;add flag name
|
---|
145 | ;
|
---|
146 | ; search for National Flag - (if Title not found in Local Flag file)
|
---|
147 | I '$G(DGIEN),$D(^DGPF(26.15,"ATIU",DGTITLE)) D
|
---|
148 | . S DGFLAG=$O(^DGPF(26.15,"ATIU",DGTITLE,""))
|
---|
149 | . I DGFLAG]"" D
|
---|
150 | . . S DGIEN=$O(^DGPF(26.15,"ATIU",DGTITLE,DGFLAG,0))
|
---|
151 | . . I '$D(^DGPF(26.15,DGIEN,0)) K DGIEN Q
|
---|
152 | . . S:$G(DGIEN) DGIEN=DGIEN_";DGPF(26.15,^"_DGFLAG ;add flag name
|
---|
153 | ;
|
---|
154 | I '$G(DGIEN) S DGDIALOG=$$EZBLD^DIALOG(261107)
|
---|
155 | ;
|
---|
156 | Q $S($G(DGIEN)>0:DGIEN,1:"0^"_$G(DGDIALOG))
|
---|
157 | ;
|
---|
158 | GETLINK(DGTIUIEN) ;get linked assignment history ien
|
---|
159 | ;This function returns the IEN of a patient's record flag assignment
|
---|
160 | ;history record that is linked to a specific TIU Progress Note.
|
---|
161 | ;
|
---|
162 | ; Associated DBIA: #4383 - DGPF ASSIGNMENT LINK TIU PN
|
---|
163 | ;
|
---|
164 | ; Input:
|
---|
165 | ; DGTIUIEN - [Required] IEN of TIU DOCUMENT (#8925) file
|
---|
166 | ;
|
---|
167 | ; Output:
|
---|
168 | ; Function result - returns IEN of linked history record on success
|
---|
169 | ; - "0" if no link found
|
---|
170 | ;
|
---|
171 | Q +$O(^DGPF(26.14,"ATIUPN",+$G(DGTIUIEN),0))
|
---|