source: WorldVistAEHR/trunk/r/NURSING_SERVICE-NUR/NURCRL4.m@ 1582

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

initial load of WorldVistAEHR

File size: 4.7 KB
Line 
1NURCRL4 ;HIRMFO/RM-CARE PLAN RANK ORDER PRINT (cont.) ;8/29/96
2 ;;4.0;NURSING SERVICE;;Apr 25, 1997
3PRINT ; ENTRY FROM NURCRL0 TO PRINT THIS REPORT.
4 ;
5 ; Set up required variables for sort.
6 ; Calculate patient census over date/time range.
7 K ^TMP($J)
8 D NOW^%DTC S NURCNOW=%,NURCNCP=$O(^GMRD(124.2,"AA","NURSC",2,"Nursing Care Plan",1,0)),NURCINT=$O(^GMRD(124.25,"AA","NURSC","NURSING INTERVENTION",0)),NURCORD=$O(^GMRD(124.25,"AA","NURSC","ORDERABLE",0))
9 I '$$CENSUS^NURCRL2(NURCBGDT,NURCENDT,NURCNOW,NURCSORT)!'NURCNCP!'NURCINT!'NURCORD U IO S NURCPAGE=$$HEADER^NURCRL1(0) W !!,"There is no data for this report." S NURCPAGE=$$HEADER^NURCRL1(-1) S NURCOUT=1 G EXIT
10 ;
11 ; Loop through ^TMP($J,"NURCEN",DFN) and get DFN to process
12 ; Loop through ^GMR(124.3,"AA",DFN,DATE) over date time range
13 ; BEGIN
14 F DFN=0:0 S DFN=$O(^TMP($J,"NURCEN",DFN)) Q:DFN'>0 D DEM^VADPT S NURCBS5=$E(VADM(1))_$P($P(VADM(2),"^",2),"-",3) F NURCDATE=(9999999-NURCENDT):0 S NURCDATE=$O(^GMR(124.3,"AA",DFN,NURCNCP,NURCDATE)) Q:NURCDATE'>0 D
15 .; Get a care plan
16 .S NURCPDA=$O(^GMR(124.3,"AA",DFN,NURCNCP,NURCDATE,0)) Q:NURCPDA'>0
17 .; Loop through all entries in SELECTION multiple
18 .; If ACTIVE(PROBLEM(entry)) THEN
19 .; BEGIN
20 .F NURCPDA1=0:0 S NURCPDA1=$O(^GMR(124.3,NURCPDA,1,NURCPDA1)) Q:NURCPDA1'>0 S NURCPTRM=+$G(^GMR(124.3,NURCPDA,1,NURCPDA1,0)) I $$ACTIVE^NURCRL1(NURCPTRM,NURCPDA,NURCBGDT,NURCENDT) D
21 ..; Find frame with CLASSIFICATION=NURSING INTERVENTION that
22 ..; is under this problem.
23 ..S NURCITRM=$$GETTRM^NURCRL1(NURCPTRM,NURCINT)
24 ..; Get list of all frames/terms under NURSING INTERVENTION
25 ..; frame with CLASSIFICATION=ORDERABLE in NURSLIST.
26 ..; If NURSLIST is not empty then Loop through list
27 ..; BEGIN
28 ..I $$GETLST^NURCRL1(NURCITRM,NURCORD) F NURCOTRM=0:0 S NURCOTRM=$O(NURSLIST(NURCOTRM)) Q:NURCOTRM'>0 I $D(^GMR(124.3,NURCPDA,1,"B",NURCOTRM)) D
29 ...; Set up sort arrays for the orderables
30 ...I NURCRTYP=2 D
31 ....K ^TMP($J,"NURSIR",NURCPTRM,9999999-$G(^TMP($J,"NURSORD",NURCPTRM,NURCOTRM)),NURCOTRM)
32 ....S ^TMP($J,"NURSORD",NURCPTRM,NURCOTRM)=$G(^TMP($J,"NURSORD",NURCPTRM,NURCOTRM))+1,^TMP($J,"NURSIR",NURCPTRM,9999999-^TMP($J,"NURSORD",NURCPTRM,NURCOTRM),NURCOTRM)="",^TMP($J,"NURSORD",NURCPTRM,NURCOTRM,NURCBS5)=""
33 ....Q
34 ...I NURCRTYP=3 D
35 ....K ^TMP($J,"NURSIR",9999999-$G(^TMP($J,"NURSORD",NURCOTRM)),NURCOTRM)
36 ....S ^TMP($J,"NURSORD",NURCOTRM)=$G(^TMP($J,"NURSORD",NURCOTRM))+1,^TMP($J,"NURSIR",9999999-^TMP($J,"NURSORD",NURCOTRM),NURCOTRM)="",^TMP($J,"NURSORD",NURCOTRM,NURCBS5)=""
37 ....Q
38 ..; END
39 ..; Set up the sort arrays for the problems
40 ..I NURCRTYP'=3 D
41 ...K ^TMP($J,"NURSPR",9999999-$G(^TMP($J,"NURSPROB",NURCPTRM)),NURCPTRM)
42 ...S ^TMP($J,"NURSPROB",NURCPTRM)=$G(^TMP($J,"NURSPROB",NURCPTRM))+1,^TMP($J,"NURSPR",9999999-^TMP($J,"NURSPROB",NURCPTRM),NURCPTRM)="",^TMP($J,"NURSPROB",NURCPTRM,NURCBS5)=""
43 ...Q
44 .; END
45 ; END
46 ;
47 ; Set up variables conditioned on report type.
48 I NURCRTYP'=3 S NURCIPR="NURSPR",NURCPROR="NURSPROB"
49 E S NURCIPR="NURSIR",NURCPROR="NURSORD"
50 ;
51 ; Use IO
52 ; Print Header
53 U IO S NURCPAGE=$$HEADER^NURCRL1(0)
54 I '$D(^TMP($J,NURCIPR)) W !!,"There is no data for this report." S NURCOUT=1 G EXIT
55 ;
56 ; RANK=0
57 ; Loop through ^TMP($J,NURCIPR,FREQ,PROBLEM) increasing RANK with
58 ; each new FREQ
59 ; BEGIN
60 S (NURCOUT,NURCRANK)=0
61 F NURCFREQ=0:0 S NURCFREQ=$O(^TMP($J,NURCIPR,NURCFREQ)),NURCRANK=NURCRANK+1 Q:NURCFREQ'>0!NURCOUT F NURCPTRM=0:0 S NURCPTRM=$O(^TMP($J,NURCIPR,NURCFREQ,NURCPTRM)) Q:NURCPTRM'>0!NURCOUT D
62 .; WRTPROB(RANK,PROBLEM,FREQ)
63 .; RANK1=0
64 .; Loop through ^TMP($J,NURCPROR,PROBLEM,BS5)
65 .; WRTPPT(BS5)
66 .; If report type is Dx/Int then
67 .; BEGIN
68 .; Loop through ^TMP($J,"NURSIR",PR,FREQ1,ORD) increasing
69 .; RANK1 by one for each new FREQ
70 .; BEGIN
71 .S NURCRNK1=0,NURCOUT=$$WRTPROB^NURCRL1(NURCRANK,NURCPTRM,9999999-NURCFREQ) Q:NURCOUT
72 .W !?15 S NURCBS5="" F S NURCBS5=$O(^TMP($J,NURCPROR,NURCPTRM,NURCBS5)) Q:NURCBS5="" S NURCOUT=$$WRTPPT^NURCRL1(NURCBS5) Q:NURCOUT
73 .I NURCRTYP=2 D
74 ..S NURCOUT=$$HDRINT^NURCRL1 Q:NURCOUT
75 ..F NURCFRQ1=0:0 S NURCFRQ1=$O(^TMP($J,"NURSIR",NURCPTRM,NURCFRQ1)),NURCRNK1=NURCRNK1+1 Q:NURCFRQ1'>0!NURCOUT F NURCOTRM=0:0 S NURCOTRM=$O(^TMP($J,"NURSIR",NURCPTRM,NURCFRQ1,NURCOTRM)) Q:NURCOTRM'>0!NURCOUT D
76 ...; WRTORD(RANK1,ORD,FREQ1)
77 ...; Loop through ^TMP($J,"NURSORD",PROBLEM,ORD,BS5)
78 ...; WRTOPT(BS5)
79 ...S NURCOUT=$$WRTORD^NURCRL1(NURCRNK1,NURCOTRM,9999999-NURCFRQ1) Q:NURCOUT
80 ...W !?20 S NURCBS5="" F S NURCBS5=$O(^TMP($J,"NURSORD",NURCPTRM,NURCOTRM,NURCBS5)) Q:NURCBS5="" S NURCOUT=$$WRTOPT^NURCRL1(NURCBS5) Q:NURCOUT
81 ..; END
82 .; END
83 ; END
84EXIT Q
Note: See TracBrowser for help on using the repository browser.