ORY165A ;SLC/DAN Clean up non-canonic dates ;12/19/02 12:01
;;3.0;ORDER ENTRY/RESULTS REPORTING;**165**Dec 17, 1997
;DBIA Section
;10018 - DIE Call
;10063 - %ZTLOAD Call
;10141 - XPDUTL Call
;10070 - XMD Call
;This routine will find all order date/time entries that
;are non-canonical and enter them in canonic form.
N ORI,DA,ORMSG
S ORMSG(1)="A task is being queued in the background to identify"
S ORMSG(2)="any orders whose START DATE/TIME or STOP DATE/TIME field is a non-canonic"
S ORMSG(3)="number (having trailing zeros)."
S ORMSG(4)=""
S ORMSG(5)="These entries will be set to the correct canonic form"
S ORMSG(6)="by the background job and a mail message will be sent"
S ORMSG(7)="to the initiator of this patch at completion."
S ORMSG(8)=""
S ZTRTN="DQ^ORY165A",ZTIO="",ZTDESC="DATE/TIME ORDER field clean up - Patch 165",ZTDTH=$H,ZTSAVE("DUZ")="" D ^%ZTLOAD
S ORMSG(9)="The task number is "_$G(ZTSK)
D MES^XPDUTL(.ORMSG) I '$D(ZTQUEUED) N DIR,Y S DIR(0)="E",DIR("A")="Press return to continue installation" D ^DIR
Q
DQ ;Start processing here
N ORSR,ORVP,ORDG,ORI,DA
F ORSR="AD","AE" S ORI="00" F S ORI=$O(^OR(100,ORSR,ORI)) Q:ORI="" I ORI'=+ORI D ;if date/time is non-canonic then fix
.S DA="" F S DA=$O(^OR(100,ORSR,ORI,DA)) Q:DA="" D:ORSR="AD" SK^ORDD100 D:ORSR="AE" EK^ORDD100A D UPDATE
.Q
;Now check the AW xref, which has a different format
S ORSR="AW"
S ORVP="" F S ORVP=$O(^OR(100,ORSR,ORVP)) Q:ORVP="" S ORDG=0 F S ORDG=$O(^OR(100,ORSR,ORVP,ORDG)) Q:'+ORDG D
.S ORI="00" F S ORI=$O(^OR(100,ORSR,ORVP,ORDG,ORI)) Q:'+ORI I ORI'=+ORI S DA=0 F S DA=$O(^OR(100,ORSR,ORVP,ORDG,ORI,DA)) Q:'+DA D WK^ORDD100,UPDATE
.Q
D MAIL ;send email notifying initiator that clean up is finished
Q
UPDATE ;change date/time to canonic form and call DIE to reset cross references
N DIE,DR
S DIE="^OR(100,",DR=$S(ORSR="AD"!(ORSR="AW"):21,1:22)_"///"_+ORI
D ^DIE
D:ORSR="AW" WS^ORDD100 D:ORSR="AD" SS^ORDD100 D:ORSR="AE" ES^ORDD100A
Q
MAIL ; -- Send completion message to user who initiated conversion
N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,XMMG,ORTXT
S XMDUZ="PATCH OR*3*165 CLEAN-UP",XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
S ORTXT(1)="The START DATE/TIME and STOP DATE/TIME field clean up for patch OR*3*165"
S ORTXT(2)="completed at "_$$FMTE^XLFDT($$NOW^XLFDT)_"."
S XMTEXT="ORTXT(",XMSUB="PATCH OR*3*165 Clean Up COMPLETED"
D ^XMD
Q
ORY165A ;SLC/DAN Clean up non-canonic dates ;12/19/02 12:01
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**165**Dec 17, 1997
+2 ;DBIA Section
+3 ;10018 - DIE Call
+4 ;10063 - %ZTLOAD Call
+5 ;10141 - XPDUTL Call
+6 ;10070 - XMD Call
+7 ;This routine will find all order date/time entries that
+8 ;are non-canonical and enter them in canonic form.
+9 NEW ORI,DA,ORMSG
+10 SET ORMSG(1)="A task is being queued in the background to identify"
+11 SET ORMSG(2)="any orders whose START DATE/TIME or STOP DATE/TIME field is a non-canonic"
+12 SET ORMSG(3)="number (having trailing zeros)."
+13 SET ORMSG(4)=""
+14 SET ORMSG(5)="These entries will be set to the correct canonic form"
+15 SET ORMSG(6)="by the background job and a mail message will be sent"
+16 SET ORMSG(7)="to the initiator of this patch at completion."
+17 SET ORMSG(8)=""
+18 SET ZTRTN="DQ^ORY165A"
SET ZTIO=""
SET ZTDESC="DATE/TIME ORDER field clean up - Patch 165"
SET ZTDTH=$HOROLOG
SET ZTSAVE("DUZ")=""
DO ^%ZTLOAD
+19 SET ORMSG(9)="The task number is "_$GET(ZTSK)
+20 DO MES^XPDUTL(.ORMSG)
IF '$DATA(ZTQUEUED)
NEW DIR,Y
SET DIR(0)="E"
SET DIR("A")="Press return to continue installation"
DO ^DIR
+21 QUIT
DQ ;Start processing here
+1 NEW ORSR,ORVP,ORDG,ORI,DA
+2 ;if date/time is non-canonic then fix
FOR ORSR="AD","AE"
SET ORI="00"
FOR
SET ORI=$ORDER(^OR(100,ORSR,ORI))
IF ORI=""
QUIT
IF ORI'=+ORI
Begin DoDot:1
+3 SET DA=""
FOR
SET DA=$ORDER(^OR(100,ORSR,ORI,DA))
IF DA=""
QUIT
IF ORSR="AD"
DO SK^ORDD100
IF ORSR="AE"
DO EK^ORDD100A
DO UPDATE
+4 QUIT
End DoDot:1
+5 ;Now check the AW xref, which has a different format
+6 SET ORSR="AW"
+7 SET ORVP=""
FOR
SET ORVP=$ORDER(^OR(100,ORSR,ORVP))
IF ORVP=""
QUIT
SET ORDG=0
FOR
SET ORDG=$ORDER(^OR(100,ORSR,ORVP,ORDG))
IF '+ORDG
QUIT
Begin DoDot:1
+8 SET ORI="00"
FOR
SET ORI=$ORDER(^OR(100,ORSR,ORVP,ORDG,ORI))
IF '+ORI
QUIT
IF ORI'=+ORI
SET DA=0
FOR
SET DA=$ORDER(^OR(100,ORSR,ORVP,ORDG,ORI,DA))
IF '+DA
QUIT
DO WK^ORDD100
DO UPDATE
+9 QUIT
End DoDot:1
+10 ;send email notifying initiator that clean up is finished
DO MAIL
+11 QUIT
UPDATE ;change date/time to canonic form and call DIE to reset cross references
+1 NEW DIE,DR
+2 SET DIE="^OR(100,"
SET DR=$SELECT(ORSR="AD"!(ORSR="AW"):21,1:22)_"///"_+ORI
+3 DO ^DIE
+4 IF ORSR="AW"
DO WS^ORDD100
IF ORSR="AD"
DO SS^ORDD100
IF ORSR="AE"
DO ES^ORDD100A
+5 QUIT
MAIL ; -- Send completion message to user who initiated conversion
+1 NEW XMSUB,XMTEXT,XMDUZ,XMY,XMZ,XMMG,ORTXT
+2 SET XMDUZ="PATCH OR*3*165 CLEAN-UP"
SET XMY(.5)=""
IF $GET(DUZ)
SET XMY(DUZ)=""
+3 SET ORTXT(1)="The START DATE/TIME and STOP DATE/TIME field clean up for patch OR*3*165"
+4 SET ORTXT(2)="completed at "_$$FMTE^XLFDT($$NOW^XLFDT)_"."
+5 SET XMTEXT="ORTXT("
SET XMSUB="PATCH OR*3*165 Clean Up COMPLETED"
+6 DO ^XMD
+7 QUIT