PXRMREDF ; SLC/PJH - Edit PXRM reminder findings. ;05/08/2014
;;2.0;CLINICAL REMINDERS;**4,6,12,26**;Feb 04, 2005;Build 404
;
; Called by PXRMREDT which newes and initialized DEF, DEF1, DEF2.
;
SET S:'$D(^PXD(811.9,DA,20,0)) ^PXD(811.9,DA,20,0)="^811.902V" Q
;Display ALL findings
;
;--------------------
DSPALL(TYPE,NODE,DA,LIST) ;
I '$D(LIST) D Q
. I TYPE="D" W !!,"Reminder has no findings!",!
. I TYPE="T" W !!,"Reminder Term has no findings!",!
N FINUM,FMTSTR,FNAME,FTYPE,IND,NL,OUTPUT,TEXTSTR
W !!,"Choose from:",!
S FMTSTR="2L1^60L1^9L1^3R"
S FTYPE=""
F S FTYPE=$O(LIST(FTYPE)) Q:FTYPE="" D
. S FNAME=0
. F S FNAME=$O(LIST(FTYPE,FNAME)) Q:FNAME="" D
.. S FINUM=0
.. F S FINUM=$O(LIST(FTYPE,FNAME,FINUM)) Q:FINUM="" D
... S TEXTSTR=FTYPE_U_FNAME_U_"Finding #"_U_FINUM
... D COLFMT^PXRMTEXT(FMTSTR,TEXTSTR," ",.NL,.OUTPUT)
... F IND=1:1:NL W !,OUTPUT(IND)
;Update
D LIST^PXRMREDT(NODE,DA,.DEF1,.LIST)
Q
;
;Edit individual FINDING entry
;-----------------------------
FEDIT(IEN) ;
N CFIEN,DA,DIC,DIE,DR,ETYPE,GLOB
N STATUS,TERMSTAT,TIEN,TERMTYPE,VF,WPIEN,Y
S DA(1)=IEN
S DIC="^PXD(811.9,"_IEN_",20,"
I $P(^PXD(811.9,IEN,100),U)="N",$G(PXRMINST)'=1 S DIC(0)="QEA"
E S DIC(0)="QEAL"
S DIC("A")="Select FINDING: "
S DIC("P")="811.902V"
D ^DIC
I Y=-1 S DTOUT=1 Q
S DIE=DIC K DIC
S DIE("NO^")="OUTOK"
S DA=+Y,GLOB=$P($P(Y,U,2),";",2) Q:GLOB=""
S TYPE=$G(DEF1(GLOB))
S SDA(2)=DA(1),SDA(1)=DA
;Save term IEN
S STATUS=0
I TYPE="CF" S CFIEN=$P($P(Y,U,2),";",1) D HELP^PXRMCF(CFIEN)
I TYPE="MH" D WARN^PXRMMH
I TYPE="RT" S TIEN=$P($P(Y,U,2),";",1)
;Finding record fields
W !!,"Editing Finding Number: "_$G(DA)
S DR=".01;3;I X=""0Y"" S Y=6;1;2;6;7;8;9;12;17"
;Taxonomy - use inactive problems
I TYPE="TX" D
.S TERMSTAT=$$TAXNODE^PXRMSTA1($P($P(Y,U,2),";"))
.I TERMSTAT="P" S DR=DR_";10" Q
.I TERMSTAT'=0 S DR=DR_";10",STATUS=1
I TYPE="RT" D
.S TERMTYPE=$$TERMTYPE(TIEN)
.I TERMTYPE["H" S DR=DR_";11"
;Health Factor - within category rank
I TYPE="HF" S DR=DR_";11"
;If V file INCLUDE VISIT DATA
S VF=$S(TYPE="ED":1,TYPE="EX":1,TYPE="HF":1,TYPE="IM":1,TYPE="ST":1,TYPE="TX":1,1:0)
I TYPE="RT",$P(TERMTYPE,U,2)="VF" S VF=1
I VF S DR=DR_";28"
;
;Mental Health - scale
I TYPE="MH" S DR=DR_";13"
;Radiology procedure.
I TYPE="RP" S STATUS=1
;Orderable Item
I TYPE="OI" S DR=DR_";27",STATUS=1
;Rx Type
I (TYPE="DC")!(TYPE="DG")!(TYPE="DR") S DR=DR_";16;27",STATUS=1
;Condition
S DR=DR_";14;15;18"
I TYPE="CF" S DR=DR_";26"
;Found/not found text
S DR=DR_";4;5"
;
I TYPE="RT" D
. I TERMTYPE["D" S DR=DR_";16;27",STATUS=1
. I TERMTYPE["O" S DR=DR_";27",STATUS=1
. I TERMTYPE["R" S STATUS=1
. I TERMTYPE["T" S STATUS=1
.I TERMTYPE[2 D
.. N MSG
.. S MSG(1)="Cannot set a status since the term contains multiple types of findings"
.. S MSG(2)="Edit the status field at the term level for each finding" H 2
.. D EN^DDIOL(.MSG)
;Edit finding record
D ^DIE
S $P(^PXD(811.9,IEN,20,0),U,3)=0
I $D(Y) S DTOUT=1 Q
;Check if deleted
I '$D(DA) Q
I STATUS=1,$D(Y)=0 D STATUS^PXRMSTA1(.DA,"D")
;
S ETYPE=$P(^PXD(811.9,IEN,20,SDA(1),0),U,1)
;Option to edit term findings
I $P(ETYPE,";",2)="PXRMD(811.5," D
. S TIEN=$P(ETYPE,";",1)
. D TMAP(IEN,TIEN)
Q
;
;Edit individual function finding entry
;-----------------------------
FFEDIT(IEN) ;
N DA,DIC,DIE,DR,Y
S DA(1)=IEN
S DIC="^PXD(811.9,"_IEN_",25,"
S DIC(0)="QEAL"
S DIC("A")="Select FUNCTION FINDING: "
D ^DIC
I Y=-1 S DTOUT=1 Q
S DIE=DIC K DIC
S DA=+Y
;Finding record fields
S DR=".01;3"
;Edit finding record
D ^DIE
I $D(Y) S DTOUT=1 Q
I '$D(DA) Q
;If the function string is null don't do the rest of the fields.
I $G(^PXD(811.9,IEN,25,DA,3))="" Q
S DR="1;2;11;12;15;I X=""0Y"" S Y=16;13;14;16"
D ^DIE
I $D(Y) S DTOUT=1 Q
I '$D(DA) Q
;Check if deleted
Q
;
;Edit Reminder Function Findings
;----------------------
FFIND ;
N DTOUT,DUOUT
F D Q:$D(DUOUT)!$D(DTOUT)
.D FFEDIT(DA) I $D(DUOUT)!$D(DTOUT) Q
K DUOUT,DTOUT
Q
;
;Edit Reminder Findings
;----------------------
FIND(LIST) ;
N DTOUT,DUOUT,NODE,SDA
D SET ; Check if node defined
S NODE="^PXD(811.9)"
F D Q:$D(DUOUT)!$D(DTOUT)
.;Display list of existing reminder findings
.W !!,"Reminder Definition Findings"
.D DSPALL("D",NODE,DA,.LIST)
.;Edit findings
.D FEDIT(DA) I $D(DUOUT)!$D(DTOUT) D LIST^PXRMREDT(NODE,DA,.DEF1,.LIST) Q
.;Update list with finding changes
.D LIST^PXRMREDT(NODE,DA,.DEF1,.LIST)
Q
;
;General help text routine
;-------------------------
HELP(CALL) ;
N HTEXT
N DIWF,DIWL,DIWR,IC
S DIWF="C70",DIWL=0,DIWR=70
;
I CALL=1 D
.S HTEXT(1)="Select the type of finding you wish to change or add."
.S HTEXT(2)="Type '?' for a list of the available finding types."
I CALL=2 D
.S HTEXT(1)="Select section of the reminder you wish to edit or 'All'"
.S HTEXT(2)="to step through all sections of the reminder definition."
I CALL=3 D
.S HTEXT(1)="Select 'Y' to edit the findings mapped to this term"
.S HTEXT(2)="or 'N' to return to select another reminder finding."
;
K ^UTILITY($J,"W")
S IC=""
F S IC=$O(HTEXT(IC)) Q:IC="" D
. S X=HTEXT(IC)
. D ^DIWP
W !
S IC=0
F S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC="" D
. W !,^UTILITY($J,"W",0,IC,0)
K ^UTILITY($J,"W")
W !
Q
;
;Display TERM findings
;--------------------
TDSP(DA) ;
N FIRST,SUB,SUB1,TLST
S FIRST=1,SUB="",SUB1=""
;Build list of term findings
D TLST(.TLST,DA)
;Display list
F S SUB=$O(TLST(SUB)) Q:SUB="" D
.S SUB1=0
.F S SUB1=$O(TLST(SUB,SUB1)) Q:SUB1="" D
..I FIRST S FIRST=0 W !!,"Reminder Term Findings:",!!
..W SUB
..W ?8,SUB1,!
I FIRST W !!,"Term has no mapped findings",!!
Q
;
;List Reminders using this term
;------------------------------
TERMS(TIEN,RIEN) ;
;RIEN will be the reminder ien if called from reminder edit
;or zero if called from term edit
N ARRAY,FIND,IEN,SUB,TCNT,RNAME
;Scan all reminders in file #811.9
S IEN=0,FIND="PXRMD(811.5,",TCNT=0
F S IEN=$O(^PXD(811.9,IEN)) Q:'IEN D
.;Exclude current reminder called in reminder edit
.I RIEN,IEN=RIEN Q
.;Check the term findings
.I '$D(^PXD(811.9,IEN,20,"E",FIND,TIEN)) Q
.;Add to reminder array
.S RNAME=$P($G(^PXD(811.9,IEN,0)),U)
.I RNAME="" S RNAME=IEN
.I '$D(ARRAY(RNAME)) S TCNT=TCNT+1
.S ARRAY(RNAME)=""
;
;Display list of reminders using the term
I TCNT D
.N TXT
.S TXT="This Reminder Term is" S:RIEN TXT=TXT_" also"
.S TXT=TXT_" used by the following Reminder Definition"
.I TCNT>1 S TXT=TXT_"s"
.W !!,TXT_":"
.S RNAME="" F S RNAME=$O(ARRAY(RNAME)) Q:RNAME="" W !," ",RNAME
Q
;
;------------------------------
;Check term for finding item to edit status item
TERMTYPE(TIEN) ;
N DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,TYPE,VF
S (DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,VF)=0
S TYPE="" F S TYPE=$O(^PXRMD(811.5,TIEN,20,"B",TYPE)) Q:TYPE="" D
. I TYPE["AUTTEDT(" S (OTHER,VF)=1 Q
. I TYPE["AUTTHF(" S (HF,OTHER,VF)=1 Q
. I TYPE["AUTTIMM(" S (OTHER,VF)=1 Q
. I TYPE["AUTTSK(" S (OTHER,VF)=1 Q
. I TYPE["ORD" S (ORD,FOUND)=1 Q
. I TYPE["PS" S (DRUG,FOUND)=1 Q
. I TYPE["PXD(811.2" S (FOUND,TAX,VF)=1 Q
. I TYPE["RAMIS" S (FOUND,RAD)=1 Q
. S OTHER=1
I RAD=1,ORD=0,TAX=0,DRUG=0,OTHER=0 S RESULT="R"
I RAD=0,ORD=1,TAX=0,DRUG=0,OTHER=0 S RESULT="O"
I RAD=0,ORD=0,TAX=1,DRUG=0,OTHER=0 S RESULT="T"
I RAD=0,ORD=0,TAX=0,DRUG=1,OTHER=0 S RESULT="D"
I OTHER=1 S RESULT=1 I FOUND=1 S RESULT=2
I RESULT="T" S RESULT=$$TAXTYPE^PXRMSTA1(TIEN,"")
I HF=1 S RESULT="H"_RESULT
I VF=1 S RESULT=RESULT_U_"VF"
Q RESULT
;
;Build list of mapped findings for term
;--------------------------------------
TLST(ARRAY,DA) ;
N TYPE,DATA,GLOB,IEN,NAME,NODE,SUB
;Clear passed arrays
K ARRAY
;Build cross reference global to file number
;Get each finding
S SUB=0 F S SUB=$O(^PXRMD(811.5,DA,20,SUB)) Q:'SUB D
.S DATA=$G(^PXRMD(811.5,DA,20,SUB,0)) I DATA="" Q
.;Determine global and global ien
.S NODE=$P(DATA,U),GLOB=$P(NODE,";",2),IEN=$P(NODE,";")
.;Ignore null entries
.I (GLOB="")!(IEN="") Q
.;Work out the file type
.S TYPE=$G(DEF1(GLOB)) Q:TYPE=""
.S NAME=$P($G(@(U_GLOB_IEN_",0)")),U)
.S ARRAY(TYPE,NAME)=""
Q
;
;Map Term findings
;-----------------
TMAP(RIEN,TIEN) ;
N TOPT,TNAM
;Display any other reminders using this term
D TERMS(TIEN,RIEN)
;Term name
S TNAM=$P($G(^PXRMD(811.5,TIEN,0)),U)
;Give option to edit mapped findings (Y/N)
D TMASK(.TOPT,TNAM) Q:$D(DUOUT)!($D(DTOUT))
;Edit term findings
I TOPT="Y" D TRMED(TIEN)
Q
;
;Option to edit term findings
;----------------------------
TMASK(YESNO,TNAM) ;
N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
S DIR(0)="YA0"
S DIR("A")="Do you want to edit mapped findings for "_TNAM_": "
S (DIR("B"),YESNO)="N"
S DIR("?")="Enter Y or N. For detailed help type ??"
S DIR("??")=U_"D HELP^PXRMREDF(3)"
W !
D ^DIR K DIR
I $D(DIROUT)!$D(DIRUT) Q
I $D(DTOUT)!$D(DUOUT) Q
S YESNO=$E(Y(0))
Q
;
;Term edit
;---------
TRMED(DA) ;
N CS1,CS2,DIC,DLAYGO,DTOUT,DUOUT,Y
K DLAYGO,DTOUT,DUOUT,Y
;Display term findings
D TDSP(DA)
;Initialize change history
S CS1=$$FILE^PXRMEXCS(811.5,DA)
;Edit term findings
S DIC="^PXRMD(811.5,"
D EDIT^PXRMTMED(DIC,DA)
;Update change history
S CS2=$$FILE^PXRMEXCS(811.5,DA)
I CS2=0 Q
I CS2'=CS1 D SEHIST^PXRMUTIL(811.5,DIC,DA)
Q
;
PXRMREDF ; SLC/PJH - Edit PXRM reminder findings. ;05/08/2014
+1 ;;2.0;CLINICAL REMINDERS;**4,6,12,26**;Feb 04, 2005;Build 404
+2 ;
+3 ; Called by PXRMREDT which newes and initialized DEF, DEF1, DEF2.
+4 ;
SET IF '$DATA(^PXD(811.9,DA,20,0))
SET ^PXD(811.9,DA,20,0)="^811.902V"
QUIT
+1 ;Display ALL findings
+2 ;
+3 ;--------------------
DSPALL(TYPE,NODE,DA,LIST) ;
+1 IF '$DATA(LIST)
Begin DoDot:1
+2 IF TYPE="D"
WRITE !!,"Reminder has no findings!",!
+3 IF TYPE="T"
WRITE !!,"Reminder Term has no findings!",!
End DoDot:1
QUIT
+4 NEW FINUM,FMTSTR,FNAME,FTYPE,IND,NL,OUTPUT,TEXTSTR
+5 WRITE !!,"Choose from:",!
+6 SET FMTSTR="2L1^60L1^9L1^3R"
+7 SET FTYPE=""
+8 FOR
SET FTYPE=$ORDER(LIST(FTYPE))
IF FTYPE=""
QUIT
Begin DoDot:1
+9 SET FNAME=0
+10 FOR
SET FNAME=$ORDER(LIST(FTYPE,FNAME))
IF FNAME=""
QUIT
Begin DoDot:2
+11 SET FINUM=0
+12 FOR
SET FINUM=$ORDER(LIST(FTYPE,FNAME,FINUM))
IF FINUM=""
QUIT
Begin DoDot:3
+13 SET TEXTSTR=FTYPE_U_FNAME_U_"Finding #"_U_FINUM
+14 DO COLFMT^PXRMTEXT(FMTSTR,TEXTSTR," ",.NL,.OUTPUT)
+15 FOR IND=1:1:NL
WRITE !,OUTPUT(IND)
End DoDot:3
End DoDot:2
End DoDot:1
+16 ;Update
+17 DO LIST^PXRMREDT(NODE,DA,.DEF1,.LIST)
+18 QUIT
+19 ;
+20 ;Edit individual FINDING entry
+21 ;-----------------------------
FEDIT(IEN) ;
+1 NEW CFIEN,DA,DIC,DIE,DR,ETYPE,GLOB
+2 NEW STATUS,TERMSTAT,TIEN,TERMTYPE,VF,WPIEN,Y
+3 SET DA(1)=IEN
+4 SET DIC="^PXD(811.9,"_IEN_",20,"
+5 IF $PIECE(^PXD(811.9,IEN,100),U)="N"
IF $GET(PXRMINST)'=1
SET DIC(0)="QEA"
+6 IF '$TEST
SET DIC(0)="QEAL"
+7 SET DIC("A")="Select FINDING: "
+8 SET DIC("P")="811.902V"
+9 DO ^DIC
+10 IF Y=-1
SET DTOUT=1
QUIT
+11 SET DIE=DIC
KILL DIC
+12 SET DIE("NO^")="OUTOK"
+13 SET DA=+Y
SET GLOB=$PIECE($PIECE(Y,U,2),";",2)
IF GLOB=""
QUIT
+14 SET TYPE=$GET(DEF1(GLOB))
+15 SET SDA(2)=DA(1)
SET SDA(1)=DA
+16 ;Save term IEN
+17 SET STATUS=0
+18 IF TYPE="CF"
SET CFIEN=$PIECE($PIECE(Y,U,2),";",1)
DO HELP^PXRMCF(CFIEN)
+19 IF TYPE="MH"
DO WARN^PXRMMH
+20 IF TYPE="RT"
SET TIEN=$PIECE($PIECE(Y,U,2),";",1)
+21 ;Finding record fields
+22 WRITE !!,"Editing Finding Number: "_$GET(DA)
+23 SET DR=".01;3;I X=""0Y"" S Y=6;1;2;6;7;8;9;12;17"
+24 ;Taxonomy - use inactive problems
+25 IF TYPE="TX"
Begin DoDot:1
+26 SET TERMSTAT=$$TAXNODE^PXRMSTA1($PIECE($PIECE(Y,U,2),";"))
+27 IF TERMSTAT="P"
SET DR=DR_";10"
QUIT
+28 IF TERMSTAT'=0
SET DR=DR_";10"
SET STATUS=1
End DoDot:1
+29 IF TYPE="RT"
Begin DoDot:1
+30 SET TERMTYPE=$$TERMTYPE(TIEN)
+31 IF TERMTYPE["H"
SET DR=DR_";11"
End DoDot:1
+32 ;Health Factor - within category rank
+33 IF TYPE="HF"
SET DR=DR_";11"
+34 ;If V file INCLUDE VISIT DATA
+35 SET VF=$SELECT(TYPE="ED":1,TYPE="EX":1,TYPE="HF":1,TYPE="IM":1,TYPE="ST":1,TYPE="TX":1,1:0)
+36 IF TYPE="RT"
IF $PIECE(TERMTYPE,U,2)="VF"
SET VF=1
+37 IF VF
SET DR=DR_";28"
+38 ;
+39 ;Mental Health - scale
+40 IF TYPE="MH"
SET DR=DR_";13"
+41 ;Radiology procedure.
+42 IF TYPE="RP"
SET STATUS=1
+43 ;Orderable Item
+44 IF TYPE="OI"
SET DR=DR_";27"
SET STATUS=1
+45 ;Rx Type
+46 IF (TYPE="DC")!(TYPE="DG")!(TYPE="DR")
SET DR=DR_";16;27"
SET STATUS=1
+47 ;Condition
+48 SET DR=DR_";14;15;18"
+49 IF TYPE="CF"
SET DR=DR_";26"
+50 ;Found/not found text
+51 SET DR=DR_";4;5"
+52 ;
+53 IF TYPE="RT"
Begin DoDot:1
+54 IF TERMTYPE["D"
SET DR=DR_";16;27"
SET STATUS=1
+55 IF TERMTYPE["O"
SET DR=DR_";27"
SET STATUS=1
+56 IF TERMTYPE["R"
SET STATUS=1
+57 IF TERMTYPE["T"
SET STATUS=1
+58 IF TERMTYPE[2
Begin DoDot:2
+59 NEW MSG
+60 SET MSG(1)="Cannot set a status since the term contains multiple types of findings"
+61 SET MSG(2)="Edit the status field at the term level for each finding"
HANG 2
+62 DO EN^DDIOL(.MSG)
End DoDot:2
End DoDot:1
+63 ;Edit finding record
+64 DO ^DIE
+65 SET $PIECE(^PXD(811.9,IEN,20,0),U,3)=0
+66 IF $DATA(Y)
SET DTOUT=1
QUIT
+67 ;Check if deleted
+68 IF '$DATA(DA)
QUIT
+69 IF STATUS=1
IF $DATA(Y)=0
DO STATUS^PXRMSTA1(.DA,"D")
+70 ;
+71 SET ETYPE=$PIECE(^PXD(811.9,IEN,20,SDA(1),0),U,1)
+72 ;Option to edit term findings
+73 IF $PIECE(ETYPE,";",2)="PXRMD(811.5,"
Begin DoDot:1
+74 SET TIEN=$PIECE(ETYPE,";",1)
+75 DO TMAP(IEN,TIEN)
End DoDot:1
+76 QUIT
+77 ;
+78 ;Edit individual function finding entry
+79 ;-----------------------------
FFEDIT(IEN) ;
+1 NEW DA,DIC,DIE,DR,Y
+2 SET DA(1)=IEN
+3 SET DIC="^PXD(811.9,"_IEN_",25,"
+4 SET DIC(0)="QEAL"
+5 SET DIC("A")="Select FUNCTION FINDING: "
+6 DO ^DIC
+7 IF Y=-1
SET DTOUT=1
QUIT
+8 SET DIE=DIC
KILL DIC
+9 SET DA=+Y
+10 ;Finding record fields
+11 SET DR=".01;3"
+12 ;Edit finding record
+13 DO ^DIE
+14 IF $DATA(Y)
SET DTOUT=1
QUIT
+15 IF '$DATA(DA)
QUIT
+16 ;If the function string is null don't do the rest of the fields.
+17 IF $GET(^PXD(811.9,IEN,25,DA,3))=""
QUIT
+18 SET DR="1;2;11;12;15;I X=""0Y"" S Y=16;13;14;16"
+19 DO ^DIE
+20 IF $DATA(Y)
SET DTOUT=1
QUIT
+21 IF '$DATA(DA)
QUIT
+22 ;Check if deleted
+23 QUIT
+24 ;
+25 ;Edit Reminder Function Findings
+26 ;----------------------
FFIND ;
+1 NEW DTOUT,DUOUT
+2 FOR
Begin DoDot:1
+3 DO FFEDIT(DA)
IF $DATA(DUOUT)!$DATA(DTOUT)
QUIT
End DoDot:1
IF $DATA(DUOUT)!$DATA(DTOUT)
QUIT
+4 KILL DUOUT,DTOUT
+5 QUIT
+6 ;
+7 ;Edit Reminder Findings
+8 ;----------------------
FIND(LIST) ;
+1 NEW DTOUT,DUOUT,NODE,SDA
+2 ; Check if node defined
DO SET
+3 SET NODE="^PXD(811.9)"
+4 FOR
Begin DoDot:1
+5 ;Display list of existing reminder findings
+6 WRITE !!,"Reminder Definition Findings"
+7 DO DSPALL("D",NODE,DA,.LIST)
+8 ;Edit findings
+9 DO FEDIT(DA)
IF $DATA(DUOUT)!$DATA(DTOUT)
DO LIST^PXRMREDT(NODE,DA,.DEF1,.LIST)
QUIT
+10 ;Update list with finding changes
+11 DO LIST^PXRMREDT(NODE,DA,.DEF1,.LIST)
End DoDot:1
IF $DATA(DUOUT)!$DATA(DTOUT)
QUIT
+12 QUIT
+13 ;
+14 ;General help text routine
+15 ;-------------------------
HELP(CALL) ;
+1 NEW HTEXT
+2 NEW DIWF,DIWL,DIWR,IC
+3 SET DIWF="C70"
SET DIWL=0
SET DIWR=70
+4 ;
+5 IF CALL=1
Begin DoDot:1
+6 SET HTEXT(1)="Select the type of finding you wish to change or add."
+7 SET HTEXT(2)="Type '?' for a list of the available finding types."
End DoDot:1
+8 IF CALL=2
Begin DoDot:1
+9 SET HTEXT(1)="Select section of the reminder you wish to edit or 'All'"
+10 SET HTEXT(2)="to step through all sections of the reminder definition."
End DoDot:1
+11 IF CALL=3
Begin DoDot:1
+12 SET HTEXT(1)="Select 'Y' to edit the findings mapped to this term"
+13 SET HTEXT(2)="or 'N' to return to select another reminder finding."
End DoDot:1
+14 ;
+15 KILL ^UTILITY($JOB,"W")
+16 SET IC=""
+17 FOR
SET IC=$ORDER(HTEXT(IC))
IF IC=""
QUIT
Begin DoDot:1
+18 SET X=HTEXT(IC)
+19 DO ^DIWP
End DoDot:1
+20 WRITE !
+21 SET IC=0
+22 FOR
SET IC=$ORDER(^UTILITY($JOB,"W",0,IC))
IF IC=""
QUIT
Begin DoDot:1
+23 WRITE !,^UTILITY($JOB,"W",0,IC,0)
End DoDot:1
+24 KILL ^UTILITY($JOB,"W")
+25 WRITE !
+26 QUIT
+27 ;
+28 ;Display TERM findings
+29 ;--------------------
TDSP(DA) ;
+1 NEW FIRST,SUB,SUB1,TLST
+2 SET FIRST=1
SET SUB=""
SET SUB1=""
+3 ;Build list of term findings
+4 DO TLST(.TLST,DA)
+5 ;Display list
+6 FOR
SET SUB=$ORDER(TLST(SUB))
IF SUB=""
QUIT
Begin DoDot:1
+7 SET SUB1=0
+8 FOR
SET SUB1=$ORDER(TLST(SUB,SUB1))
IF SUB1=""
QUIT
Begin DoDot:2
+9 IF FIRST
SET FIRST=0
WRITE !!,"Reminder Term Findings:",!!
+10 WRITE SUB
+11 WRITE ?8,SUB1,!
End DoDot:2
End DoDot:1
+12 IF FIRST
WRITE !!,"Term has no mapped findings",!!
+13 QUIT
+14 ;
+15 ;List Reminders using this term
+16 ;------------------------------
TERMS(TIEN,RIEN) ;
+1 ;RIEN will be the reminder ien if called from reminder edit
+2 ;or zero if called from term edit
+3 NEW ARRAY,FIND,IEN,SUB,TCNT,RNAME
+4 ;Scan all reminders in file #811.9
+5 SET IEN=0
SET FIND="PXRMD(811.5,"
SET TCNT=0
+6 FOR
SET IEN=$ORDER(^PXD(811.9,IEN))
IF 'IEN
QUIT
Begin DoDot:1
+7 ;Exclude current reminder called in reminder edit
+8 IF RIEN
IF IEN=RIEN
QUIT
+9 ;Check the term findings
+10 IF '$DATA(^PXD(811.9,IEN,20,"E",FIND,TIEN))
QUIT
+11 ;Add to reminder array
+12 SET RNAME=$PIECE($GET(^PXD(811.9,IEN,0)),U)
+13 IF RNAME=""
SET RNAME=IEN
+14 IF '$DATA(ARRAY(RNAME))
SET TCNT=TCNT+1
+15 SET ARRAY(RNAME)=""
End DoDot:1
+16 ;
+17 ;Display list of reminders using the term
+18 IF TCNT
Begin DoDot:1
+19 NEW TXT
+20 SET TXT="This Reminder Term is"
IF RIEN
SET TXT=TXT_" also"
+21 SET TXT=TXT_" used by the following Reminder Definition"
+22 IF TCNT>1
SET TXT=TXT_"s"
+23 WRITE !!,TXT_":"
+24 SET RNAME=""
FOR
SET RNAME=$ORDER(ARRAY(RNAME))
IF RNAME=""
QUIT
WRITE !," ",RNAME
End DoDot:1
+25 QUIT
+26 ;
+27 ;------------------------------
+28 ;Check term for finding item to edit status item
TERMTYPE(TIEN) ;
+1 NEW DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,TYPE,VF
+2 SET (DRUG,FOUND,HF,ORD,OTHER,RAD,RESULT,TAX,VF)=0
+3 SET TYPE=""
FOR
SET TYPE=$ORDER(^PXRMD(811.5,TIEN,20,"B",TYPE))
IF TYPE=""
QUIT
Begin DoDot:1
+4 IF TYPE["AUTTEDT("
SET (OTHER,VF)=1
QUIT
+5 IF TYPE["AUTTHF("
SET (HF,OTHER,VF)=1
QUIT
+6 IF TYPE["AUTTIMM("
SET (OTHER,VF)=1
QUIT
+7 IF TYPE["AUTTSK("
SET (OTHER,VF)=1
QUIT
+8 IF TYPE["ORD"
SET (ORD,FOUND)=1
QUIT
+9 IF TYPE["PS"
SET (DRUG,FOUND)=1
QUIT
+10 IF TYPE["PXD(811.2"
SET (FOUND,TAX,VF)=1
QUIT
+11 IF TYPE["RAMIS"
SET (FOUND,RAD)=1
QUIT
+12 SET OTHER=1
End DoDot:1
+13 IF RAD=1
IF ORD=0
IF TAX=0
IF DRUG=0
IF OTHER=0
SET RESULT="R"
+14 IF RAD=0
IF ORD=1
IF TAX=0
IF DRUG=0
IF OTHER=0
SET RESULT="O"
+15 IF RAD=0
IF ORD=0
IF TAX=1
IF DRUG=0
IF OTHER=0
SET RESULT="T"
+16 IF RAD=0
IF ORD=0
IF TAX=0
IF DRUG=1
IF OTHER=0
SET RESULT="D"
+17 IF OTHER=1
SET RESULT=1
IF FOUND=1
SET RESULT=2
+18 IF RESULT="T"
SET RESULT=$$TAXTYPE^PXRMSTA1(TIEN,"")
+19 IF HF=1
SET RESULT="H"_RESULT
+20 IF VF=1
SET RESULT=RESULT_U_"VF"
+21 QUIT RESULT
+22 ;
+23 ;Build list of mapped findings for term
+24 ;--------------------------------------
TLST(ARRAY,DA) ;
+1 NEW TYPE,DATA,GLOB,IEN,NAME,NODE,SUB
+2 ;Clear passed arrays
+3 KILL ARRAY
+4 ;Build cross reference global to file number
+5 ;Get each finding
+6 SET SUB=0
FOR
SET SUB=$ORDER(^PXRMD(811.5,DA,20,SUB))
IF 'SUB
QUIT
Begin DoDot:1
+7 SET DATA=$GET(^PXRMD(811.5,DA,20,SUB,0))
IF DATA=""
QUIT
+8 ;Determine global and global ien
+9 SET NODE=$PIECE(DATA,U)
SET GLOB=$PIECE(NODE,";",2)
SET IEN=$PIECE(NODE,";")
+10 ;Ignore null entries
+11 IF (GLOB="")!(IEN="")
QUIT
+12 ;Work out the file type
+13 SET TYPE=$GET(DEF1(GLOB))
IF TYPE=""
QUIT
+14 SET NAME=$PIECE($GET(@(U_GLOB_IEN_",0)")),U)
+15 SET ARRAY(TYPE,NAME)=""
End DoDot:1
+16 QUIT
+17 ;
+18 ;Map Term findings
+19 ;-----------------
TMAP(RIEN,TIEN) ;
+1 NEW TOPT,TNAM
+2 ;Display any other reminders using this term
+3 DO TERMS(TIEN,RIEN)
+4 ;Term name
+5 SET TNAM=$PIECE($GET(^PXRMD(811.5,TIEN,0)),U)
+6 ;Give option to edit mapped findings (Y/N)
+7 DO TMASK(.TOPT,TNAM)
IF $DATA(DUOUT)!($DATA(DTOUT))
QUIT
+8 ;Edit term findings
+9 IF TOPT="Y"
DO TRMED(TIEN)
+10 QUIT
+11 ;
+12 ;Option to edit term findings
+13 ;----------------------------
TMASK(YESNO,TNAM) ;
+1 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
+2 SET DIR(0)="YA0"
+3 SET DIR("A")="Do you want to edit mapped findings for "_TNAM_": "
+4 SET (DIR("B"),YESNO)="N"
+5 SET DIR("?")="Enter Y or N. For detailed help type ??"
+6 SET DIR("??")=U_"D HELP^PXRMREDF(3)"
+7 WRITE !
+8 DO ^DIR
KILL DIR
+9 IF $DATA(DIROUT)!$DATA(DIRUT)
QUIT
+10 IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+11 SET YESNO=$EXTRACT(Y(0))
+12 QUIT
+13 ;
+14 ;Term edit
+15 ;---------
TRMED(DA) ;
+1 NEW CS1,CS2,DIC,DLAYGO,DTOUT,DUOUT,Y
+2 KILL DLAYGO,DTOUT,DUOUT,Y
+3 ;Display term findings
+4 DO TDSP(DA)
+5 ;Initialize change history
+6 SET CS1=$$FILE^PXRMEXCS(811.5,DA)
+7 ;Edit term findings
+8 SET DIC="^PXRMD(811.5,"
+9 DO EDIT^PXRMTMED(DIC,DA)
+10 ;Update change history
+11 SET CS2=$$FILE^PXRMEXCS(811.5,DA)
+12 IF CS2=0
QUIT
+13 IF CS2'=CS1
DO SEHIST^PXRMUTIL(811.5,DIC,DA)
+14 QUIT
+15 ;