1 | QACI1 ; OAKOIFO/TKW - DATA MIGRATION - AUTO-CLOSE ROCS ;4/25/05 16:51
|
---|
2 | ;;2.0;Patient Representative;**19**;07/25/1995;Build 55
|
---|
3 | EN ; Auto-close open ROCs with a Date of Contact prior to user-selected date.
|
---|
4 | I $D(^XTMP("QACMIGR","ROC","U")) D
|
---|
5 | . W !!,"*** CAUTION! You have already moved some ROCs to the staging area. To migrate"
|
---|
6 | . W !,"any changes to these ROCs, you will need to run the option to move data to"
|
---|
7 | . W !,"the staging area again. ***" Q
|
---|
8 | I $D(^XTMP("QACMIGR","ROC","D")) D
|
---|
9 | . W !!,"*** You cannot auto-close ROCs that have already migrated into PATS ***" Q
|
---|
10 | I '$D(^XTMP("QACMIGR","ROC","E")) D Q
|
---|
11 | . W !!,"*** CAUTION! You have not yet run the option to generate the error report.",!," You must run it before auto-closing ROCs!" Q
|
---|
12 | N PATSCLDT,ROCIEN,ROC0,ROC2,ROCNO,CONVROC,CONDATE,INFOBY,ENTBY,STATION,TXT,EDITEBY,EDITIBY,EDITDIV,EDITITXT,EDITRTXT,PATSFDA,PATSIENS,DOTCNT,PATSCDT,CURRDT
|
---|
13 | N PATSCNT S PATSCNT=0
|
---|
14 | S CURRDT=$$DT^XLFDT()
|
---|
15 | S PATSCDT=$$FMTE^XLFDT(CURRDT)
|
---|
16 | S DOTCNT=0
|
---|
17 | ; Set default text to replace null issue text or null resolution text
|
---|
18 | S TXT(1)="This R.O.C. was auto-closed prior to migration to PATS"
|
---|
19 | ; Prompt them for auto-close date
|
---|
20 | S PATSCLDT=$$DEFDATE^QACI1A
|
---|
21 | W !!!,"You have asked to auto-close Open ROCs with a Date of Contact prior to",!,"the beginning of the previous quarter -- "_$$FMTE^XLFDT(PATSCLDT),!
|
---|
22 | D Q:Y'=1
|
---|
23 | . N DIR S DIR(0)="YO"
|
---|
24 | . S DIR("A")="Are you sure"
|
---|
25 | . S DIR("B")="YES"
|
---|
26 | . D ^DIR Q
|
---|
27 | W !,"."
|
---|
28 | ;
|
---|
29 | ; Initialize header for all migration data so Kernel will kill global in 30 days.
|
---|
30 | S $P(^XTMP("QACMIGR",0),"^",1,2)=$$FMADD^XLFDT(CURRDT,30)_"^"_CURRDT
|
---|
31 | ; Set a flag indicating that auto-close in in process
|
---|
32 | S $P(^XTMP("QACMIGR","AUTO","C"),"^",2)=1
|
---|
33 | ; Read through CONSUMER CONTACTS and auto-close ROCs.
|
---|
34 | F ROCIEN=0:0 S ROCIEN=$O(^QA(745.1,ROCIEN)) Q:'ROCIEN S ROC0=$G(^(ROCIEN,0)) D
|
---|
35 | . S DOTCNT=DOTCNT+1 I DOTCNT=500 W "." S DOTCNT=0
|
---|
36 | . ; Quit if ROC is already closed or if ROC number is null.
|
---|
37 | . Q:$P($G(^QA(745.1,ROCIEN,7)),"^",2)="C"
|
---|
38 | . S ROCNO=$P(ROC0,"^") Q:ROCNO=""
|
---|
39 | . S CONVROC=$$CONVROC^QACI2C(ROCNO)
|
---|
40 | . ; Quit is ROC has errors, or has been migrated.
|
---|
41 | . Q:$D(^XTMP("QACMIGR","ROC","E",ROCNO_" "))
|
---|
42 | . Q:$D(^XTMP("QACMIGR","ROC","D",CONVROC))
|
---|
43 | . ; Quit if date of contact is past the close date, or if it's null
|
---|
44 | . S CONDATE=$P(ROC0,"^",2) Q:CONDATE>PATSCLDT
|
---|
45 | . S CONDATE=$$FMTE^XLFDT(CONDATE,5)
|
---|
46 | . Q:CONDATE=""
|
---|
47 | . S ROC2=$G(^QA(745.1,ROCIEN,2))
|
---|
48 | . S (EDITEBY,EDITIBY,EDITDIV,EDITITXT,EDITRTXT)=0
|
---|
49 | . ;Extract and check DIVISION. Quit if station number is invalid.
|
---|
50 | . S STATION=+$P(ROC0,"^",16)
|
---|
51 | . I 'STATION S STATION=$$LKUP^XUAF4($P(ROCNO,".")),EDITDIV=1
|
---|
52 | . Q:$$STA^XUAF4(STATION)=""
|
---|
53 | . ;Extract info taken by and entered by--quit if both are null.
|
---|
54 | . S INFOBY=$P(ROC0,"^",6),ENTBY=$P(ROC0,"^",7)
|
---|
55 | . I ENTBY="" S ENTBY=INFOBY,EDITEBY=1
|
---|
56 | . I INFOBY="" S INFOBY=ENTBY,EDITIBY=1
|
---|
57 | . Q:INFOBY=""
|
---|
58 | . ;Make sure there is at least one issue code on the ROC, unless
|
---|
59 | . ; the date of contact is in or prior to FY 2003.
|
---|
60 | . S I=$O(^QA(745.1,ROCIEN,3,0)),X=$P($G(^QA(745.1,ROCIEN,3,+I,0)),"^"),X=$P($G(^QA(745.2,+X,0)),"^")
|
---|
61 | . I X="",$P(ROC0,"^",2)>3030930 Q
|
---|
62 | . ; Issue Text
|
---|
63 | . S TXT="" D
|
---|
64 | .. F I=0:0 S I=$O(^QA(745.1,ROCIEN,4,I)) Q:'I S TXT=$G(^(I,0)) Q:TXT]""
|
---|
65 | .. Q
|
---|
66 | . I TXT="" S EDITITXT=1
|
---|
67 | . ; Resolution Text
|
---|
68 | . S TXT="" D
|
---|
69 | .. F I=0:0 S I=$O(^QA(745.1,ROCIEN,6,I)) Q:'I S TXT=$G(^(I,0)) Q:TXT]""
|
---|
70 | .. Q
|
---|
71 | . I TXT="" S EDITRTXT=1
|
---|
72 | . ;
|
---|
73 | . ; Set status of ROC to Closed and update any missing required fields
|
---|
74 | . ; with their default values
|
---|
75 | . K ^TMP("DIERR",$J)
|
---|
76 | . K PATSFDA S PATSIENS=ROCIEN_","
|
---|
77 | . S PATSFDA(745.1,PATSIENS,27)="C"
|
---|
78 | . S PATSFDA(745.1,PATSIENS,26)=CURRDT
|
---|
79 | . I EDITEBY S PATSFDA(745.1,PATSIENS,9)=ENTBY
|
---|
80 | . I EDITIBY S PATSFDA(745.1,PATSIENS,8)=INFOBY
|
---|
81 | . I EDITDIV S PATSFDA(745.1,PATSIENS,37)=STATION
|
---|
82 | . D FILE^DIE("","PATSFDA")
|
---|
83 | . K PATSFDA
|
---|
84 | . I $D(^TMP("DIERR",$J)) D REOPEN Q
|
---|
85 | . ; Update Issue Text if necessary.
|
---|
86 | . I EDITITXT D WP^DIE(745.1,PATSIENS,22,"","TXT")
|
---|
87 | . I $D(^TMP("DIERR",$J)) D REOPEN Q
|
---|
88 | . ; Update Resolution Text if necessary.
|
---|
89 | . I EDITRTXT D WP^DIE(745.1,PATSIENS,25,"","TXT")
|
---|
90 | . I $D(^TMP("DIERR",$J)) D REOPEN Q
|
---|
91 | . ; Build a list of ROCs that were auto-closed.
|
---|
92 | . S ^XTMP("QACMIGR","AUTO","C",ROCNO_" ")=PATSCDT_"^"_EDITEBY_"^"_EDITIBY_"^"_EDITITXT_"^"_EDITRTXT_"^"_EDITDIV
|
---|
93 | . ; Update the count of ROCs that were autoclosed
|
---|
94 | . S PATSCNT=PATSCNT+1
|
---|
95 | . Q
|
---|
96 | W "Done."
|
---|
97 | ; Update count of ROCs autoclosed, set flag to indicate process is done.
|
---|
98 | S PATSCNT=$P(^XTMP("QACMIGR","AUTO","C"),"^")+PATSCNT D
|
---|
99 | . I PATSCNT=0 K ^XTMP("QACMIGR","AUTO","C") Q
|
---|
100 | . S ^XTMP("QACMIGR","AUTO","C")=PATSCNT_"^0" Q
|
---|
101 | ; Print report of ROCs auto-closed.
|
---|
102 | D ENRPT2^QACI1A
|
---|
103 | Q
|
---|
104 | ;
|
---|
105 | REOPEN ; Re-open ROC if an error occurred during FileMan update
|
---|
106 | K PATSFDA,^TMP("DIERR",$J)
|
---|
107 | S PATSFDA(745.1,PATSIENS,27)="O"
|
---|
108 | D FILE^DIE("","PATSFDA")
|
---|
109 | K PATSFDA Q
|
---|
110 | ;
|
---|
111 | ;
|
---|