source: WorldVistAEHR/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUPUTSX.m@ 1005

Last change on this file since 1005 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.0 KB
Line 
1TIUPUTSX ; SLC/MAM - Uploading Op Reports to SURGERY file #130 ;11/15/01
2 ;;1.0;TEXT INTEGRATION UTILITIES;**129**;Jun 20, 1997
3 ; External References in TIUPUTSX:
4 ; DBIA 3477 ^SRF
5LOOKUP ; Upload Lookup Method for Document Definition Operative Report
6 ; -- Requires lookup variables TIUSRCN, TIUSSN, & TIUODT --
7 ;These contain the transcribed data needed by the Lookup Method
8 ;to look up the desired target record in the SURGERY file, and to
9 ;check that the record is consistent with at least one other item
10 ;of transcribed data.
11 ;Lookup variables must be listed in the Op Report Upload Header
12 ;Definition. They are set to their corresponding transcribed values
13 ;in GETREC^TIUPUTC1.
14 ; -- Sets Y= SURGERY record CASE NUMBER (the .001 field in the SURGERY
15 ; file, #130) --
16 N DFN,TIUSR0
17 ; -- If lookup variable values are invalid or missing from
18 ; transcription, set Y = -1 and quit --
19 I $S('$D(TIUSSN):1,$G(TIUSRCN)']"":1,$G(TIUSSN)?4N:1,$G(TIUSSN)']"":1,$G(TIUODT)'>0:1,1:0) S Y=-1 G LOOKUPX
20 I TIUSSN?3N1P2N1P4N.E S TIUSSN=$TR(TIUSSN,"-/","")
21 I TIUSSN["?" S Y=-1 G LOOKUPX
22 ; -- Kill unwanted field nodes of header caption array --
23 ;After this lookup (in STUFREC^TIUPUTC), the software uses array
24 ;TIUHDR to try to file transcribed data for ALL captions which
25 ;specify field numbers in the Upload Header Definition. Since some
26 ;of these transcribed data may not be accurate, it is important NOT to
27 ;file them unless they are intended for filing. (They may be included
28 ;in the transcription for administrative purposes, or to help
29 ;look up the correct target record, but NOT BE INTENDED for filing.)
30 ;Since one can't know what captions sites may mistakenly have
31 ;attributed field numbers to, it may be best to save out any nodes
32 ;that are intended for filing, kill the whole array, and then
33 ;replace the saved nodes. For Op Reports, NO fields are intended for
34 ;filing (except the text field, of course), so we kill ALL nodes
35 ;of TIUHDR.
36 K TIUHDR
37 ; -- Get the 0-node of the SURGERY record which corresponds to
38 ; the transcribed CASE NUMBER --
39 S TIUSR0=$G(^SRF(TIUSRCN,0))
40 ; -- Get the patient that corresponds to transcribed SSN --
41 S DFN=+$$PATIENT^TIULA(TIUSSN)
42 ; -- Confirm that the patient from the SURGERY record matches
43 ; the patient from the transcribed SSN --
44 I +TIUSR0'=DFN S Y=-1 G LOOKUPX
45 ; -- Confirm that the transcribed OPERATION DATE matches the OPERATION
46 ;DATE from the SURGERY record --
47 I $$IDATE^TIULC(TIUODT)'=$P($P(TIUSR0,U,9),".") S Y=-1 G LOOKUPX
48 ; -- If the data are consistent, set Y = transcribed CASE NUMBER,
49 ;(the .001 field in the SURGERY file) --
50 S Y=TIUSRCN
51LOOKUPX Q
52FIX ; Filing Error Resolution Code for Docmt Def Operative Report
53 ; -- Called by MRT Review Filing Events option (FILERR^TIURE)
54 ; if BUFDA exists; otherwise called from an alert
55 ; (DISPLAY^TIUPEVNT). Warning: XQADATA may be left around
56 ; from a PREVIOUS alert, so don't use it's existence to
57 ; determine how this was called. --
58 ;
59 N TIUOK,TIUOUT,X,Y,SURGDA,RETRY,DIC,DWPK,TIUBUF,TIUERRDA
60 N ECHO,TIUSR0
61 ; -- Inquire to SURGERY file and let user select the correct
62 ; target record --
63 F D Q:+$G(TIUOUT)!$G(TIUOK)
64 . N DIC,X,Y,DA,DIQ
65 . W ! S DIC=130,DIC(0)="AEMNQ"
66 . S DIC("A")="Select Patient or Surgery Case Number: "
67 . D ^DIC I +Y'>0 S TIUOUT=1 W !,"OK, you can try again later" Q
68 . ; -- Show user the selected record in its entirety and get
69 . ; user's confirmation --
70 . S (DA,SURGDA)=+Y,DIQ(0)="R" ; Show case number
71 . W ! D EN^DIQ
72 . S TIUOK=$$READ^TIUU("Y","... Is this the correct Surgery record","YES","^D RECDHELP^TIUPUTSX")
73 . I $D(DIRUT) S TIUOUT=1 W !,"OK, you can try again later"
74 ; -- Quit if user has not selected and confirmed a record --
75 I '$G(TIUOK) G FIXEXIT
76 ; -- Present user with correct header data corresponding to
77 ; selected record --
78 W !!,"To file the transcribed Surgeon's Dictation into the Surgery record you have"
79 W !,"just selected, you will need to correct the upload data in its temporary"
80 W !,"storage place, and then try again to file it."
81 S TIUSR0=$G(^SRF(SURGDA,0))
82 ; -- Force $$NAME,SSN^TIULO to reinitialize pt demographics --
83 N VADM,VA,VAERR
84 W !!,"The stored upload header data for ",$$NAME^TIULS($$NAME^TIULO(+TIUSR0),"LAST,FIRST MI")
85 W !,"should be corrected to read:"
86 W !!,"PATIENT SSN:",?20,$$SSN^TIULO(+TIUSR0)
87 W !,"CASE NUMBER:",?20,SURGDA
88 W !,"OPERATION DATE:",?20,$$DATE^TIULS($P($P(TIUSR0,U,9),".")),!
89 ; -- Note: We did NOT present the patient name in the data (above)
90 ; that should be corrected. The patient name tends to be ambiguous
91 ; and is not used in the Lookup Method, so we don't wish to imply
92 ; that it IS used --
93 I '$$READ^TIUU("EA","Press RETURN to continue...") W !,"OK, you can try again later" G FIXEXIT
94 ; -- Get 8925.2 Buffer IFN and 8925.4 Upload Log Event IFN from
95 ; calling routine TIURE or TIUPEVNT --
96 I +$G(BUFDA) S TIUBUF=+BUFDA,TIUERRDA=+$G(ERRDA)
97 I '$G(BUFDA),+$G(XQADATA) S TIUBUF=+$G(XQADATA),TIUERRDA=+$P(XQADATA,";",3)
98 I '$G(TIUBUF)!'$G(TIUERRDA) W !,"Can't find stored upload record; see IRM" H 5 G FIXEXIT
99 I '$G(TIUERRDA) S TIUERRDA=0
100 ; -- Let user correct the header data in the TIU UPLOAD BUFFER file
101 ; entry, and then try (again) to file it in the SURGERY file --
102 W !!,"You may now correct the stored upload data."
103 S DIC="^TIU(8925.2,"_+TIUBUF_",""TEXT"",",DWPK=1 D EN^DIWE
104 S RETRY=$$READ^TIUU("YO","Are you ready to file this data in the Surgery file","YES","^D FILEHELP^TIUPUTSX")
105 ; -- Delete current filing error alert, mark the current error
106 ; resolved in the TIU UPLOAD LOG file, and try to file the data
107 ; from the corrected TIU UPLOAD BUFFER file entry into
108 ; the SURGERY file. (If data fails to file again, a NEW alert is
109 ; generated during that process.) --
110 I 'RETRY W !,"OK, you can try again later." G FIXEXIT
111 S ECHO=1 ; Will write "Filing Record//Resolving Error..."
112 D ALERTDEL^TIUPEVNT(TIUBUF),RESOLVE^TIUPEVNT(TIUERRDA,ECHO),FILE^TIUUPLD(TIUBUF)
113 I $G(BUFDA),'$G(TIUDONE) W !,"Old error marked resolved; new error created. New error may take several more",!,"seconds to file, and may not be within current date/time range.",! H 5 ; Feedback for MRT option
114FIXEXIT ;
115 ; -- Set variables to go to exit for DISPLAY^TIUPEVNT
116 ; or FILERR^TIURE immediately upon return from this resolve
117 ; code. (Everything they do after executing the resolve code
118 ; has been incorporated INTO THIS CODE.)
119 K EVNTDA S TIUDONE=1
120 Q
121 ;
122RECDHELP ;Help for correct record prompt
123 W !,"Is this the Surgery record you wish to upload the transcribed data into?"
124 W !,"If not, answer NO and select a different record, or enter '^' to come back",!,"and resolve the filing error later."
125 Q
126FILEHELP ;Help for retrying the upload filer prompt
127 W !,"If you are sure that you have identified the correct Surgery record, and have"
128 W !,"corrected the stored header data accordingly, then answer YES to try again"
129 W !,"to upload the data into the Surgery record."
130 W !,"If you answer NO, the corrected data will remain in temporary storage,"
131 W !,"the filing error alert will remain in place, and you can attempt to resolve"
132 W !,"the alert later."
133 Q
Note: See TracBrowser for help on using the repository browser.