source: WorldVistAEHR/trunk/r/ENROLLMENT_APPLICATION_SYSTEM-EAS/EASWTAPI.m@ 1211

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

initial load of WorldVistAEHR

File size: 2.2 KB
Line 
1EASWTAPI ; ALB/SCK - ENROLLMENT DATE API - ; 7-12-2002
2 ;;1.0;ENROLLMENT APPLICATION SYSTEM;**17**;MAR 15, 2001
3 ;
4ENROLL(DFN) ; Find enrollement date for patient
5 ; Input
6 ; DFN - IEN of the patient file
7 ;
8 ; Output
9 ; 0 - If an enrollment date cannot be determined
10 ; 1^IEN^date^type - If an enrollment date can be determined
11 ;
12 ; 1 - Flag that an enrollment date was determined
13 ; IEN - IEN of the PATIENT ENROLLMENT File entry returned
14 ; date - Date in FileMan internal format
15 ; type - "E" for an ENROLLMENT DATE
16 ; "A" for an ENROLLMENT APPLICATION DATE
17 ;
18 N RSLT,EAIEN,EAIEN1,EAX,DONE,EAVER,EASTAT,EANODE
19 ;
20 S RSLT=0
21 S DFN=$G(DFN) I 'DFN Q RSLT
22 I '$D(^DPT(DFN,0)) Q RSLT
23 ;
24 ;; Retrieve last enrollment record for patient
25 S EAIEN="Z",EAIEN=$O(^DGEN(27.11,"C",DFN,EAIEN),-1)
26 I 'EAIEN Q RSLT
27 ;; If last enrollment record is Cancel/Decline, return 0
28 I $$GET1^DIQ(27.11,EAIEN,.04,"I")=7 Q $G(RSLT)
29 ;
30 S RSLT=$$VERIFY(EAIEN)
31 I 'RSLT S RSLT=$$UNVERIFY(EAIEN)
32 Q RSLT
33 ;
34VERIFY(EAIEN) ; Find latest verified record
35 N EAX,EANODE,EAVER,RSLT,DONE
36 ;
37 S EANODE=EAIEN_"~"_$G(^DGEN(27.11,EAIEN,0))
38 S RSLT=0
39 S EAVER=$$SEARCH(EANODE,2)
40 I +$P($G(EAVER),"~",1)>0 D
41 . S RSLT="1^"_$P(EAVER,"~",1)_U_$P(EAVER,U,10)_"^E"
42 Q RSLT
43 ;
44UNVERIFY(EAIEN) ; Find an un-verified record
45 N EAX,EANODE,EAUNV,RSLT,DONE
46 ;
47 S RSLT=0
48 S EANODE=EAIEN_"~"_$G(^DGEN(27.11,EAIEN,0))
49 S EAUNV=$$SEARCH(EANODE,1)
50 I +$P($G(EAUNV),"~",1)>0 D
51 . S RSLT="1^"_$P(EAUNV,"~",1)_U_$P($P(EAUNV,"~",2),U,1)_"^A"
52 Q RSLT
53 ;
54SEARCH(EANODE,STAT) ; Search for enrollment record
55 N EACUR,DONE,EAX,EAIEN
56 ;
57 I $P(EANODE,U,4)=STAT S EACUR=EANODE
58 F EAX=1:1 D Q:$G(DONE)
59 . S EAIEN=$P(EANODE,U,9)
60 . I 'EAIEN S DONE=1 Q
61 . S EANODE=$G(^DGEN(27.11,EAIEN,0))
62 . I $P(EANODE,U,4)=STAT S EACUR=EAIEN_"~"_$G(^DGEN(27.11,EAIEN,0))
63 . I $P(EANODE,U,4)=7 S DONE=1
64 Q $G(EACUR)
65 ;
66CHECK(DFN) ;
67 N EAX,EAIEN,EANODE,DONE
68 ;
69 S DFN=$G(DFN) I 'DFN Q
70 Q:'$D(^DPT(DFN,0))
71 ;
72 S EAIEN="Z"
73 S EAIEN=$O(^DGEN(27.11,"C",DFN,EAIEN),-1)
74 Q:'EAIEN
75 S EANODE=$G(^DGEN(27.11,EAIEN,0))
76 W !,EAIEN_" | "_EANODE
77 ;
78 F EAX=1:1 D Q:$G(DONE)
79 . S EAIEN=$P(EANODE,U,9)
80 . I 'EAIEN S DONE=1 Q
81 . S EANODE=$G(^DGEN(27.11,EAIEN,0))
82 . W !,EAIEN_" | "_EANODE
83 Q
Note: See TracBrowser for help on using the repository browser.