source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORY110.m@ 1365

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

initial load of WorldVistAEHR

File size: 2.9 KB
RevLine 
[613]1ORY110 ;SLC/DAN--Clean up orderable items file ;1/4/02 13:57
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**110**;Dec 17, 1997
3 N IEN,DIK,IEN6,COUNT
4 K ^ORD(101.43,"B") ;Delete "B" cross reference to be rebuilt below
5 D MES^XPDUTL("Re-indexing the B cross reference of the SYNONYM field...")
6 S IEN=0 F S IEN=$O(^ORD(101.43,IEN)) Q:'+IEN D
7 .I $G(^ORD(101.43,IEN,0))="" K ^ORD(101.43,IEN) Q ;Delete extraneous nodes when 0 node doesn't exist
8 .I $O(^ORD(101.43,IEN,2,0)) K ^ORD(101.43,IEN,2,"B") S DIK="^ORD(101.43,IEN,2,",DIK(1)=".01^B",DA(1)=IEN D ENALL^DIK ;Reset "B" cross reference for synonym multiple
9 ;
10 K DIK,DA
11 D MES^XPDUTL("Re-indexing the B cross reference of the ORDERABLE ITEMS file")
12 S DIK="^ORD(101.43,",DIK(1)=".01^B" D ENALL^DIK ;Rebuild B cross reference at the file level
13 ;
14 D BMES^XPDUTL("Reviewing ORDER DIALOG file for incorrect pointer default values.")
15 S IEN=0 F S IEN=$O(^ORD(101.41,IEN)) Q:'+IEN I $D(^(IEN,6)) D
16 .S IEN6=0 F S IEN6=$O(^ORD(101.41,IEN,6,IEN6)) Q:'+IEN6 I $L($G(^(IEN6,1)),"^")>1 S ^ORD(101.41,IEN,6,IEN6,1)=$P(^ORD(101.41,IEN,6,IEN6,1),"^"),COUNT=$G(COUNT)+1
17 D MES^XPDUTL("Finished."_$S($G(COUNT)>0:" Fixed "_$G(COUNT)_" node"_$S($G(COUNT)>1:"s.",1:"."),1:""))
18 ;
19 S ZTRTN="DQ^ORY110",ZTDTH=$H,ZTDESC="Patch OR*3*110 ORDER file cleanup",ZTSAVE("DUZ")="",ZTIO="" D ^%ZTLOAD
20 D MES^XPDUTL("Starting ORDER file clean-up job in the background. Task # "_+$G(ZTSK))
21 Q
22 ;
23DQ ;Entry point for background job to clean up ORDER file
24 N IEN,SUB,COUNT
25 S IEN=$$GETIEN(3010826.24)-1 ;get first IEN for date, subtract one so first IEN is reviewed
26 I IEN=-1 D MAIL Q
27 F S IEN=$O(^OR(100,IEN)) Q:'+IEN D
28 .S SUB=0 F S SUB=$O(^OR(100,IEN,.1,SUB)) Q:'+SUB D
29 ..I $L($G(^(SUB,0)),"^")>1 D
30 ...N DIK,DA
31 ...K ^OR(100,IEN,.1,"B",$G(^OR(100,IEN,.1,SUB,0))) ;delete current B xref
32 ...S ^OR(100,IEN,.1,SUB,0)=$P(^OR(100,IEN,.1,SUB,0),"^") ;remove extra pieces
33 ...S DIK="^OR(100,IEN,.1,",DIK(1)=".01^B" ;set index to be reset and global node
34 ...S DA=SUB,DA(1)=IEN ;DA is subfile IEN, DA(1) is file level IEN
35 ...D EN1^DIK ;Set B xref for this entry
36 ...Q
37 .S SUB=0 F S SUB=$O(^OR(100,IEN,4.5,SUB)) Q:'+SUB D
38 ..I $L($G(^(SUB,1)),"^")>1 S ^(1)=$P(^(1),"^"),COUNT=$G(COUNT)+1 ;remove extra pieces, count changes
39 ;
40 D MAIL ;Send mail notification upon completion
41 Q
42 ;
43GETIEN(STDT) ;Find first IEN associated with given start date
44 N DONE,IEN
45 S (DONE,IEN)=0
46 F S STDT=$O(^OR(100,"AF",STDT)) Q:'+STDT!(DONE) D
47 .S IEN=0 F S IEN=$O(^OR(100,"AF",STDT,IEN)) Q:'+IEN I $O(^(IEN,0))=1 S DONE=1 Q ;Find first ORDER that is a new order
48 Q IEN
49 ;
50MAIL ;Send email when finished
51 N XMSUB,XMTEXT,XMDUZ,ORTXT,XMY
52 S XMDUZ="Patch OR*3*110 Post-Init"
53 S XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
54 S ORTXT(1)="The ORDER file clean-up initiated by patch OR*3*110 has completed."
55 S ORTXT(2)=""
56 S ORTXT(3)="There were "_$S($G(COUNT):COUNT,1:"no")_" changes made to the ORDER file."
57 S XMTEXT="ORTXT("
58 S XMSUB="Patch OR*3*110 ORDER file clean-up completed."
59 D ^XMD
60 Q
Note: See TracBrowser for help on using the repository browser.