source: WorldVistAEHR/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUPXAP3.m@ 1259

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

initial load of WorldVistAEHR

File size: 1.9 KB
Line 
1TIUPXAP3 ;SLC/RMO - Link Document to Visit API ;10/24/03@1000
2 ;;1.0;TEXT INTEGRATION UTILITIES;**179**;Jun 20, 1997
3 ;
4LNKVST(TIUDA,TIUVSIT) ;Entry point to link a document to an existing visit
5 ; Input -- TIUDA TIU Document file (#8925) IEN
6 ; Output -- 1=Successful and 0=Failure
7 ; TIUVSIT Visit file (#9000010) IEN
8 N OKF,TIUMVSTF
9 ;
10 ;Check if document needs to be linked to a visit
11 I $D(^TIU(8925,TIUDA,0)),$P(^(0),U,3)'>0 D
12 . ;Get existing visit to associate with document
13 . D GETVST(TIUDA,.TIUVSIT,.TIUMVSTF)
14 . ;If only one visit update the document with the visit
15 . I $G(TIUVSIT)>0,'$G(TIUMVSTF) D
16 . . I $$UPDVST^TIUPXAP2(TIUDA,TIUVSIT) S OKF=1
17 Q +$G(OKF)
18 ;
19GETVST(TIUDA,TIUVSIT,TIUMVSTF) ;Get visit to associate with document
20 ; Input -- TIUDA TIU Document file (#8925) IEN
21 ; Output -- TIUVSIT Visit file (#9000010) IEN
22 ; TIUMVSTF Multiple Visit Flag
23 ; 1=Multiple Visits
24 ;
25 N TIUD0,TIUDFN,TIUEDT,TIUHL,TIUVSITS,TIUVSTR
26 ;
27 ;Set variables
28 S TIUD0=$G(^TIU(8925,TIUDA,0))
29 S TIUDFN=$P(TIUD0,U,2),TIUEDT=$P(TIUD0,U,7)
30 S TIUHL=$P($G(^TIU(8925,TIUDA,12)),U,11)
31 S TIUVSTR=TIUHL_";"_TIUEDT_";"_$P(TIUD0,U,13)
32 ;
33 ;Check if document is an addendum, if it is use visit of parent
34 I +$$ISADDNDM^TIULC1(TIUDA) D G GETVSTQ
35 . I $D(^TIU(8925,+$P(TIUD0,U,6),0)),$P(^(0),U,3)>0 S TIUVSIT=$P(^(0),U,3)
36 ;
37 ;Check if a document has already been entered for the Vstring,
38 ;if it has use the visit in the AVSTRV cross-reference
39 I +$G(TIUVSTR),+$O(^TIU(8925,"AVSTRV",+TIUDFN,TIUVSTR,0))>0 D G GETVSTQ:$G(TIUVSIT)>0
40 . S TIUVSIT=+$O(^TIU(8925,"AVSTRV",+TIUDFN,TIUVSTR,0))
41 . I $P($G(^AUPNVSIT(+TIUVSIT,0)),U,5)'=TIUDFN S TIUVSIT=""
42 ;
43 ;Check PCE for a visit
44 S TIUVSITS=$$GETENC^PXAPI(TIUDFN,TIUEDT,TIUHL)
45 I TIUVSITS>0 S TIUVSIT=+TIUVSITS
46 ;
47 ;Set a flag if multiple visits
48 I $P(TIUVSITS,U,2)'="" S TIUMVSTF=1
49GETVSTQ K ^TMP("PXKENC",$J)
50 Q
Note: See TracBrowser for help on using the repository browser.