source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORQQVS.m@ 1751

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

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1ORQQVS ; slc/CLA,STAFF - Functions which return patient visits ;3/16/05 10:27
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,195,215,271**;Dec 17, 1997;Build 2
3 ;
4 ; DBIA 2812 NOTES^TIUSRVLV ^TMP("TIULIST",$J)
5 ; DBIA 2944 TGET^TIUSRVR1 ^TMP("TIUVIEW",$J)
6 ; DBIA 1905 SELECTED^VSIT ^TMP("VSIT",$J)
7 ;
8LIST(ORY,PT,ORSDT,OREDT,LOC) ; return visits for a patient between start & end dates for a location, if no location return all visits
9 N VIEN,NUM,CNT,INVDT,ORSRV,CNTLIMIT,ORX
10 S CNTLIMIT=100 ;limit visits to 100 most recent Visit entries
11 S VIEN="A",NUM=0,CNT=1
12 S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
13 I ORSDT="" D
14 .I '$L(LOC) S ORSDT=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORQQEAPT ENC APPT START",1,"E"))
15 .I ORSDT="" S ORSDT="T-730" ;default start date is two years ago
16 I OREDT="" D
17 .I '$L(LOC) S OREDT=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORQQEAPT ENC APPT STOP",1,"E"))
18 .I OREDT="" S OREDT="T" ;default end date is today
19 ;CONVERT ORSDT AND OREDT INTO FILEMAN DATE/TIME
20 D DT^DILF("T",ORSDT,.ORSDT,"","")
21 D DT^DILF("T",OREDT,.OREDT,"","")
22 I (ORSDT=-1)!(OREDT=-1) S ORY(1)="^Error in date range." Q
23 K ^TMP("VSIT",$J) ;DBIA 1905
24 D SELECTED^VSIT(PT,ORSDT,OREDT,LOC,"") ;DBIA 1905
25 F S VIEN=$O(^TMP("VSIT",$J,VIEN),-1) Q:VIEN=""!(CNT>CNTLIMIT) D
26 .F S NUM=$O(^TMP("VSIT",$J,VIEN,NUM)) Q:NUM="" D
27 ..S ORX=^TMP("VSIT",$J,VIEN,NUM),INVDT=9999999-$P(ORX,U)
28 ..I $$ACTLOC^ORWU(+$P(ORX,U,2))=1 D
29 ...S ORY(CNT)=VIEN_U_ORX_U_INVDT,CNT=CNT+1
30 K ^TMP("VSIT",$J)
31 Q
32VSITAPPT(ORVY,PT,SDT,EDT,DUMMY) ; return past visits and future appointments for a patient between start and end dates
33 N NDT,CNT,I,TS,ORVSITY K ORVY D NOW^%DTC S NDT=+%,CNT=1 K %
34 D PTAPPTS^ORQPTQ2(.ORYA,PT,NDT,EDT,"") ;get future appointments
35 S I=0 F S I=$O(ORYA(I)) Q:I<1 I ORYA(I)'["No appts",+ORYA(I) D
36 .S ORVY(CNT)=$P(ORYA(I),U)_";s"_U_$P(ORYA(I),U,2)_U_"sched:"_U_$P(ORYA(I),U)
37 .S ORVY(CNT)=ORVY(CNT)_U_$P(ORYA(I),U,5),CNT=CNT+1
38 D LIST(.YV,PT,SDT,NDT,"") ;get past visits
39 S I=0 F S I=$O(YV(I)) Q:I<1 D
40 .S ORVY(CNT)=$P(YV(I),U)_";v"_U_$P($P(YV(I),U,3),";",2)
41 .I $P(YV(I),U,4)="H" D
42 ..S ORVY(CNT)=$P(YV(I),U)_";a"_U_"Inpatient Stay"_U_"admitted:"
43 .I $P(YV(I),U,4)'="H" S ORVY(CNT)=ORVY(CNT)_U_"visited:"
44 .S ORVY(CNT)=ORVY(CNT)_U_$P(YV(I),U,2)_U_$P(YV(I),U,8),CNT=CNT+1
45 S:+$G(ORVY(1))<1 ORVY(1)="^No appts or visits found."
46 S TSTDT=DT_".2359"
47 D DT^DILF("T",EDT,.EDT,"","")
48 I (EDT>TSTDT) D
49 . I '$L($P($G(ORYA(1)),U)),$L($P($G(ORYA(1)),U,2)),'$L($O(ORYA(1))) D
50 . . K ORVY S ORVY(1)=ORYA(1)
51 K ORYA,YV
52 Q
53DETNOTE(ORVY,ORPT,ORVIEN) ;return progress notes for a patient's visit
54 N ORTY,ORY,TDT,ORVI
55 S TDT=0
56 K ^TMP("TIULIST",$J) ;DBIA 2812
57 D NOTES^TIUSRVLV(.ORY,ORVIEN) ;DBIA 2812
58 I '+$O(^TMP("TIULIST",$J,0)) D Q
59 . S ORVY(1)="No Progress Notes for this visit."
60 S ORVI=1
61 F S TDT=$O(^TMP("TIULIST",$J,TDT)) Q:+TDT'>0 D
62 . N SEQ,TIEN S SEQ=0
63 . F S SEQ=$O(^TMP("TIULIST",$J,TDT,SEQ)) Q:+SEQ'>0 D
64 . . N TSEQ K ^TMP("TIUVIEW",$J) ;DBIA 2944
65 . . S TIEN=$P(^TMP("TIULIST",$J,TDT,SEQ),U)
66 . . D TGET^TIUSRVR1(.ORTY,TIEN) ;DBIA 2944
67 . . S TSEQ=0
68 . . F S TSEQ=$O(@ORTY@(TSEQ)) Q:TSEQ="" D
69 . . . S ORVY(ORVI)=@ORTY@(TSEQ),ORVI=ORVI+1
70 . . S ORVY(ORVI)=" ",ORVI=ORVI+1
71 . . S ORVY(ORVI)=" ",ORVI=ORVI+1
72 K ^TMP("TIULIST",$J)
73 Q
74DETSUM(ORVY,ORPT,ORVIEN) ;return discharge summary for a patient's visit
75 N CR,ORTY,ORY,TDT
76 S TDT=0
77 K ^TMP("TIULIST",$J)
78 D SUMMARY^TIUSRVLV(.ORY,ORVIEN)
79 I '+$O(^TMP("TIULIST",$J,0)) D Q
80 . S ORVY(1)="No Discharge Summary found for this stay."
81 F S TDT=$O(^TMP("TIULIST",$J,TDT)) Q:+TDT'>0 D
82 . N SEQ,TIEN S SEQ=0
83 . F S SEQ=$O(^TMP("TIULIST",$J,TDT,SEQ)) Q:+SEQ'>0 D
84 . . N TSEQ,ORVI K ^TMP("TIUVIEW",$J)
85 . . S TIEN=$P(^TMP("TIULIST",$J,TDT,SEQ),U)
86 . . D TGET^TIUSRVR1(.ORTY,TIEN)
87 . . S TSEQ=0,ORVI=1
88 . . F S TSEQ=$O(@ORTY@(TSEQ)) Q:TSEQ="" D
89 . . . S ORVY(ORVI)=@ORTY@(TSEQ),ORVI=ORVI+1
90 . . S ORVY(ORVI)=" ",ORVI=ORVI+1
91 . . S ORVY(ORVI)=" ",ORVI=ORVI+1
92 K ^TMP("TIULIST",$J)
93 Q
Note: See TracBrowser for help on using the repository browser.