source: WorldVistAEHR/trunk/r/PATIENT_REPRESENTATIVE-QAC/QAC20PST.m@ 1015

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

initial load of WorldVistAEHR

File size: 4.0 KB
RevLine 
[613]1QAC20PST ;ALB/TKW,RRG - POST-INSTALL FOR PATCH QAC*2*20 Repair ROC numbers ;12/06/06 14:30
2 ;;2.0;Patient Representative;**20**;07/25/1995;Build 7
3 ;
4 ;
5ENV ; Environment Check
6 ;
7 Q:'$G(XPDENV)
8 W ! K %DT D NOW^%DTC S %DT="RAEX",%DT(0)=%,%DT("A")="Queue the Post-Install to run at what Date@Time: "
9 D ^%DT K %DT I $D(DTOUT)!(Y<0) W !!,"Cannot install the patch without queuing the post-install. Install aborted!",! S XPDABORT=2 Q
10 S @XPDGREF@("QAC20")=Y K DTOUT
11 Q
12 ;
13EN ;
14 S ZTDTH=@XPDGREF@("QAC20")
15 S ZTRTN="START^QAC20PST",ZTDESC="Background job to repair ROC numbers",ZTIO="" D ^%ZTLOAD K ZTDTH,ZTRTN,ZTIO,ZTDESC
16 I $D(ZTSK)&('$D(ZTQUEUED)) D BMES^XPDUTL("Task Queued!")
17 K ZTSK,ZTQUEUED
18 Q
19 ;
20START ;
21 N PARENT,ROCNO,NEWROC,IEN,QA0,YR,DIR,I,Y,TIME
22 K ^TMP("QACROCNO",$J)
23 ; Set up mailman message format
24 N LCNT,LINE,LINE2,MESS,MSG,MSG1
25 S LCNT=1,$P(LINE,"-",80)="",$P(LINE2,"=",80)=""
26 K ^TMP($J)
27 S MESS="Repair ROC numbers",MSG1=" beginning at "
28 D TIME
29 S ^TMP($J,"P20",LCNT)="",LCNT=LCNT+1
30 ;
31 ; Find parent station number from QUALITY ASSURANCE SITE PARAMETERS file
32 S PARENT=$P($G(^QA(740,1,0)),"^"),PARENT=$$STA^XUAF4(PARENT)
33 I PARENT="" S ^TMP($J,"P20",LCNT)="Cannot find Parent Institution",LCNT=LCNT+1 D XMT Q
34 ;
35 ; Build lists of ROCs with invalid numbers by year.
36 F I=0:0 S I=$O(^QA(745.1,I)) Q:'I S QA0=$G(^(I,0)),ROCNO=$P(QA0,"^") D
37 . I ROCNO="" S ^TMP("QACROCNO",$J,I," ")="" Q
38 . S YR=$E($P(QA0,"^",2),1,3)
39 . I ($P(ROCNO,".")'=PARENT)!(ROCNO'?3N.AN1"."6N) D
40 .. S:YR YR(YR)=""
41 .. S ^TMP("QACROCNO",$J,I,ROCNO)=YR Q
42 . Q
43 I '$D(^TMP("QACROCNO",$J)) S ^TMP($J,"P20",LCNT)="No invalid ROC numbers were found.",LCNT=LCNT+1 D XMT Q
44 ;
45 ; Find default 'last sequential number' for ROCs in each year.
46 S YR=""
47 F S YR=$O(YR(YR)) Q:YR="" D
48 . S ROCNO=$O(^QA(745.1,"B",PARENT_"."_$E(YR,2,3)_"9999"),-1)
49 . I $P(ROCNO,".")=PARENT,$E($P(ROCNO,".",2),1,2)=$E(YR,2,3) S YR(YR)=+$E($P(ROCNO,".",2),3,6) Q
50 . S YR(YR)=0 Q
51 ;
52 ; Assign a suggested new number for each ROC
53 F IEN=0:0 S IEN=$O(^TMP("QACROCNO",$J,IEN)) Q:'IEN D
54 . S ROCNO="" F S ROCNO=$O(^TMP("QACROCNO",$J,IEN,ROCNO)) Q:ROCNO="" D
55 .. S YR=^TMP("QACROCNO",$J,IEN,ROCNO) Q:YR="" Q:'$D(YR(YR))
56 .. S I=YR(YR)+1,YR(YR)=I
57 .. S NEWROC=PARENT_"."_$E(YR,2,3)_$E("000",1,(4-$L(I)))_I
58 .. S $P(^TMP("QACROCNO",$J,IEN,ROCNO),"^",2)=NEWROC Q
59 . Q
60 ;
61 ;
62FIX ; Repair ROC numbers
63 N FDA,CNT
64 S CNT=0
65 F IEN=0:0 S IEN=$O(^TMP("QACROCNO",$J,IEN)) Q:'IEN D
66 . S ROCNO="" F S ROCNO=$O(^TMP("QACROCNO",$J,IEN,ROCNO)) Q:ROCNO="" D:ROCNO'=" "
67 .. S NEWROC=$P(^TMP("QACROCNO",$J,IEN,ROCNO),"^",2) I NEWROC="" S ^TMP($J,"P20",LCNT)="ROC number "_ROCNO_" could not be changed. Please review manually for a missing Date of Contact.",LCNT=LCNT+1 Q
68 .. S ^TMP($J,"P20",LCNT)="ROC Number changed from "_ROCNO_" to "_NEWROC,LCNT=LCNT+1
69 .. K FDA S FDA(745.1,IEN_",",.01)=NEWROC
70 .. D FILE^DIE("","FDA")
71 .. S CNT=CNT+1
72 .. Q
73 . Q
74 S ^TMP($J,"P20",LCNT)=CNT_" ROC Numbers have been corrected.",LCNT=LCNT+1
75 D XMT
76 Q
77 ;
78ENRPT ; Setup to print report of invalid ROCs
79 N ZTSAVE
80 S ZTSAVE("PATSHDR")=""
81 D EN^XUTMDEVQ("DQRPT^QAC20PST","Report of Invalid ROCs",.ZTSAVE)
82 Q
83 ;
84DQRPT ; Print report of invalid ROCs
85 N PAGENO,LNCNT,ROCNO,IEN,NEWROC,HDDATE,%,%H,%I
86 S PAGENO=1,LNCNT=0
87 D NOW^%DTC S HDDATE=$$FMTE^XLFDT(%)
88 U IO D HDR
89 F IEN=0:0 S IEN=$O(^TMP("QACROCNO",$J,IEN)) Q:'IEN D
90 . S ROCNO="" F S ROCNO=$O(^TMP("QACROCNO",$J,IEN,ROCNO)) Q:ROCNO="" D
91 .. D:LNCNT>55 HDR
92 .. S NEWROC=$P(^TMP("QACROCNO",$J,IEN,ROCNO),"^",2)
93 .. W !,IEN,?20,$S(ROCNO=" ":"Missing",1:ROCNO),?45,$S(NEWROC="":"Cannot be fixed",1:NEWROC)
94 .. S LNCNT=LNCNT+1 Q
95 . Q
96 Q
97 ;
98HDR W #,!,"Report of Invalid ROCs",?43,HDDATE,?68,"Page "_PAGENO,!
99 W "IEN",?20,"Old ROC Number",?45,"Suggested New ROC Number",!
100 N X S X="",$P(X,"-",78)=""
101 W X,!
102 S LNCNT=0,PAGENO=PAGENO+1 Q
103 ;
104TIME ;Get current time
105 D NOW^%DTC
106 S Y=%
107 D DD^%DT
108 S TIME=Y
109 Q
110 ;
111XMT ;Send report via mail message
112 I $D(^TMP($J,"P20")) D
113 . N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
114 . S XMDUZ=.5
115 . S XMSUB="QAC*2*20 POST INSTALL RESULTS"
116 . S XMTEXT="^TMP($J,""P20"","
117 . S XMY(DUZ)=""
118 . D ^XMD
119 ;
Note: See TracBrowser for help on using the repository browser.