NURAPI ;HCIOFO/FT,AL-APIs ;8/14/02 08:43
;;4.0;NURSING SERVICE;**37**;Apr 25, 1997
;
; The entry points in this routine are documented in IA #3227.
;
; This routine uses the following IAs:
; #10035 - ^DPT( references (supported)
;
ACTLOCS(ARRAY) ; Returns all active nursing locations from the NURS LOCATION
; file (#211.4) in the array specified. FILE 211.4 points to HOSPITAL
; LOCATION file (#44).
; input: ARRAY - (Required) The name of the array to store the entries
; output: ARRAY(sequence #)=File 211.4 ien^File 44 name (for 211.4 ien)
;
N NURCNT,NURI,NURIEN,NURNAME
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)","")
I +$P($G(^TMP("DILIST",$J,0)),U,1)=0 S ARRAY(1)="NO UNIT"
S (NURCNT,NURI)=0
F S NURI=$O(^TMP("DILIST",$J,1,NURI)) Q:'NURI D
.S NURNAME=$P($G(^TMP("DILIST",$J,1,NURI)),U,1)
.S NURIEN=+$P($G(^TMP("DILIST",$J,2,NURI)),U,1)
.Q:'NURIEN
.S NURCNT=NURCNT+1
.S ARRAY(NURCNT)=NURIEN_U_NURNAME
.Q
K ^TMP("DILIST",$J)
Q
PTCHK(LOC) ; This function returns a value that indicates if any patients
; (active or inactive) are associated with the Nursing location
; identified.
; input: LOC - (Required) NURS LOCATION file (#211.4) ien
; output: 0 - no patients associated with this location
; 1 - yes, patients are associated with this location
; -1 - (minus 1) LOC is undefined or not found
;I $G(LOC)="" Q -1
I '$D(^NURSF(211.4,+LOC,0)) Q -1
I '$D(^NURSF(214,"E",LOC)) Q 0 ;FILE 214 is the NURS PATIENT file
Q 1
;
APTCHK(LOC) ; This function returns a value that indicates if active
; patients are associated with the Nursing location identified.
; input: LOC - (Required) NURS LOCATION file (#211.4) ien
; output: 0 - no active patients associated with this location
; 1 - yes, active patients are associated with this location
; -1 - (minus 1) LOC is undefined or not found
;I $G(LOC)="" Q -1
I '$D(^NURSF(211.4,+LOC,0)) Q -1
I '$D(^NURSF(214,"AF","A",LOC)) Q 0 ;FILE 214 is the NURS PATIENT file
Q 1
;
PTLIST(LOC,ARRAY) ; Returns a list of all (active and inactive) patients
; for a nursing location in the array specified.
; input: LOC - (Required) NURS LOCATION file (#211.4) ien
; input: ARRAY - (Required) Name of array to return entries in
; output: ARRAY - Subscripted by sequential number with DFN in first
; piece and patient name in second piece.
; example: ARRAY(#)=DFN^patient name
;
; If LOC is undefined or not found, then returns ARRAY(1)=-1
; If no patients on the Location, then returns ARRAY(1)="^No Patients"
;
;I $G(LOC)="" S ARRAY(1)=-1 Q
I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
N DFN,PATNAME,NURCNT
S (DFN,NURCNT)=0
F S DFN=$O(^NURSF(214,"E",LOC,DFN)) Q:DFN'>0 D
. S PATNAME=$P($G(^DPT(DFN,0)),"^")
. Q:PATNAME=""
. S NURCNT=NURCNT+1
. S ARRAY(NURCNT)=DFN_U_PATNAME
. Q
I NURCNT=0 S ARRAY(1)="^No Patients"
Q
APTLIST(LOC,ARRAY) ; Returns a list of active patients for a nursing
; location in the array specified.
; input: LOC - (Required) NURS LOCATION file (#211.4) ien
; input: ARRAY - (Required) Name of the array to return entries in
; output: ARRAY - Subscripted by sequential number with DFN in first
; piece and patient name in second piece.
; example: ARRAY(#)=DFN^patient name
;
; If LOC is undefined or not found, then returns ARRAY(1)=-1
; If no patients on the Location, then returns ARRAY(1)="^No Patients"
;
;I $G(LOC)="" S ARRAY(1)=-1 Q
I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
N DFN,NURCNT,PATNAME
S (DFN,NURCNT)=0
F S DFN=$O(^NURSF(214,"AF","A",LOC,DFN)) Q:DFN'>0 D
.S PATNAME=$P($G(^DPT(DFN,0)),"^")
.Q:PATNAME=""
.S NURCNT=NURCNT+1
.S ARRAY(NURCNT)=DFN_U_PATNAME
.Q
I NURCNT=0 S ARRAY(1)="^No Patients"
Q
FINDNLOC(LOC) ; This function returns the NURS LOCATION file (#211.4) ien
; and the ien of the location (File 44, Field .01).
; input: LOC - (Required) Name of the Nursing location (as it appears
; in File 44).
; The name should begin with the characters 'NUR '.
; If not, 'NUR<space>' will be appended to the beginning
; of LOC. If LOC is undefined, then returns -1.
; output: File 211.4 ien^File 44 ien
;
; If LOC is undefined, then returns -1
; If LOC is not found, then returns "^Location not found"
;
I $G(LOC)="" Q -1
N NUROUT,NURWARD,NURVHLOC
I LOC'?1"NUR ".E S LOC="NUR "_LOC
D FIND^DIC(211.4,"","","X",LOC,"","","","","NUROUT")
S NUROUT(1)=+$P($G(NUROUT("DILIST",0)),"^")
I NUROUT(1)'>0 Q "^Location not found"
S NURWARD=+$P(NUROUT("DILIST",2,1),"^"),NURVHLOC=+$P(NUROUT("DILIST",1,1),"^")
S LOC=NURWARD_"^"_NURVHLOC
Q LOC
;
MASWARDS(LOC,ARRAY) ; Returns the MAS wards associated with this Nursing
; location in the array specified. The .01 field of the MAS WARD
; multiple of the NURS LOCATION file points to the WARD LOCATION
; file (#42).
; input: LOC - (Required) NURS LOCATION file (#211.4) ien
; input: ARRAY - (Required) Name of array to return entries in
; output: ARRAY subscripted by the MAS WARD value.
; example: ARRAY($P(^NURSF(211.4,LOC,3,D1,0),U,1))=""
; If LOC is null or not found, then ARRAY(1)=-1
;
I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
N GMVD1
I $D(^NURSF(211.4,LOC,3)) D
.S GMVD1=0
.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))=""
.Q
I $O(ARRAY(0))="" S ARRAY(1)=-1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HNURAPI 5658 printed Dec 13, 2024@02:19:36 Page 2
NURAPI ;HCIOFO/FT,AL-APIs ;8/14/02 08:43
+1 ;;4.0;NURSING SERVICE;**37**;Apr 25, 1997
+2 ;
+3 ; The entry points in this routine are documented in IA #3227.
+4 ;
+5 ; This routine uses the following IAs:
+6 ; #10035 - ^DPT( references (supported)
+7 ;
ACTLOCS(ARRAY) ; Returns all active nursing locations from the NURS LOCATION
+1 ; file (#211.4) in the array specified. FILE 211.4 points to HOSPITAL
+2 ; LOCATION file (#44).
+3 ; input: ARRAY - (Required) The name of the array to store the entries
+4 ; output: ARRAY(sequence #)=File 211.4 ien^File 44 name (for 211.4 ien)
+5 ;
+6 NEW NURCNT,NURI,NURIEN,NURNAME
+7 DO 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)","")
+8 IF +$PIECE($GET(^TMP("DILIST",$JOB,0)),U,1)=0
SET ARRAY(1)="NO UNIT"
+9 SET (NURCNT,NURI)=0
+10 FOR
SET NURI=$ORDER(^TMP("DILIST",$JOB,1,NURI))
if 'NURI
QUIT
Begin DoDot:1
+11 SET NURNAME=$PIECE($GET(^TMP("DILIST",$JOB,1,NURI)),U,1)
+12 SET NURIEN=+$PIECE($GET(^TMP("DILIST",$JOB,2,NURI)),U,1)
+13 if 'NURIEN
QUIT
+14 SET NURCNT=NURCNT+1
+15 SET ARRAY(NURCNT)=NURIEN_U_NURNAME
+16 QUIT
End DoDot:1
+17 KILL ^TMP("DILIST",$JOB)
+18 QUIT
PTCHK(LOC) ; This function returns a value that indicates if any patients
+1 ; (active or inactive) are associated with the Nursing location
+2 ; identified.
+3 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
+4 ; output: 0 - no patients associated with this location
+5 ; 1 - yes, patients are associated with this location
+6 ; -1 - (minus 1) LOC is undefined or not found
+7 ;I $G(LOC)="" Q -1
+8 IF '$DATA(^NURSF(211.4,+LOC,0))
QUIT -1
+9 ;FILE 214 is the NURS PATIENT file
IF '$DATA(^NURSF(214,"E",LOC))
QUIT 0
+10 QUIT 1
+11 ;
APTCHK(LOC) ; This function returns a value that indicates if active
+1 ; patients are associated with the Nursing location identified.
+2 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
+3 ; output: 0 - no active patients associated with this location
+4 ; 1 - yes, active patients are associated with this location
+5 ; -1 - (minus 1) LOC is undefined or not found
+6 ;I $G(LOC)="" Q -1
+7 IF '$DATA(^NURSF(211.4,+LOC,0))
QUIT -1
+8 ;FILE 214 is the NURS PATIENT file
IF '$DATA(^NURSF(214,"AF","A",LOC))
QUIT 0
+9 QUIT 1
+10 ;
PTLIST(LOC,ARRAY) ; Returns a list of all (active and inactive) patients
+1 ; for a nursing location in the array specified.
+2 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
+3 ; input: ARRAY - (Required) Name of array to return entries in
+4 ; output: ARRAY - Subscripted by sequential number with DFN in first
+5 ; piece and patient name in second piece.
+6 ; example: ARRAY(#)=DFN^patient name
+7 ;
+8 ; If LOC is undefined or not found, then returns ARRAY(1)=-1
+9 ; If no patients on the Location, then returns ARRAY(1)="^No Patients"
+10 ;
+11 ;I $G(LOC)="" S ARRAY(1)=-1 Q
+12 IF '$DATA(^NURSF(211.4,+LOC,0))
SET ARRAY(1)=-1
QUIT
+13 NEW DFN,PATNAME,NURCNT
+14 SET (DFN,NURCNT)=0
+15 FOR
SET DFN=$ORDER(^NURSF(214,"E",LOC,DFN))
if DFN'>0
QUIT
Begin DoDot:1
+16 SET PATNAME=$PIECE($GET(^DPT(DFN,0)),"^")
+17 if PATNAME=""
QUIT
+18 SET NURCNT=NURCNT+1
+19 SET ARRAY(NURCNT)=DFN_U_PATNAME
+20 QUIT
End DoDot:1
+21 IF NURCNT=0
SET ARRAY(1)="^No Patients"
+22 QUIT
APTLIST(LOC,ARRAY) ; Returns a list of active patients for a nursing
+1 ; location in the array specified.
+2 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
+3 ; input: ARRAY - (Required) Name of the array to return entries in
+4 ; output: ARRAY - Subscripted by sequential number with DFN in first
+5 ; piece and patient name in second piece.
+6 ; example: ARRAY(#)=DFN^patient name
+7 ;
+8 ; If LOC is undefined or not found, then returns ARRAY(1)=-1
+9 ; If no patients on the Location, then returns ARRAY(1)="^No Patients"
+10 ;
+11 ;I $G(LOC)="" S ARRAY(1)=-1 Q
+12 IF '$DATA(^NURSF(211.4,+LOC,0))
SET ARRAY(1)=-1
QUIT
+13 NEW DFN,NURCNT,PATNAME
+14 SET (DFN,NURCNT)=0
+15 FOR
SET DFN=$ORDER(^NURSF(214,"AF","A",LOC,DFN))
if DFN'>0
QUIT
Begin DoDot:1
+16 SET PATNAME=$PIECE($GET(^DPT(DFN,0)),"^")
+17 if PATNAME=""
QUIT
+18 SET NURCNT=NURCNT+1
+19 SET ARRAY(NURCNT)=DFN_U_PATNAME
+20 QUIT
End DoDot:1
+21 IF NURCNT=0
SET ARRAY(1)="^No Patients"
+22 QUIT
FINDNLOC(LOC) ; This function returns the NURS LOCATION file (#211.4) ien
+1 ; and the ien of the location (File 44, Field .01).
+2 ; input: LOC - (Required) Name of the Nursing location (as it appears
+3 ; in File 44).
+4 ; The name should begin with the characters 'NUR '.
+5 ; If not, 'NUR<space>' will be appended to the beginning
+6 ; of LOC. If LOC is undefined, then returns -1.
+7 ; output: File 211.4 ien^File 44 ien
+8 ;
+9 ; If LOC is undefined, then returns -1
+10 ; If LOC is not found, then returns "^Location not found"
+11 ;
+12 IF $GET(LOC)=""
QUIT -1
+13 NEW NUROUT,NURWARD,NURVHLOC
+14 IF LOC'?1"NUR ".E
SET LOC="NUR "_LOC
+15 DO FIND^DIC(211.4,"","","X",LOC,"","","","","NUROUT")
+16 SET NUROUT(1)=+$PIECE($GET(NUROUT("DILIST",0)),"^")
+17 IF NUROUT(1)'>0
QUIT "^Location not found"
+18 SET NURWARD=+$PIECE(NUROUT("DILIST",2,1),"^")
SET NURVHLOC=+$PIECE(NUROUT("DILIST",1,1),"^")
+19 SET LOC=NURWARD_"^"_NURVHLOC
+20 QUIT LOC
+21 ;
MASWARDS(LOC,ARRAY) ; Returns the MAS wards associated with this Nursing
+1 ; location in the array specified. The .01 field of the MAS WARD
+2 ; multiple of the NURS LOCATION file points to the WARD LOCATION
+3 ; file (#42).
+4 ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
+5 ; input: ARRAY - (Required) Name of array to return entries in
+6 ; output: ARRAY subscripted by the MAS WARD value.
+7 ; example: ARRAY($P(^NURSF(211.4,LOC,3,D1,0),U,1))=""
+8 ; If LOC is null or not found, then ARRAY(1)=-1
+9 ;
+10 IF '$DATA(^NURSF(211.4,+LOC,0))
SET ARRAY(1)=-1
QUIT
+11 NEW GMVD1
+12 IF $DATA(^NURSF(211.4,LOC,3))
Begin DoDot:1
+13 SET GMVD1=0
+14 FOR
SET GMVD1=$ORDER(^NURSF(211.4,LOC,3,GMVD1))
if GMVD1'>0
QUIT
SET ARRAY($PIECE(^NURSF(211.4,LOC,3,GMVD1,0),U,1))=""
+15 QUIT
End DoDot:1
+16 IF $ORDER(ARRAY(0))=""
SET ARRAY(1)=-1
+17 QUIT