source: FOIAVistA/tag/r/HEALTH_LEVEL_SEVEN-HL/HLEMP.m@ 636

Last change on this file since 636 was 628, checked in by George Lilly, 14 years ago

initial load of FOIAVistA 6/30/08 version

File size: 4.0 KB
Line 
1HLEMP ;ALB/CJM-HL7 - APIs for Monitor Events Log Profiles ;07/10/2003
2 ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13,1995
3 ;
4FDEFAULT(DUZ) ;
5 ;Description: Given a DUZ, returns the default profile, or "" on failure
6 ;
7 Q:'$G(DUZ) 0
8 Q $O(^HLEV(776.5,"AC",DUZ,0))
9 ;
10 Q $S(Y=-1:0,1:+Y)
11 ;
12GET(IEN,PROFILE) ;
13 ;Description - given the ien, it returns an array containing the profile
14 ;Input:
15 ; IEN - ien of the profile
16 ;Output:
17 ; function returns 0 on failure, 1 on success
18 ; PROFILE( **pass by reference**
19 ; "ALL APPS" - 1 if all sending applications should be included, 0 otherwise
20 ; "ALL SITES" - 1 if all sites should be included, 0 otherwise
21 ; "ALL STATUSES" 1 if all review statuses should be included, 0 otherwise
22 ; "ALL TYPES" - 1 if all event types should be included, 0 otherwise
23 ; "APPS",<HL7 APPLICATION PARAMETER>) -list of sending applications to include - NOT the iens, but the names of the HL7 Application Parameter
24 ; "DUZ" - the duz of the profile's owner
25 ; "DEFAULT" - 1 if this is the default profile, 0 if it isn't
26 ; "IEN" - ien of the profile
27 ; "NAME" - name of the profile
28 ; "SITES",<institution ien>) - list of institution numbers to include
29 ; "START" - starting date/time for selecting events for display, in FM format
30 ; "STATUSES",<review status code>) - list of review status codes to include
31 ; "TYPES",<HL7 MONITOR EVENT TYPE>) - list of event type iens
32 ; "URGENT" - 1 means urgent only, 0 means disregard urgency
33 ;
34 ;
35 Q:'$G(IEN) 0
36 N NODE,SITE,TYPE,APP,STATUS,APPNAME,I
37 K PROFILE S PROFILE=IEN
38 S NODE=$G(^HLEV(776.5,IEN,0))
39 Q:'$L(NODE) 0
40 S PROFILE("IEN")=IEN
41 S PROFILE("DUZ")=+NODE
42 S PROFILE("NAME")=$P(NODE,"^",2)
43 S PROFILE("DEFAULT")=$P(NODE,"^",3)
44 S PROFILE("ALL SITES")=$P(NODE,"^",4)
45 S PROFILE("ALL TYPES")=$P(NODE,"^",5)
46 S PROFILE("ALL APPS")=$P(NODE,"^",6)
47 S PROFILE("ALL STATUSES")=$P(NODE,"^",7)
48 S START=+$P(NODE,"^",8) D
49 .N NOW
50 .S NOW=$$NOW^XLFDT
51 .S PROFILE("START")=0
52 .I START=1 S PROFILE("START")=$$FMADD^XLFDT(NOW,,-1) Q
53 .I START=2 S PROFILE("START")=$$FMADD^XLFDT(NOW,,-2) Q
54 .I START=3 S PROFILE("START")=$$FMADD^XLFDT(NOW,,-6) Q
55 .I START=4 S PROFILE("START")=+NOW Q
56 .I START=5 S PROFILE("START")=$$FMADD^XLFDT(NOW,-1) Q
57 .I START=6 S PROFILE("START")=$$FMADD^XLFDT(+NOW,-1) Q
58 .I START=7 S PROFILE("START")=$$FMADD^XLFDT(NOW,-2) Q
59 .I START=8 S PROFILE("START")=$$FMADD^XLFDT(NOW,-3) Q
60 .I START=9 S PROFILE("START")=$$FMADD^XLFDT(NOW,-7) Q
61 S PROFILE("URGENT")=$P(NODE,"^",9)
62 S SITE=0
63 F I="APPS","SITES","TYPES","STATUSES" S PROFILE(I)=""
64 F S SITE=$O(^HLEV(776.5,IEN,1,SITE)) Q:'SITE S PROFILE("SITES",+$G(^HLEV(776.5,IEN,1,SITE,0)))=""
65 S TYPE=0
66 F S TYPE=$O(^HLEV(776.5,IEN,2,TYPE)) Q:'TYPE S PROFILE("TYPES",+$G(^HLEV(776.5,IEN,2,TYPE,0)))=""
67 S APP=0
68 F S APP=$O(^HLEV(776.5,IEN,3,APP)) Q:'APP S PROFILE("APPS",$$APPNAME^HLEMU(+$G(^HLEV(776.5,IEN,3,APP,0))))=""
69 S STATUS=0
70 F S STATUS=$O(^HLEV(776.5,IEN,4,STATUS)) Q:'STATUS S APPNAME=$$APPNAME^HLEMU(+$G(^HLEV(776.5,IEN,4,STATUS,0))) I $L(APPNAME) S PROFILE("APPS",APPNAME)=""
71 Q 1
72 ;
73CREATE(DUZ,NAME,ERROR) ;
74 ;Given the DUZ and a name, creates a new profile of that name.
75 ;Output-
76 ; function value - returns the new profile ien on success, 0 on failure
77 ; ERROR **optional, pass by reference** an array of errors
78 ;
79 Q:'$G(DUZ) 0
80 Q:'$L(NAME) 0
81 ;
82 N DATA
83 S DATA(.01)=DUZ
84 S DATA(.02)=NAME
85 Q $$ADD^HLEMU(776.5,,.DATA,.ERROR)
86 ;
87EDIT(PROFILE) ;
88 ;Given the ien of a profile, allows a user to edit it.
89 ;Input: PROFILE - ien of a profile
90 ;Output: function returns 1 on success, 0 on failure, or on indication that the user did not complete the edit
91 ;
92 Q:'$G(PROFILE) 0
93 Q:'$G(^HLEV(776.5,PROFILE,0)) 0
94 K DA,DIE,DR
95 S DA=PROFILE
96 S DIE=776.5
97 S DR=".02:.09"
98 S DIE("NO^")="OUTOK"
99 D ^DIE
100 I '$D(Y),'$D(DTOUT),$$GET(PROFILE,.PROFILE) D
101 .S DR=""
102 .S DIE("NO^")="OUTOK"
103 .I 'PROFILE("ALL SITES") S DR="1;"
104 .I 'PROFILE("ALL TYPES") S DR=DR_"2;"
105 .I 'PROFILE("ALL APPS") S DR=DR_"3;"
106 .I 'PROFILE("ALL STATUSES") S DR=DR_4
107 .D ^DIE
108 Q $S($D(Y)!$D(DTOUT):0,1:1)
109 ;
110DELETE(PROFILE) ;
111 ;Given the ien, deletes the profile
112 Q $$DELETE^HLEMU(776.5,.PROFILE)
Note: See TracBrowser for help on using the repository browser.