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

AICDKWL1.m

Go to the documentation of this file.
AICDKWL1 ; IHS/OHPRD/ACC - PART 2 OF LOOKUP CONTROL PROGRAM FOR "AND"ING INVERTED SEARCH ; 
 ;;4.0;AICD;;DEC 03, 2014;Build 7
NOTSHRT D ^AICDTOKN
 D CHKREP
 K AICDWORD,AICDDFN,AICDAWRD,AICDADFN,AICDNUSE S AICDNUSE=0
 D PREPSCH^AICDKWL2
 I AICDNWDS=0 W:AICDASK "Narrative contained no useable words.",! G:'AICDNUSE NOTSHRTX
 I AICDNUSE,AICDNWDS W:AICDASK !,"The following word",$S(AICDNUSE=1:" was",1:"s were")," not used in this search:",! S AICDWD="" F AICDQ=0:0 S AICDWD=$O(AICDNUSE(AICDWD)) Q:AICDWD=""  W:AICDASK ?5,AICDWD,!
NOTSHRTX K AICDNUSE
 K ^UTILITY("AICDHITS",$J) S ^UTILITY("AICDHITS",$J)=0 D:AICDNWDS ^AICDKSCH
 I ^UTILITY("AICDHITS",$J)=0 W:AICDASK "Search was unsuccessful.",! S Y=-1 G EXIT
 G VERIFY
CHKREP ;
 S AICDWORD="" F  S AICDWORD=$O(AICDWT(AICDWORD)) Q:AICDWORD=""  S AICDDFN=$O(^AICDKWLC(AICDKWCT,2,"B",AICDWORD,0)) D:AICDDFN CHKREP2
 K AICDREP,AICDREPT
 Q
CHKREP2 K AICDWT(AICDWORD)
 S AICDREP=$P(^AICDKWLC(AICDKWCT,2,AICDDFN,0),U,2)
 F  D CHKREP3 Q:AICDREPT=""  S AICDWT(AICDREPT)=""
 Q
CHKREP3 F  Q:$E(AICDREP)'=" "  S AICDREP=$E(AICDREP,2,$L(AICDREP))
 S AICDREPI=$F(AICDREP," ")
 I AICDREPI S AICDREPT=$E(AICDREP,1,AICDREPI-2),AICDREP=$E(AICDREP,AICDREPI,$L(AICDREP))
 E  S AICDREPT=AICDREP,AICDREP=""
 Q
VERIFY ;
 S Y=-1
 I ^UTILITY("AICDHITS",$J)=1 D ASKONE G VERIFY2
 D:AICDASK ASKSEL:^UTILITY("AICDHITS",$J)>1
VERIFY2 I +Y>0,$D(^DD(+$P(@(AICDGBL_"0)"),U,2),0,"ACT")) X ^("ACT")
 I +Y>0,$D(@(AICDREF1_(+Y)_",0)"))#2 S Y=+Y_U_$P(^(0),U,1)
EXIT ;
 ;IHS/BAO/TMD - 3/13/2005 - modified next line to not kill hits
 ;K ^UTILITY("AICDHITS",$J)
EXIT2 ;
 K AICDWD,AICDNWDS,AICDKWCT,AICDI,AICDQ
 K AICDREF,AICDREF0,AICDREF1,AICDREF2,AICDREF3,AICDREF4
 K AICDGBL,AICDT,AICDL,AICDKSCH,AICDX,AICDASK
 S X=AICDXSAV K AICDXSAV
 Q
 ;
ASKONE ; ASK IF SINGLE HIT IS ACCEPTABLE
 I $P(@(AICDKSCH("GBL")_"0)"),U,2)'["O" G ASKONEOK
 G:'AICDASK ASKONEOK
 W !
 S AICDH=1,AICDMULT=0
 D DSPLY
 F AICDQ=0:0 R " OK? Y// ",X:$S($D(DTIME):DTIME,1:300),! S:'$T X="^" S X=$E(X_"Y") S:X?1L X=$C($A(X)-32) Q:"^YN"[X  W $C(7)
 K Y
 I "^N"[X S Y=-1 G ASKONEX
ASKONEOK S Y=^UTILITY("AICDHITS",$J,1) I $D(DIC(0))#2,DIC(0)["Z" S AICDH=1,Y(0)=@AICDREF3 ;*4*
ASKONEX K AICDH,AICDMULT,AICDDESC,AICDF
 Q
 ;
ASKSEL ; ASK FOR SELECTION AMONG HITS
 W !!,"The following matches were found:",!!
 S AICDMULT=1,AICDGRP=1
DSPGRP S AICDH2=$S((AICDGRP+4)'>^UTILITY("AICDHITS",$J):AICDGRP+4,1:^UTILITY("AICDHITS",$J))
 F AICDH=AICDGRP:1:AICDH2 D DSPLY
 W !
 F AICDQ=0:0 W "Select 1-",^UTILITY("AICDHITS",$J),": " R X:$S($D(DTIME):DTIME,1:300),! S:'$T X="^" Q:X["^"!(X="")!(X="-")  Q:X?1N.N&(X>0)&(X'>^UTILITY("AICDHITS",$J))  W $C(7)
 I X="" S AICDGRP=$S((AICDGRP+5)'>^UTILITY("AICDHITS",$J):AICDGRP+5,1:1) G DSPGRP
 I X="-" S AICDGRP=$S(AICDGRP'=1:AICDGRP-5,1:^UTILITY("AICDHITS",$J)-1\5*5+1) G DSPGRP
 I X?1"^"1N.N S AICDI=($E(X,2,255)-1)\5*5+1 I AICDI'>^UTILITY("AICDHITS",$J) S AICDGRP=AICDI G DSPGRP
 I X["^" S Y=-1
 E  S AICDH=X,Y=^UTILITY("AICDHITS",$J,AICDH) I $D(DIC(0))#2,DIC(0)["Z" S Y(0)=@AICDREF3
 K AICDH,AICDMULT,AICDH2,AICDGRP,AICDDESC,AICDF
 Q
 ;
DSPLY ; DISPLAY CODE AND TEXT
 S AICDI=^UTILITY("AICDHITS",$J,AICDH)
 S AICDREF0=AICDREF1_AICDI_",0)"
 I $D(AICDKSCH("DSPLY")) D @AICDKSCH("DSPLY") Q
 W:AICDMULT $J(AICDH,4),": "
 W $P(@(AICDREF1_"AICDI,0)"),"^",1),!
 S AICDDESC="<display protocol not provided>"
DSPDESC F %=0:0 Q:AICDDESC=""  D GETFRAG W:AICDMULT ?7 W AICDF,!
 W !
 K AICDC,AICDF
 Q
GETFRAG I $L(AICDDESC)<72 S AICDF=AICDDESC,AICDDESC="" Q
 F AICDC=73:-1:1 Q:$E(AICDDESC,AICDC)=" "
 S AICDF=$E(AICDDESC,1,AICDC-1),AICDDESC=$E(AICDDESC,AICDC+1,255)
 Q