source: FOIAVistA/trunk/r/NURSING_SERVICE-NUR/NURAPI.m@ 1203

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

initial load of FOIAVistA 6/30/08 version

File size: 5.4 KB
Line 
1NURAPI ;HCIOFO/FT,AL-APIs ;8/14/02 08:43
2 ;;4.0;NURSING SERVICE;**37**;Apr 25, 1997
3 ;
4 ; The entry points in this routine are documented in IA #3227.
5 ;
6 ; This routine uses the following IAs:
7 ; #10035 - ^DPT( references (supported)
8 ;
9ACTLOCS(ARRAY) ; Returns all active nursing locations from the NURS LOCATION
10 ; file (#211.4) in the array specified. FILE 211.4 points to HOSPITAL
11 ; LOCATION file (#44).
12 ; input: ARRAY - (Required) The name of the array to store the entries
13 ; output: ARRAY(sequence #)=File 211.4 ien^File 44 name (for 211.4 ien)
14 ;
15 N NURCNT,NURI,NURIEN,NURNAME
16 D LIST^DIC(211.4,"","","","*","","","","I $S('$D(^NURSF(211.4,""D"",""I"",+Y)):1,$P(^NURSF(211.4,+Y,1),U)=""I"":0,1:1)","")
17 I +$P($G(^TMP("DILIST",$J,0)),U,1)=0 S ARRAY(1)="NO UNIT"
18 S (NURCNT,NURI)=0
19 F S NURI=$O(^TMP("DILIST",$J,1,NURI)) Q:'NURI D
20 .S NURNAME=$P($G(^TMP("DILIST",$J,1,NURI)),U,1)
21 .S NURIEN=+$P($G(^TMP("DILIST",$J,2,NURI)),U,1)
22 .Q:'NURIEN
23 .S NURCNT=NURCNT+1
24 .S ARRAY(NURCNT)=NURIEN_U_NURNAME
25 .Q
26 K ^TMP("DILIST",$J)
27 Q
28PTCHK(LOC) ; This function returns a value that indicates if any patients
29 ; (active or inactive) are associated with the Nursing location
30 ; identified.
31 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
32 ; output: 0 - no patients associated with this location
33 ; 1 - yes, patients are associated with this location
34 ; -1 - (minus 1) LOC is undefined or not found
35 ;I $G(LOC)="" Q -1
36 I '$D(^NURSF(211.4,+LOC,0)) Q -1
37 I '$D(^NURSF(214,"E",LOC)) Q 0 ;FILE 214 is the NURS PATIENT file
38 Q 1
39 ;
40APTCHK(LOC) ; This function returns a value that indicates if active
41 ; patients are associated with the Nursing location identified.
42 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
43 ; output: 0 - no active patients associated with this location
44 ; 1 - yes, active patients are associated with this location
45 ; -1 - (minus 1) LOC is undefined or not found
46 ;I $G(LOC)="" Q -1
47 I '$D(^NURSF(211.4,+LOC,0)) Q -1
48 I '$D(^NURSF(214,"AF","A",LOC)) Q 0 ;FILE 214 is the NURS PATIENT file
49 Q 1
50 ;
51PTLIST(LOC,ARRAY) ; Returns a list of all (active and inactive) patients
52 ; for a nursing location in the array specified.
53 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
54 ; input: ARRAY - (Required) Name of array to return entries in
55 ; output: ARRAY - Subscripted by sequential number with DFN in first
56 ; piece and patient name in second piece.
57 ; example: ARRAY(#)=DFN^patient name
58 ;
59 ; If LOC is undefined or not found, then returns ARRAY(1)=-1
60 ; If no patients on the Location, then returns ARRAY(1)="^No Patients"
61 ;
62 ;I $G(LOC)="" S ARRAY(1)=-1 Q
63 I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
64 N DFN,PATNAME,NURCNT
65 S (DFN,NURCNT)=0
66 F S DFN=$O(^NURSF(214,"E",LOC,DFN)) Q:DFN'>0 D
67 . S PATNAME=$P($G(^DPT(DFN,0)),"^")
68 . Q:PATNAME=""
69 . S NURCNT=NURCNT+1
70 . S ARRAY(NURCNT)=DFN_U_PATNAME
71 . Q
72 I NURCNT=0 S ARRAY(1)="^No Patients"
73 Q
74APTLIST(LOC,ARRAY) ; Returns a list of active patients for a nursing
75 ; location in the array specified.
76 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
77 ; input: ARRAY - (Required) Name of the array to return entries in
78 ; output: ARRAY - Subscripted by sequential number with DFN in first
79 ; piece and patient name in second piece.
80 ; example: ARRAY(#)=DFN^patient name
81 ;
82 ; If LOC is undefined or not found, then returns ARRAY(1)=-1
83 ; If no patients on the Location, then returns ARRAY(1)="^No Patients"
84 ;
85 ;I $G(LOC)="" S ARRAY(1)=-1 Q
86 I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
87 N DFN,NURCNT,PATNAME
88 S (DFN,NURCNT)=0
89 F S DFN=$O(^NURSF(214,"AF","A",LOC,DFN)) Q:DFN'>0 D
90 .S PATNAME=$P($G(^DPT(DFN,0)),"^")
91 .Q:PATNAME=""
92 .S NURCNT=NURCNT+1
93 .S ARRAY(NURCNT)=DFN_U_PATNAME
94 .Q
95 I NURCNT=0 S ARRAY(1)="^No Patients"
96 Q
97FINDNLOC(LOC) ; This function returns the NURS LOCATION file (#211.4) ien
98 ; and the ien of the location (File 44, Field .01).
99 ; input: LOC - (Required) Name of the Nursing location (as it appears
100 ; in File 44).
101 ; The name should begin with the characters 'NUR '.
102 ; If not, 'NUR<space>' will be appended to the beginning
103 ; of LOC. If LOC is undefined, then returns -1.
104 ; output: File 211.4 ien^File 44 ien
105 ;
106 ; If LOC is undefined, then returns -1
107 ; If LOC is not found, then returns "^Location not found"
108 ;
109 I $G(LOC)="" Q -1
110 N NUROUT,NURWARD,NURVHLOC
111 I LOC'?1"NUR ".E S LOC="NUR "_LOC
112 D FIND^DIC(211.4,"","","X",LOC,"","","","","NUROUT")
113 S NUROUT(1)=+$P($G(NUROUT("DILIST",0)),"^")
114 I NUROUT(1)'>0 Q "^Location not found"
115 S NURWARD=+$P(NUROUT("DILIST",2,1),"^"),NURVHLOC=+$P(NUROUT("DILIST",1,1),"^")
116 S LOC=NURWARD_"^"_NURVHLOC
117 Q LOC
118 ;
119MASWARDS(LOC,ARRAY) ; Returns the MAS wards associated with this Nursing
120 ; location in the array specified. The .01 field of the MAS WARD
121 ; multiple of the NURS LOCATION file points to the WARD LOCATION
122 ; file (#42).
123 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
124 ; input: ARRAY - (Required) Name of array to return entries in
125 ; output: ARRAY subscripted by the MAS WARD value.
126 ; example: ARRAY($P(^NURSF(211.4,LOC,3,D1,0),U,1))=""
127 ; If LOC is null or not found, then ARRAY(1)=-1
128 ;
129 I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
130 N GMVD1
131 I $D(^NURSF(211.4,LOC,3)) D
132 .S GMVD1=0
133 .F S GMVD1=$O(^NURSF(211.4,LOC,3,GMVD1)) Q:GMVD1'>0 S ARRAY($P(^NURSF(211.4,LOC,3,GMVD1,0),U,1))=""
134 .Q
135 I $O(ARRAY(0))="" S ARRAY(1)=-1
136 Q
Note: See TracBrowser for help on using the repository browser.