Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ORY57

ORY57.m

Go to the documentation of this file.
ORY57 ;SLC/MKB - Postinit for patch OR*3*57 ;6/2/99  15:35
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**57**;Dec 17, 1997
 ;
POST ; -- task job for EN
 ;
 N ZTRTN,ZTDTH,ZTIO,ZTDESC,ZTSK,MSG
 S ZTRTN="EN^ORY57",ZTDTH=$H,ZTIO="",ZTDESC="Remove bad B xref nodes"
 D ^%ZTLOAD S MSG="Task "_$S($G(ZTSK):"#"_ZTSK,1:"not")_" started."
 D MES^XPDUTL(MSG)
 Q
 ;
EN ; -- fix xrefs corrupted by Convert Protocols option
 ;
 N ORIDX,ORDITEM,ORDMENU,ORDA,ORITM,ORPOS
 S ORIDX="^ORD(101.41,""AD"")"
 F  S ORIDX=$Q(@ORIDX) Q:ORIDX'?1"^ORD(101.41,""AD"",".E  D
 . S ORDITEM=+$P(ORIDX,",",3),ORDMENU=+$P(ORIDX,",",4),ORDA=+$P(ORIDX,",",5)
 . S ORITM=$G(^ORD(101.41,ORDITEM,10,ORDA,0)) Q:$P(ORITM,U,2)'=ORDITEM  ;ok
 . K ^ORD(101.41,ORDITEM,10,ORDA) D CKDLG ;ck ORDITEM for bad data
 . D XREF S ORPOS=+$P(ORITM,U)
 . I $D(^ORD(101.41,ORDMENU,10,ORDA,0))!$O(^ORD(101.41,ORDMENU,10,"B",ORPOS,0)) K @ORIDX Q
 . S ^ORD(101.41,ORDMENU,10,ORDA,0)=$$XUTL
 Q
 ;
XREF ; -- rebuild Item B&D xrefs for ORDMENU
 N LAST,TOTAL,NODE,DA S (LAST,TOTAL)=0
 K ^ORD(101.41,ORDMENU,10,"B"),^ORD(101.41,ORDMENU,10,"D") S DA=0
 F  S DA=$O(^ORD(101.41,ORDMENU,10,DA)) Q:DA'>0  S NODE=$G(^(DA,0)) D
 . S:NODE ^ORD(101.41,ORDMENU,10,"B",+$P(NODE,U),DA)=""
 . S:$P(NODE,U,2) ^ORD(101.41,ORDMENU,10,"D",+$P(NODE,U,2),DA)=""
 . S LAST=DA,TOTAL=TOTAL+1
 S $P(^ORD(101.41,ORDMENU,10,0),U,3,4)=LAST_U_TOTAL
 Q
 ;
XUTL() ; -- find ORDMENU item in ^XUTL, return data
 N ORPITEM,ORPMENU,ORNM,XUTL,OLDPOS,ORY
 S ORNM=$P($G(^ORD(101.41,ORDMENU,0)),U),ORPMENU=$$FIND1^DIC(101,,"O",ORNM)
 S ORNM=$P($G(^ORD(101.41,ORDITEM,0)),U),ORPITEM=$$FIND1^DIC(101,,"O",ORNM)
 S ORY=$P(ORITM,U,1,2) G:(ORPMENU'>0)!(ORPITEM'>0) XQ
 S OLDPOS=$$FINDXUTL^ORCMEDT1(ORPMENU,ORPITEM) G:OLDPOS'>0 XQ
 S XUTL=$G(^XUTL("XQORM",ORPMENU_";ORD(101,",OLDPOS,0))
 S:$P(XUTL,U,2)=ORPITEM ORY=ORY_U_$P(XUTL,U,4)_U_$S($P(XUTL,U,3)'=$P($G(^ORD(101.41,ORDITEM,0)),U,2):$P(XUTL,U,3),1:"")
XQ Q ORY
 ;
CKDLG ; -- ck ORDITEM for bad data
 Q:'$D(^ORD(101.41,ORDITEM,10))  N ORIDX,OROOT,ORP,ORI
 S ORIDX="^ORD(101.41,"_ORDITEM_",10,""A"")",OROOT="^ORD(101.41,"_ORDITEM_",10,"""
 F  S ORIDX=$Q(@ORIDX) Q:$E(ORIDX,1,$L(OROOT))'=OROOT  D
 . S ORP=$L(ORIDX,","),ORI=+$P(ORIDX,",",ORP) ;last piece=DA
 . I ORI=ORDA K @ORIDX
 Q