source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDWLQSC1.m@ 846

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

initial load of WorldVistAEHR

File size: 4.3 KB
Line 
1SDWLQSC1 ;IOFO BAY PINES/ESW - WAITING LIST-SC PRIORITY BACKGROUND ;09/02/2004 2:10 PM [4/21/05 8:04pm] ; Compiled December 20, 2006 09:00:39
2 ;;5.3;scheduling;**446**;AUG 13, 1993;Build 77
3 ;
4 ;
5 ;This routine will be called by SDWLQSC that run as a background job. It is created because SDWLQSC exceeded 10000.
6 Q
7EN2 ;Part 2 - checks status of appts linked to closed EWL entries.
8 N IEN,APPT,WLAPPT,CLINIC,SDAPPT,WLSTAT,STATUS,NN,SDFORM,EE
9 S (IEN,APPT,WLAPPT,CLINIC,SDAPPT,WLSTAT,STATUS,NN,SDFORM,EE)=""
10 S EE=0,DFN=0
11 F S DFN=$O(^SDWL(409.3,"B",DFN)) Q:DFN<1 D
12 .K ^TMP("ENC",$J)
13 .S IEN="" F S IEN=$O(^SDWL(409.3,"B",DFN,IEN)) Q:IEN<1 D
14 ..S STATUS="" S STATUS=$$GET1^DIQ(409.3,IEN_",",23,"I")
15 ..IF STATUS="C" D
16 ...IF $G(^SDWL(409.3,IEN,"SDAPT")) D
17 ....S CLINIC=$$GET1^DIQ(409.3,IEN_",",13.2,"I") IF CLINIC>0 D
18 .....S WLAPPT=$$GET1^DIQ(409.3,IEN_",",13,"I"),WLSTAT=$$GET1^DIQ(409.3,IEN_",",21,"I")
19 .....IF WLSTAT="SA" D APPT^SDWLQSC(CLINIC,IEN) ; call creates ^TMP("SDWLQSC3",$J)
20 ..I STATUS="O" S SDPCL=$$GET1^DIQ(409.3,IEN_",",8,"I"),SDPSP=$$GET1^DIQ(409.3,IEN_",",7,"I") I SDPCL>0!(SDPSP>0) D
21 ...S (SDCL,SDSP)=""
22 ...I SDPCL>0 S SDCL=$$GET1^DIQ(409.32,SDPCL_",",.01,"I")
23 ...I SDPSP>0 S SDSP=$$GET1^DIQ(409.31,SDPSP_",",.01,"I")
24 ...S SDORG=$$GET1^DIQ(409.3,IEN_",",1,"I")
25 ...N SDD S SDD=$$CHKENC(DFN,SDORG,SDCL,SDSP,0) ; 0 - the first appt/enc only
26 .IF $D(^TMP("ENC",$J)) D MESS9^SDWLMSG(DFN) K ^TMP("ENC",$J)
27 IF $D(^TMP("SDWLQSC3",$J)) D MESS2^SDWLMSG
28 Q
29CHKENC(DFN,SDORG,SDCL,SDSP,PROC) ;check if any encounters are present
30 ;SDORG - orig DATE of EWL entry
31 ;SDCL - pointer to file 44
32 ;SDSP - pointer to fiel # 40.7
33 ;PROC - 0 -create the first appt/enc only
34 ; 1 - multiple appt/enc ; called from outside for a list of appointment(s)/encounter(s)
35 S CNT=0,EE=0
36 N SDEND S X1=SDORG,X2=119 D C^%DTC S SDEND=X
37 K ^TMP("SD ENCOUNTER LIST",$J) K ^TMP($J,"SDAMA301") K ^TMP($J,"APPT") K ^TMP("ENC",$J)
38 N SDARR S SDARR(1)=SDORG_";"_SDEND
39 S SDARR(3)="R" ;only kept/scheduled
40 S SDARR(4)=DFN
41 I SDCL S SDARR(2)=SDCL
42 I SDSP S SDARR(13)=$$GET1^DIQ(40.7,SDSP_",",1) ; STOP CODE
43 S SDARR("FLDS")="1;2;3;4;10;13;14;17"
44 S SDAPPT=$$SDAPI^SDAMA301(.SDARR)
45 I SDAPPT D
46 .I 'PROC N SS,SDP S SS="^TMP("_$J_",""SDAMA301"")" S SDP=@$Q(@SS) D ; string containg app data
47 ..; see example: SDP=3060615.09^359;11CP SURG^^7171882;WOLF,ED^^^^^^^^
48 ..N CL,SDC S CL=+$P(SDP,U,2) S SDC=$$GET1^DIQ(44,CL_",",.01),SDC=$E(SDC,1,17)
49 ..S SDNAM=$$GET1^DIQ(2,DFN_",",.01),SDNAM=$E(SDNAM,1,19)
50 ..N Y,SDAPPT S Y=+SDP D DD^%DT S SDAPPT=Y
51 ..N Y S Y=SDORG D DD^%DT S SDORGD=Y S SDORGD=$S(SDCL>0:"C-",1:"S-")_SDORGD
52 ..S SDFORM=$$FORM^SDFORM(SDNAM,22,SDC,20,SDORGD,20,SDAPPT,21)
53 ..S EE="" S EE=+$O(^TMP("ENC",$J,EE),-1)+1 S ^TMP("ENC",$J,EE)=SDFORM
54 .I PROC N SS S SS="^TMP("_$J_",""SDAMA301"")" F S SS=$Q(@SS) Q:SS'["SDAMA301" D
55 ..N CL,SDP S SDP=@SS S SD=+SDP,CL=+$P(SDP,U,2)
56 ..S SCNT=$O(^TMP($J,"APPT",""),-1)+1
57 ..S ^TMP($J,"APPT",SCNT)=^TMP($J,"SDAMA301",DFN,CL,SD)
58 ..N SDCLIN S SDCLIN=$$CLIN^SDWLBACC(CL),SDINST=$P(SDCLIN,U),SDFAC=$P(SDCLIN,U,2),SDINSTE=$P(SDCLIN,U,3)
59 ..S $P(^TMP($J,"APPT",SCNT),"^",15)=SDINST_";"_SDINSTE
60 ..S $P(^TMP($J,"APPT",SCNT),"^",16)=SDFAC
61 ..N SDD3 S SDD3=$S(SD<DT:"KEPT",1:"SCHEDULED") S $P(^TMP($J,"APPT",SCNT),U,3)=";"_SDD3
62 I 'PROC I EE Q EE
63 N ARR,SQ K ^TMP("SD ENCOUNTER LIST",$J) D LISTPAT^SDOERPC(.ARR,DFN,SDORG,SDEND)
64 I $D(@ARR) S CNT=0,SQ="" F S SQ=$O(^TMP("SD ENCOUNTER LIST",$J,SQ)) Q:SQ="" D I 'PROC,EE=1 Q
65 .I SDCL Q:$P(^TMP("SD ENCOUNTER LIST",$J,SQ),U,4)'=SDCL S STR=$P(^TMP("SD ENCOUNTER LIST",$J,SQ),";;",2)
66 .I SDSP Q:$P(^TMP("SD ENCOUNTER LIST",$J,SQ),U,3)'=SDSP S STR=$P(^TMP("SD ENCOUNTER LIST",$J,SQ),";;",2)
67 .S CL=$P(STR,U,4)
68 .S SDC=$$GET1^DIQ(44,CL_",",.01),SDC=$E(SDC,1,17)
69 .S SDNAM=$$GET1^DIQ(2,DFN_",",.01),SDNAM=$E(SDNAM,1,19)
70 .N Y S Y=$P(STR,U) D DD^%DT S SDAPPT=Y,SDAPPT=SDAPPT_"-E"
71 .N Y S Y=SDORG D DD^%DT S SDORGD=Y S SDORGD=$S(SDCL>0:"C-",1:"S-")_SDORGD ; C - clinic EWL entry ; S - specialty EWL entry
72 .I 'PROC S SDFORM=$$FORM^SDFORM(SDNAM,22,SDC,20,SDORGD,20,SDAPPT,21) D Q
73 ..S EE="" S EE=+$O(^TMP("ENC",$J,EE),-1)+1 S ^TMP("ENC",$J,EE)=SDFORM
74 .I PROC S SCNT=$O(^TMP($J,"APPT",""),-1)+1 D
75 ..I +$P(STR,U,7) S ^TMP($J,"APPT",SCNT)=$P(STR,U)_U_CL_";"_SDC_"^^"_DFN_";"_SDNAM D
76 ...S $P(^TMP($J,"APPT",SCNT),U,18)=$P(STR,U,7)
77 ...S $P(^TMP($J,"APPT",SCNT),U,3)=";CHECKED OUT"
78 I PROC I $D(^TMP($J,"APPT")) S EE=1
79 Q EE
Note: See TracBrowser for help on using the repository browser.