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

APCDPLIE.m

Go to the documentation of this file.
APCDPLIE ;IHS/CMI/LAB - UPDATE ICD CODE FROM BSTS
 ;;2.0;IHS PCC SUITE;**16**;MAY 14, 2009;Build 9
 ;; ;
 ;
 ;THIS ROUTINE IS CALLED FROM AN OPTION THAT IS SCHEDULED TO RUN
 ;AT A SITE DEFINED INTERVAL. IT LOOPS THE PROBLEM FILE AND CHECKS
 ;ANY SNOMED CODED PROBLEM THAT HAS A STATUS OF EPISODIC.
 ;IF THE USED AS POV DATE IS GREATER THAN THE PARAMETER THE
 ;PROBLEM IS MARKED AS INACTIVE.
 ;E.G.  EPISODIC PROBLEM WAS LAST USED AS POV ON 1/1/16.
 ;PARAMETER IS SET TO 30.  TODAY IS 3/1/16.  SINCE 1/1/16 IS
 ;GREATER THAN 30 DAYS AGO IT WILL MARK THE PROBLEM AS INACTIVE.
EP ;EP - CALLED FROM SCHEDULED OPTION
 D QUEUE
 D XIT
 Q
XIT ;
 D EN^XBVK("APCD")
 Q
QUEUE ;EP
 S APCDDAYS=$$GET^XPAR("SYS","BGO IPL INACTIVATE TIMEFRAME")
 I APCDDAYS="" Q
 S APCDX=0,APCDCNT=0
 F  S APCDX=$O(^AUPNPROB(APCDX)) Q:APCDX'=+APCDX  D
 .Q:'$D(^AUPNPROB(APCDX,0))
 .S APCDCI=$P($G(^AUPNPROB(APCDX,800)),U)  ;only snomed coded problems
 .Q:APCDCI=""
 .S APCDCS=$P(^AUPNPROB(APCDX,0),U,12) ;current status
 .Q:APCDCS'="E"  ;EPISODIC PROBLEMS ONLY
 .S APCDLU=$$LASTUAPV(APCDX)
 .;
 .I APCDLU="" Q  ;NEVER USED AS POV??
 .S X=$$FMDIFF^XLFDT(DT,APCDLU)
 .;W !,APCDX," ",APCDLU," ",APCDCS W "   ",X
 .I X<APCDDAYS Q
 .;W "  INACTIVATE"
 .D CS
 Q
LASTUAPV(P) ;
 I '$G(P) Q ""
 NEW X,Y,Z,V,D
 S X=0
 F  S X=$O(^AUPNPROB(P,14,X)) Q:X'=+X  D
 .S V=$P($G(^AUPNPROB(P,14,X,0)),U,1)  ;VISIT IEN
 .I 'V Q  ;NO .01??
 .I '$D(^AUPNVSIT(V,0)) Q  ;VISIT MUST HAVE BEEN DELETED
 .S D=$$VD^APCLV(V)  ;VISIT DATE, FM FORMAT
 .S Z(D)=""
 S X=0
 F  S X=$O(^AUPNPROB(P,15,X)) Q:X'=+X  D
 .S V=$P($G(^AUPNPROB(P,15,X,0)),U,1)  ;VISIT IEN
 .I 'V Q  ;NO .01??
 .I '$D(^AUPNVSIT(V,0)) Q  ;VISIT MUST HAVE BEEN DELETED
 .S D=$$VD^APCLV(V)  ;VISIT DATE, FM FORMAT
 .S Z(D)=""
 S Z=$O(Z(99999999),-1)
 Q Z
CS ;update status .12 and update PROBLEM entry and the change log
 ;update my log
 K DIE,DA,DR
 S DIE="^AUPNPROB(",DA=APCDX,DR=".12///I" D ^DIE K DIE,DA,DR
 K DIC,DD,D0,DO,DO
 S DIADD=1,DLAYGO=9001040.1,DIC(0)="L",DIC="^APCDPLMD("
 S X=DT,DIC("DR")=".02////"_APCDX_";.07////9000011;1301///E"_";1302///I;1303///"_APCDLU
 D FILE^DICN
 K DIC,DIADD,DLAYGO
 S APCDLOGE=+Y
 Q
SETE ;
 S DA=APCDLOGE,DIE="^APCDPLMD(",DR="1///"_ERR("DIERR",1)
 Q