AMQQN ; IHS/CMI/THL - NATURAL LANGUAGE INTERPRETER ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;-----
I AMQQQSTG="" G EXIT
S X=AMQQQSTG
S AMQQNN=1
S AMQQXX=""
W !!
D WAIT^DICD
W !!
RUN F AMQQNRUN=0,1,2 D @("^AMQQN"_AMQQNRUN) I $D(AMQQFAIL) D FAIL,KILL,KILL1 G EXIT
D SET
D KILL
D AND
I $D(AMQQFAIL) D FAIL G EXIT
D EN1^AMQQQ2,KILL1
S AMQV("OPTION")="LIST"
S AMQQXX("FORMAT")=1
D ^AMQQCMPL
EXIT K AMQQONE,AMQQXX,AMQQNTAX,AMQQFAIL,%,%Y,A,B,C,I,J,N,S,Z,C
Q
;
SET S AMQQXX(0)=AMQQNSBJ
S AMQQNA=1
I "^MALES^BOYS^MEN^"[(U_AMQQNSBJ_U) S AMQQXX(99.1,1)="3^SEX;11^IS;M" G SET1
I "^FEMALES^GIRLS^WOMEN"[(U_AMQQNSBJ_U) S AMQQXX(99.1,1)="3^SEX;11^IS;F" G SET1
I AMQQNSBJ="INFANTS" S AMQQXX(.1,1)="33^AGE;39^LESS THAN;1" G SET1
SET1 I $D(AMQQFAIL) Q
S AMQQNSVL=$G(AMQQNSVL)
I $D(AMQQNATT),$D(AMQQNCND),$D(AMQQNVAL)
E Q
I '$G(AMQQCTXS) S AMQQXX(AMQQNA,1)=AMQQNATT_";"_AMQQNCND_";"_AMQQNVAL Q
S AMQQXX(AMQQNA,1)=$S($G(AMQQNCND)="MTAX":(AMQQNATT_";MTAX;"_AMQQNVAL),1:(AMQQNATT_";MULT"))
I "MTAX"[$G(AMQQNCND),$G(AMQQNSUB)="" Q
I $G(AMQQNCND)="" S AMQQXX(AMQQNA,1,1,1)=AMQQNSCD_";"_AMQQNSVL Q
I $G(AMQQNSUB)="" S AMQQXX(AMQQNA,1,1,1)=AMQQNCND_";"_AMQQNVAL Q
I AMQQNSTP="O",'$D(AMQQNISF),$D(AMQQONE) S AMQQXX(AMQQNA,1,2,1)=AMQQNSCD_";"_AMQQNSVL,AMQQXX(AMQQNA,1,1,1)=AMQQNCND_";"_AMQQNVAL Q
S AMQQXX(AMQQNA,1,2,1)=AMQQNCND_";"_AMQQNVAL
S AMQQXX(AMQQNA,1,1,1)=AMQQNSCD_";"_AMQQNSVL
Q
;
KILL K AMQQNATT,AMQQNCND,AMQQNN,AMQQNRUN,AMQQNSBJ,AMQQNSCD,AMQQNSTP,AMQQNSUB,AMQQNSVL,AMQQNVAL,AMQQQ,AUPNDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX,A,B,I,J,S,X,Y,Z,%,%Y,AMQQCTXS,AMQQLINK
Q
;
KILL1 K AMQQLSQF,AMQQATN,AMQQATNM,AMQQMMCC,AMQQMULT,AMQQQSTG,N,AMQQQ,AMQQYYYY,I,N,X,Y,Z,AMQQCNAM,AMQQXX,AMQQXXND,AMQQYYAT,AMQQNA,AMQQNAP
Q
;
FAIL ;EP;
I $G(AMQQFAIL)=-1 Q
I $D(AMQQNSF) K AMQQNSF D KILL Q
I AMQQFAIL=4 W !!,"I'm unable to identify the subject of the query...try again",!!,*7 G F1
W !!,"Sorry, I don't understand your query. Check for spelling errors and typos."
W !,"If this fails, try rewording the query. If you still fail, dont blame me..."
W !,"After all, I'm only a stupid machine!!",!!,*7
F1 R "<>",%:DTIME E S AMQQQUIT=""
D KILL
Q
;
AND F AMQQNAP=1:0 S AMQQNAP=$O(AMQQNAP(AMQQNAP)) Q:'AMQQNAP S AMQQNA=AMQQNA+1 S X=AMQQNAP(AMQQNAP) D ^AMQQN2,SET1,KILL I $D(AMQQFAIL) Q
Q
;
AMQQN ; IHS/CMI/THL - NATURAL LANGUAGE INTERPRETER ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;-----
+3 IF AMQQQSTG=""
GOTO EXIT
+4 SET X=AMQQQSTG
+5 SET AMQQNN=1
+6 SET AMQQXX=""
+7 WRITE !!
+8 DO WAIT^DICD
+9 WRITE !!
RUN FOR AMQQNRUN=0,1,2
DO @("^AMQQN"_AMQQNRUN)
IF $DATA(AMQQFAIL)
DO FAIL
DO KILL
DO KILL1
GOTO EXIT
+1 DO SET
+2 DO KILL
+3 DO AND
+4 IF $DATA(AMQQFAIL)
DO FAIL
GOTO EXIT
+5 DO EN1^AMQQQ2
DO KILL1
+6 SET AMQV("OPTION")="LIST"
+7 SET AMQQXX("FORMAT")=1
+8 DO ^AMQQCMPL
EXIT KILL AMQQONE,AMQQXX,AMQQNTAX,AMQQFAIL,%,%Y,A,B,C,I,J,N,S,Z,C
+1 QUIT
+2 ;
SET SET AMQQXX(0)=AMQQNSBJ
+1 SET AMQQNA=1
+2 IF "^MALES^BOYS^MEN^"[(U_AMQQNSBJ_U)
SET AMQQXX(99.1,1)="3^SEX;11^IS;M"
GOTO SET1
+3 IF "^FEMALES^GIRLS^WOMEN"[(U_AMQQNSBJ_U)
SET AMQQXX(99.1,1)="3^SEX;11^IS;F"
GOTO SET1
+4 IF AMQQNSBJ="INFANTS"
SET AMQQXX(.1,1)="33^AGE;39^LESS THAN;1"
GOTO SET1
SET1 IF $DATA(AMQQFAIL)
QUIT
+1 SET AMQQNSVL=$GET(AMQQNSVL)
+2 IF $DATA(AMQQNATT)
IF $DATA(AMQQNCND)
IF $DATA(AMQQNVAL)
+3 IF '$TEST
QUIT
+4 IF '$GET(AMQQCTXS)
SET AMQQXX(AMQQNA,1)=AMQQNATT_";"_AMQQNCND_";"_AMQQNVAL
QUIT
+5 SET AMQQXX(AMQQNA,1)=$SELECT($GET(AMQQNCND)="MTAX":(AMQQNATT_";MTAX;"_AMQQNVAL),1:(AMQQNATT_";MULT"))
+6 IF "MTAX"[$GET(AMQQNCND)
IF $GET(AMQQNSUB)=""
QUIT
+7 IF $GET(AMQQNCND)=""
SET AMQQXX(AMQQNA,1,1,1)=AMQQNSCD_";"_AMQQNSVL
QUIT
+8 IF $GET(AMQQNSUB)=""
SET AMQQXX(AMQQNA,1,1,1)=AMQQNCND_";"_AMQQNVAL
QUIT
+9 IF AMQQNSTP="O"
IF '$DATA(AMQQNISF)
IF $DATA(AMQQONE)
SET AMQQXX(AMQQNA,1,2,1)=AMQQNSCD_";"_AMQQNSVL
SET AMQQXX(AMQQNA,1,1,1)=AMQQNCND_";"_AMQQNVAL
QUIT
+10 SET AMQQXX(AMQQNA,1,2,1)=AMQQNCND_";"_AMQQNVAL
+11 SET AMQQXX(AMQQNA,1,1,1)=AMQQNSCD_";"_AMQQNSVL
+12 QUIT
+13 ;
KILL KILL AMQQNATT,AMQQNCND,AMQQNN,AMQQNRUN,AMQQNSBJ,AMQQNSCD,AMQQNSTP,AMQQNSUB,AMQQNSVL,AMQQNVAL,AMQQQ,AUPNDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX,A,B,I,J,S,X,Y,Z,%,%Y,AMQQCTXS,AMQQLINK
+1 QUIT
+2 ;
KILL1 KILL AMQQLSQF,AMQQATN,AMQQATNM,AMQQMMCC,AMQQMULT,AMQQQSTG,N,AMQQQ,AMQQYYYY,I,N,X,Y,Z,AMQQCNAM,AMQQXX,AMQQXXND,AMQQYYAT,AMQQNA,AMQQNAP
+1 QUIT
+2 ;
FAIL ;EP;
+1 IF $GET(AMQQFAIL)=-1
QUIT
+2 IF $DATA(AMQQNSF)
KILL AMQQNSF
DO KILL
QUIT
+3 IF AMQQFAIL=4
WRITE !!,"I'm unable to identify the subject of the query...try again",!!,*7
GOTO F1
+4 WRITE !!,"Sorry, I don't understand your query. Check for spelling errors and typos."
+5 WRITE !,"If this fails, try rewording the query. If you still fail, dont blame me..."
+6 WRITE !,"After all, I'm only a stupid machine!!",!!,*7
F1 READ "<>",%:DTIME
IF '$TEST
SET AMQQQUIT=""
+1 DO KILL
+2 QUIT
+3 ;
AND FOR AMQQNAP=1:0
SET AMQQNAP=$ORDER(AMQQNAP(AMQQNAP))
IF 'AMQQNAP
QUIT
SET AMQQNA=AMQQNA+1
SET X=AMQQNAP(AMQQNAP)
DO ^AMQQN2
DO SET1
DO KILL
IF $DATA(AMQQFAIL)
QUIT
+1 QUIT
+2 ;