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

APCLDF1.m

Go to the documentation of this file.
APCLDF1 ; IHS/CMI/LAB -IHS -PROCESS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
PARSE ;- ENTRY POINT from APCLDF - Parse script   
 S DATE=$P(X,";",2),X=$P(X,";")
 S COND=$P(X," ")
 I COND="ALL"!(COND="LAST")!(COND="FIRST")
 E  I "INACTIVEPROBLEMSFAMILYPERSONALHISTORY"[$P($P(X," "),".") S X="ALL "_X,COND="ALL"
 E  S X="ALL "_X,COND="ALL"
 I '$P(X," ",2) S X=$P(X," ")_$S(COND="ALL":" 9999999 ",1:" 1 ")_$P(X," ",2,15)
 S NUM=$P(X," ",2)
 S FILE=$P(X," ",3),FILE=$TR(FILE,"."," ")
 S VAL=$P(X," ",4,15)
 I DATE]"" D DATE
X3 Q
 ;
DATE ; Process dates
 NEW YRLER
 S BOOL=$P(DATE," "),BOOL=$S(BOOL="<>":"<>","BEFORELESS<"[BOOL:"<","BETWEENDURING"[BOOL:"<>","AFTERGREATERSINCE>"[BOOL:">","ON=EQUALS"[BOOL:"=",1:"")
 I BOOL="" S APCLER=16 G X9
 S DATE=$P(DATE," ",2,15)
 I BOOL="<>" S STDATE=$P(DATE,"-"),EDATE=$P(DATE,"-",2) D  I 1
 . S X=STDATE K %DT D ^%DT S STDATE=Y I Y=-1 S YRLER=17 G X10
 . I EDATE="",$E(STDATE,6,7)'="00" S APCLER=17 G X10
 . I EDATE="" S EDATE=STDATE
 . E  S X=EDATE K %DT D ^%DT S EDATE=Y I Y=-1 S YRLER=17 G X10
 . I $E(STDATE,6,7)="00"!($E(EDATE,6,7)="00") F X="STDATE","EDATE" D DATECHG
X10 . Q
 E  S X=DATE S:BOOL="=" %DT="X" D ^%DT K %DT S DATE=Y D  I Y=-1 S APCLER=17
 . I Y=-1 Q
 . I $E(DATE,6,7)="00" S X="DATE" D DATECHG
X9 Q
 ;
DATECHG ; Change dates to usuable form if user just enters date with year
 ; or month and year only
 I X="STDATE" D  G X11
 . S STDATE=$S($E(STDATE,4,5)="00":$E(STDATE,1,3)_"0101",1:$E(STDATE,1,5)_"01")
 I X="EDATE" D  G X11
 . S EDATE=$S($E(EDATE,4,5)="00":$E(EDATE,1,3)_1231,1:$E(EDATE,1,5)_31)
 E  D
 . I BOOL=">" S DATE=$S($E(DATE,4,5)="00":$E(DATE,1,3)_1231,1:$E(DATE,1,5)_31)
 . E  S DATE=$S($E(DATE,4,5)="00":$E(DATE,1,3)_"0101",1:$E(DATE,1,5)_"01")
X11 Q
 ;
PROCESS ;  - ENTRY POINT from APCLDF - Get values and/or create tax vals
 I TYPE="VISIT" D VISIT^APCLDF3 G X8
 I VAL="*" D  G X8
 . S APCLTX=""
 . I COND'="LAST" S VAL=0 F  S VAL=$O(^TMP("APCLTAX",$J,VAL))  Q:'VAL  D @(TYPE_"^APCLDF2") Q:'VAL  D  I 1
 .. I '$D(APCLER) D RESULTS^APCLDF2
 . E  S VAL="" D @(TYPE_"^APCLDF2") D
 .. I '$D(APCLER) D RESULTS^APCLDF2
 I $E(VAL)'="[" D
 . D @(TYPE_"^APCLDF2")
 E  D
 . I TAX="LAB TAX" D LABTAX G X8
 . S X=TAX,DIC="^AMQQ(5,",DIC(0)="FM",DIC("S")="I $P(^(0),U,14)" D ^DIC K DIC
 . I Y=-1 S APCLER=7
 . E  D
 .. S AMQQLINK=$P(^AMQQ(5,+Y,0),U,5),AMQQTAXT=$P(^(0),U,14),AMQQTGBL=U_$P($P(^(0),U,18),"("),APCLTX=""
 .. S X=VAL,AMQQGTX="^TMP(""APCLTAX"","_$J_"," S:$D(APCLINT) AMQQECHO="" D EN1^AMQQGTX D
 ... I '$D(^TMP("APCLTAX",$J)) S APCLER=10 Q
 ... ;I COND'="LAST" D @(TYPE_"^APCLDF2") I 1
 ...I COND'="LAST" S VAL=0 F  S VAL=$O(^TMP("APCLTAX",$J,VAL))  Q:'VAL  D @(TYPE_"^APCLDF2") Q:'VAL  D  I 1
 ....I '$D(APCLER) D RESULTS^APCLDF2
 ... E  S VAL="" D @(TYPE_"^APCLDF2")
 .. I '$D(APCLER) D RESULTS^APCLDF2
X8 Q
 ;
LABTAX ;resolve lab taxonomy and store in ^TMP("APCLTAX",$J,lab ien,site/spec ien)=""
 NEW LABTAX,X
 S APCLTX=""
 S X=$E(VAL,2,99999999),DIC="^ATXLAB(",DIC(0)="FM" D ^DIC K DIC
 I Y=-1 S APCLER=7 Q
 S LABTAX=+Y
 S X=0 F  S X=$O(^ATXLAB(LABTAX,21,X)) Q:X'=+X  S ^TMP("APCLTAX",$J,$P(^ATXLAB(LABTAX,21,X,0),U))="",Y=0 F  S Y=$O(^ATXLAB(LABTAX,21,X,11,Y)) Q:Y'=+Y  D
 .Q  ;DON'T DO THIS SITE/SPECIMEN CHECK IHS/CMI/LAB
 .S Z=$P(^ATXLAB(LABTAX,21,X,0),U),T=$P(^ATXLAB(LABTAX,21,X,11,Y,0),U)
 .S ^TMP("APCLTAX",$J,Z,T)=""
 .Q
 I '$D(^TMP("APCLTAX",$J)) S APCLER=10 Q
 I COND'="LAST" S VAL=0 F  S VAL=$O(^TMP("APCLTAX",$J,VAL)) Q:'VAL  D @(TYPE_"^APCLDF2") Q:'VAL  D  I 1
 .I '$D(APCLER) D RESULTS^APCLDF2
 E  S VAL="" D @(TYPE_"^APCLDF2")
 I '$D(APCLER) D RESULTS^APCLDF2
 K LABTAX,X,Y,Z,T
 D @(TYPE_"^APCLDF2") Q:'VAL  I 1
 Q