Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: NURAPI

NURAPI.m

Go to the documentation of this file.
  1. NURAPI ;HCIOFO/FT,AL-APIs ;8/14/02 08:43
  1. ;;4.0;NURSING SERVICE;**37**;Apr 25, 1997
  1. ;
  1. ; The entry points in this routine are documented in IA #3227.
  1. ;
  1. ; This routine uses the following IAs:
  1. ; #10035 - ^DPT( references (supported)
  1. ;
  1. 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
  1. ; LOCATION file (#44).
  1. ; input: ARRAY - (Required) The name of the array to store the entries
  1. ; output: ARRAY(sequence #)=File 211.4 ien^File 44 name (for 211.4 ien)
  1. ;
  1. N NURCNT,NURI,NURIEN,NURNAME
  1. 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)","")
  1. I +$P($G(^TMP("DILIST",$J,0)),U,1)=0 S ARRAY(1)="NO UNIT"
  1. S (NURCNT,NURI)=0
  1. F S NURI=$O(^TMP("DILIST",$J,1,NURI)) Q:'NURI D
  1. .S NURNAME=$P($G(^TMP("DILIST",$J,1,NURI)),U,1)
  1. .S NURIEN=+$P($G(^TMP("DILIST",$J,2,NURI)),U,1)
  1. .Q:'NURIEN
  1. .S NURCNT=NURCNT+1
  1. .S ARRAY(NURCNT)=NURIEN_U_NURNAME
  1. .Q
  1. K ^TMP("DILIST",$J)
  1. Q
  1. PTCHK(LOC) ; This function returns a value that indicates if any patients
  1. ; (active or inactive) are associated with the Nursing location
  1. ; identified.
  1. ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
  1. ; output: 0 - no patients associated with this location
  1. ; 1 - yes, patients are associated with this location
  1. ; -1 - (minus 1) LOC is undefined or not found
  1. ;I $G(LOC)="" Q -1
  1. I '$D(^NURSF(211.4,+LOC,0)) Q -1
  1. I '$D(^NURSF(214,"E",LOC)) Q 0 ;FILE 214 is the NURS PATIENT file
  1. Q 1
  1. ;
  1. APTCHK(LOC) ; This function returns a value that indicates if active
  1. ; patients are associated with the Nursing location identified.
  1. ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
  1. ; output: 0 - no active patients associated with this location
  1. ; 1 - yes, active patients are associated with this location
  1. ; -1 - (minus 1) LOC is undefined or not found
  1. ;I $G(LOC)="" Q -1
  1. I '$D(^NURSF(211.4,+LOC,0)) Q -1
  1. I '$D(^NURSF(214,"AF","A",LOC)) Q 0 ;FILE 214 is the NURS PATIENT file
  1. Q 1
  1. ;
  1. PTLIST(LOC,ARRAY) ; Returns a list of all (active and inactive) patients
  1. ; for a nursing location in the array specified.
  1. ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
  1. ; input: ARRAY - (Required) Name of array to return entries in
  1. ; output: ARRAY - Subscripted by sequential number with DFN in first
  1. ; piece and patient name in second piece.
  1. ; example: ARRAY(#)=DFN^patient name
  1. ;
  1. ; If LOC is undefined or not found, then returns ARRAY(1)=-1
  1. ; If no patients on the Location, then returns ARRAY(1)="^No Patients"
  1. ;
  1. ;I $G(LOC)="" S ARRAY(1)=-1 Q
  1. I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
  1. N DFN,PATNAME,NURCNT
  1. S (DFN,NURCNT)=0
  1. F S DFN=$O(^NURSF(214,"E",LOC,DFN)) Q:DFN'>0 D
  1. . S PATNAME=$P($G(^DPT(DFN,0)),"^")
  1. . Q:PATNAME=""
  1. . S NURCNT=NURCNT+1
  1. . S ARRAY(NURCNT)=DFN_U_PATNAME
  1. . Q
  1. I NURCNT=0 S ARRAY(1)="^No Patients"
  1. Q
  1. APTLIST(LOC,ARRAY) ; Returns a list of active patients for a nursing
  1. ; location in the array specified.
  1. ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
  1. ; input: ARRAY - (Required) Name of the array to return entries in
  1. ; output: ARRAY - Subscripted by sequential number with DFN in first
  1. ; piece and patient name in second piece.
  1. ; example: ARRAY(#)=DFN^patient name
  1. ;
  1. ; If LOC is undefined or not found, then returns ARRAY(1)=-1
  1. ; If no patients on the Location, then returns ARRAY(1)="^No Patients"
  1. ;
  1. ;I $G(LOC)="" S ARRAY(1)=-1 Q
  1. I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
  1. N DFN,NURCNT,PATNAME
  1. S (DFN,NURCNT)=0
  1. F S DFN=$O(^NURSF(214,"AF","A",LOC,DFN)) Q:DFN'>0 D
  1. .S PATNAME=$P($G(^DPT(DFN,0)),"^")
  1. .Q:PATNAME=""
  1. .S NURCNT=NURCNT+1
  1. .S ARRAY(NURCNT)=DFN_U_PATNAME
  1. .Q
  1. I NURCNT=0 S ARRAY(1)="^No Patients"
  1. Q
  1. FINDNLOC(LOC) ; This function returns the NURS LOCATION file (#211.4) ien
  1. ; and the ien of the location (File 44, Field .01).
  1. ; input: LOC - (Required) Name of the Nursing location (as it appears
  1. ; in File 44).
  1. ; The name should begin with the characters 'NUR '.
  1. ; If not, 'NUR<space>' will be appended to the beginning
  1. ; of LOC. If LOC is undefined, then returns -1.
  1. ; output: File 211.4 ien^File 44 ien
  1. ;
  1. ; If LOC is undefined, then returns -1
  1. ; If LOC is not found, then returns "^Location not found"
  1. ;
  1. I $G(LOC)="" Q -1
  1. N NUROUT,NURWARD,NURVHLOC
  1. I LOC'?1"NUR ".E S LOC="NUR "_LOC
  1. D FIND^DIC(211.4,"","","X",LOC,"","","","","NUROUT")
  1. S NUROUT(1)=+$P($G(NUROUT("DILIST",0)),"^")
  1. I NUROUT(1)'>0 Q "^Location not found"
  1. S NURWARD=+$P(NUROUT("DILIST",2,1),"^"),NURVHLOC=+$P(NUROUT("DILIST",1,1),"^")
  1. S LOC=NURWARD_"^"_NURVHLOC
  1. Q LOC
  1. ;
  1. MASWARDS(LOC,ARRAY) ; Returns the MAS wards associated with this Nursing
  1. ; location in the array specified. The .01 field of the MAS WARD
  1. ; multiple of the NURS LOCATION file points to the WARD LOCATION
  1. ; file (#42).
  1. ; input: LOC - (Required) NURS LOCATION file (#211.4) ien
  1. ; input: ARRAY - (Required) Name of array to return entries in
  1. ; output: ARRAY subscripted by the MAS WARD value.
  1. ; example: ARRAY($P(^NURSF(211.4,LOC,3,D1,0),U,1))=""
  1. ; If LOC is null or not found, then ARRAY(1)=-1
  1. ;
  1. I '$D(^NURSF(211.4,+LOC,0)) S ARRAY(1)=-1 Q
  1. N GMVD1
  1. I $D(^NURSF(211.4,LOC,3)) D
  1. .S GMVD1=0
  1. .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))=""
  1. .Q
  1. I $O(ARRAY(0))="" S ARRAY(1)=-1
  1. Q