XQA366PO ;ISC-SF.SEA/JLI - POST INSTALL FOR SURROGATES FOR ALERTS ;9/6/05  14:35
 ;;8.0;KERNEL;**366**;Jul 10, 1995
 ;;
 ; go through alert file and convert any current surrogates to active entries in surrogate multiple
 N XQAI,XQANOW,X0
 S XQANOW=$$NOW^XLFDT()
 F XQAI=0:0 S XQAI=$O(^XTV(8992,XQAI)) Q:XQAI'>0  S X0=$G(^(XQAI,0)) S:X0="" ^XTV(8992,XQAI,0)=XQAI D
 . N XQALSURO,XQALSTRT,XQALEND
 . S XQALSURO=$P(X0,U,2),XQALSTRT=$P(X0,U,3),XQALEND=$P(X0,U,4)
 . I XQALSURO="" Q
 . I $D(^XTV(8992,XQAI,2)) Q
 . N XQAIENS,XQAFDA
 . I XQALSTRT="" S XQALSTRT=XQANOW,XQAFDA(8992,XQAI_",",.03)=XQANOW D FILE^DIE("","XQAFDA") K XQAFDA
 . S XQAIENS="+1,"_XQAI_",",XQAFDA(8992.02,XQAIENS,.01)=XQALSTRT
 . S XQAFDA(8992.02,XQAIENS,.02)=XQALSURO
 . I XQALEND'="" S XQAFDA(8992.02,XQAIENS,.03)=XQALEND
 . I XQALSTRT'>XQANOW S XQAFDA(8992.02,XQAIENS,.04)=1
 . D UPDATE^DIE("","XQAFDA")
 . Q
 Q
