1 | TIUGEDI1 ; SLC/MAM - Enter New ID Document Code; 11/14/00
|
---|
2 | ;;1.0;TEXT INTEGRATION UTILITIES;**100**;Jun 20, 1997
|
---|
3 | ; New rtn for ID notes
|
---|
4 | ; 3/2/00 moved GETRECG from TIUGEDIT to TIUGEDI1
|
---|
5 | GETRECG(DFN,TIU,TIUTYP,TIUDPRM,TIUNEW,EDIT,DADDA) ; Get record
|
---|
6 | ;for ID entry.
|
---|
7 | ; Returns DA: new docmt for user to continue entering, or
|
---|
8 | ;existing docmt for user to edit, or just link, or addend.
|
---|
9 | ; Requires array TIU. References TIU("VSTR") = LOC;VDT;VTYP
|
---|
10 | ; TIU("VISIT") = Visit File IFN
|
---|
11 | ; TIU("LOC")
|
---|
12 | ; TIU("VLOC")
|
---|
13 | ; TIU("STOP") = stop code
|
---|
14 | ; Requires array TIUTYP as in MAIN
|
---|
15 | ; Passes back flags:
|
---|
16 | ; TIUNEW = 1 if good docmt is returned and it is new
|
---|
17 | ; = 0 if returned docmt already existed, timeout, etc
|
---|
18 | ; EDIT = 1 to open DA for edit (already know Person can edit)
|
---|
19 | ; = 0 to forget the edit
|
---|
20 | ; Requires DADDA = IFN of docmt DA will be added to.
|
---|
21 | N DA,MULTOK,TLFULL,DALKABLE,YESDOIT
|
---|
22 | ;-- Get parameters for selected title, set TLFULL: --
|
---|
23 | ; TLFULL: Already have max # entries on this title/pt/vst
|
---|
24 | ; MULTOK: More than ONE record/visit is OK
|
---|
25 | D DOCPRM^TIULC1(TIUTYP,.TIUDPRM) S MULTOK=+$P($G(TIUDPRM(0)),U,10)
|
---|
26 | S (TIUNEW,EDIT,TLFULL)=0
|
---|
27 | I 'MULTOK,$$EXIST^TIUEDI3(DFN,TIUTYP,TIU("VSTR")) S TLFULL=1
|
---|
28 | ; -- Find existing docmts for proposed title/patient/visit
|
---|
29 | ; which are linkable to DADDA: --
|
---|
30 | S DALKABLE=$$EXISTLNK(DFN,TIUTYP,TIU("VSTR"),DUZ,DADDA)
|
---|
31 | ; -- If there are NO such existing docmts,
|
---|
32 | ; let user create new or tell user they can't, quit: --
|
---|
33 | I 'DALKABLE D G GETX
|
---|
34 | . I 'TLFULL S DA=$$CREATREC^TIUEDI3(DFN,.TIU,TIUTYP(1)),TIUNEW=1 Q
|
---|
35 | . I TLFULL W !!,"There is already a ",$P(TIUTYP(1),U,3),".",!,"Only ONE record of this type per Visit is allowed...",! H 1 Q
|
---|
36 | ; -- There IS such a docmt. --
|
---|
37 | ; -- If docmt is already linked, and user can edit,
|
---|
38 | ; ask if user wants to create new note anyway: --
|
---|
39 | I $G(^TIU(8925,DALKABLE,21))=DADDA D G GETX
|
---|
40 | . W !,"The note already has an ID entry you can edit with that title and visit"
|
---|
41 | . S YESDOIT=$$READ^TIUU("Y","Would you like to create a new entry anyway","NO")
|
---|
42 | . I YESDOIT S DA=$$CREATREC^TIUEDI3(DFN,.TIU,TIUTYP(1)),TIUNEW=1 Q
|
---|
43 | . W !,"Opening the existing entry" S DA=DALKABLE,EDIT=1
|
---|
44 | ; -- If docmt is NOT already linked, create new,
|
---|
45 | ; or edit existing, or just link existing: --
|
---|
46 | W !,"You already have a document you can link for that patient, title, and visit."
|
---|
47 | S YESDOIT=$$READ^TIUU("Y","Would you like to create a new entry anyway","NO")
|
---|
48 | I $D(DUOUT)!$D(DTOUT)!$D(DIROUT) G GETX
|
---|
49 | I YESDOIT S DA=$$CREATREC^TIUEDI3(DFN,.TIU,TIUTYP(1)) S TIUNEW=1 G GETX
|
---|
50 | ; -- If user says, no don't create, then try edit: --
|
---|
51 | N CANDO S CANDO=+$$CANDO^TIULP(DALKABLE,"EDIT RECORD")
|
---|
52 | I CANDO W !,"Opening the existing entry" S DA=DALKABLE,EDIT=1 G GETX
|
---|
53 | ; -- If user can't edit, just return it for linking: --
|
---|
54 | I 'CANDO D G GETX
|
---|
55 | . S DA=DALKABLE
|
---|
56 | GETX ;
|
---|
57 | I TIUNEW,'$G(DA) W !,"No new entry created" H 2 S TIUNEW=0
|
---|
58 | Q +$G(DA)
|
---|
59 | ;
|
---|
60 | EXISTLNK(DFN,TIUTYP,TIUVSTR,PERSON,DADDA) ; If a docmt PERSON
|
---|
61 | ;can LINK already EXISTS for the given patient, title, and visit,
|
---|
62 | ;then return it. If there are more than one, get the smallest DA.
|
---|
63 | ; Receives TIUVSTR = LOC;VDT;VTYP
|
---|
64 | ; Needs TIUTYP = title DA
|
---|
65 | ; Needs DADDA = IFN of docmt DA will be added to.
|
---|
66 | N REQUEST,DA,TIUI,CANLINK,DALKDAD
|
---|
67 | I '$G(PERSON) S PERSON=DUZ
|
---|
68 | S (REQUEST,TIUI,DA)=0
|
---|
69 | LOOP ; -- Find existing docmt for given patient, title, & visit:--
|
---|
70 | F S TIUI=+$O(^TIU(8925,"APTLD",DFN,TIUTYP,TIUVSTR,TIUI)) Q:'TIUI D Q:REQUEST Q:DA
|
---|
71 | . ; -- If TIUI is bad, reject it and keep looking:
|
---|
72 | . I '$D(^TIU(8925,TIUI,0)) D Q
|
---|
73 | . . K ^TIU(8925,"APTLD",DFN,TIUTYP,TIUVSTR,TIUI)
|
---|
74 | . ; -- If TIUI has requesting package (e.g. Consults),
|
---|
75 | . ; then reject it and quit looking: --
|
---|
76 | . I +$P($G(^TIU(8925,TIUI,14)),U,5) S REQUEST=1 Q ; **22**
|
---|
77 | . N CANLINK S CANLINK=+$$CANDO^TIULP(TIUI,"ATTACH TO ID NOTE",PERSON)
|
---|
78 | . ; -- If person can't link it, keep looking: --
|
---|
79 | . I 'CANLINK Q
|
---|
80 | . ; -- If already linked somewhere else, keep looking: --
|
---|
81 | . S DALKDAD=$G(^TIU(8925,TIUI,21))
|
---|
82 | . I DALKDAD,DALKDAD'=DADDA Q
|
---|
83 | . ; -- If already linked to dad, but can't edit, keep looking: --
|
---|
84 | . I DALKDAD,'$$CANDO^TIULP(TIUI,"EDIT RECORD") Q
|
---|
85 | . ; -- If already linked to dad & can edit, return it: --
|
---|
86 | . I DALKDAD S DA=TIUI Q
|
---|
87 | . ; -- If not already linked, return it: --
|
---|
88 | . S DA=TIUI
|
---|
89 | EXISTLX ;
|
---|
90 | Q +$G(DA)
|
---|