PXRMDTAX ; SLC/AGP - Reminder Dialog Taxonomy Field editor/List Manager ;03/14/2014
;;2.0;CLINICAL REMINDERS;**26**;Feb 04, 2005;Build 404
;
;ADDTAXF1(FIELD,CODE,ARRAY) ;
ADDTAXF1(CODE,ARRAY) ;
N CURVALUE,PROMPT,RESULT,SARRAY,TEMP,TYPE,X,Y
S CURVALUE=$$GETTEXT^PXRMDTAX(.ARRAY,CODE)
;I CURVALUE="" S CURVALUE="Selectable "_$S(FIELD=2:"current ",FIELD=3:"historical ",1:"")_$S($E(TEMP)="d":TEMP_"es",1:TEMP_"s")_" codes"
Q CURVALUE
;
;central location for building array of codes when determine what codes go with an
;encounter type
BLDCODE(TYPE,CODESYS) ;
I TYPE="ALL" S (CODESYS("ICD"),CODESYS("10D"),CODESYS("CPT"),CODESYS("CPC"))="" Q
I TYPE="POV" S (CODESYS("ICD"),CODESYS("10D"))="" Q
I TYPE="CPT" S (CODESYS("CPT"),CODESYS("CPC"))="" Q
Q
;
;build FDA array for Taxonomy Fields multiple
BLDFDA(CODE,IEN,FDA,DEFAULT) ;
N DA,ENCTYPE,FIELD,IENS,NODEIEN,RESULT,TEMP,VALUE,X
S X=$S(CODE="POV":141,1:142)
S VALUE=$$TAXDIR(X,CODE,IEN,.DEFAULT) I VALUE[U Q VALUE
S FDA(801.41,IEN_",",X)=VALUE
Q VALUE
;
CHECKER(DIEN,TIEN,FIELD,OUTPUT) ;
N CNT,FAIL,NAME,NODE,RESULT,TAXSEL,TDX,TDXNODE,TNAME,TPR,TPRNODE,TYPE
S FAIL=""
S NODE=$G(^PXRMD(801.41,DIEN,0)),NAME=$P(NODE,U),TYPE=$S($P(NODE,U,4)="G":"Group",1:"Element")
S TNAME=$P($G(^PXD(811.2,TIEN,0)),U)
I $P($G(^PXD(811.2,TIEN,0)),U,6)=1 S OUTPUT(1)="Dialog "_TYPE_" "_NAME_" contains an inactive taxonomy "_TNAME_".",FAIL="W" Q FAIL
I '$D(^PXD(811.2,TIEN,20,"AUID")) S OUTPUT(1)="Dialog "_TYPE_" "_NAME_" contains a taxonomy "_TNAME_" that does not have codes marked to be used in a dialog.",FAIL=$S(FIELD="F":"F",1:"W") I FIELD'="" Q FAIL
;
S TAXSEL=$P($G(^PXRMD(801.41,DIEN,"TAX")),U)
S TDX=$$TOK(TIEN,"POV"),TPR=$$TOK(TIEN,"CPT")
;I TYPE="Group",TDX,TPR,TAXSEL'["N" S OUTPUT(1)="Dialog "_TYPE_" "_NAME_" cannot have a taxonomy selection field value other than 'No Pick List'.",FAIL="F" Q FAIL
;.I TAXSEL'["N" S OUTPUT(1)="Dialog "_TYPE_" "_NAME_" cannot have a taxonomy selection field value other than 'No Pick List'.",FAIL="F"
I TAXSEL="N" Q FAIL
S TDXNODE=$S($P($G(^PXRMD(801.41,DIEN,"POV")),U)'="":1,1:0),TPRNODE=$S($P($G(^PXRMD(801.41,DIEN,"CPT")),U)'="":1,1:0)
S CNT=0
I TAXSEL="A",TDX,TPR D Q FAIL
.S RESULT=$$CHCKCOMP(TDXNODE,TDX,"POV",NAME) I RESULT'="" S FAIL="W",CNT=CNT+1,OUTPUT(CNT)=RESULT
.S RESULT=$$CHCKCOMP(TPRNODE,TPR,"CPT",NAME) I RESULT'="" S FAIL="W",CNT=CNT+1,OUTPUT(CNT)=RESULT
I TAXSEL="D" S RESULT=$$CHCKCOMP(TDXNODE,TDX,"POV",NAME) I RESULT'="" S FAIL="W",CNT=CNT+1,OUTPUT(CNT)=RESULT
I TAXSEL="P" S RESULT=$$CHCKCOMP(TPRNODE,TPR,"CPT",NAME) I RESULT'="" S FAIL="W",CNT=CNT+1,OUTPUT(CNT)=RESULT
I $$HASACT(TIEN)=0 S FAIL="W",CNT=CNT+1,OUTPUT(CNT)="Taxonomy "_TNAME_" does not contain active codes for "_$$FMTE^XLFDT(DT)
Q FAIL
;
CHCKCOMP(DNODE,TNODE,TYPE,NAME) ;
N NODE S NODE=$S(TYPE="POV":"diagnosis",1:"procedure")
I DNODE=1,TNODE=0 Q "Dialog element "_NAME_" "_NODE_" Header Text is defined, but the taxonomy does not have "_NODE_" codes marked to be used in a dialog."
I DNODE=0,TNODE=1 Q "Dialog element "_NAME_" "_NODE_" Header Text is not defined, but the taxonomy does have "_NODE_" codes marked to be used in a dialog."
Q ""
;
;write out code display used by List Manager
CODES(TIEN,CODES,NLINE,HIST,ISMAIL) ;
N BDATE,CODE,DATE,DATES,DESC,DTEXT,EDATE,NLINES,STR,SUB
N TAB,TEXT,TEXTIN,TEXTOUT,X
;
S SUB=""
F S SUB=$O(CODES(SUB)) Q:SUB="" D
.S CODE=$P(CODES(SUB),U,2),DESC=$P(CODES(SUB),U,3)
.S BDATE=$$FMTE^XLFDT($P($G(CODE),":",2))
.S EDATE=$S($P($G(CODE),":",3)'="":$$FMTE^XLFDT($P($G(CODE),":",3)),1:"")
.S DATE=BDATE_"-"_EDATE
.S STR=$$LJ^XLFSTR($P($G(CODE),":"),8)
.S STR=STR_DESC
.S TEXTIN(1)=STR
.D FORMAT^PXRMTEXT(1,$S(ISMAIL:35,1:44),1,.TEXTIN,.NLINES,.TEXTOUT)
.F X=1:1:NLINES D
..S DTEXT=$S(X=1:$$LJ^XLFSTR(TEXTOUT(X),$S(ISMAIL=1:38,1:45))_DATE,1:TEXTOUT(X))
..S NLINE=NLINE+1
..S ^TMP(NODE,$J,NLINE,0)=$J("",15)_DTEXT
Q
;
;general field delete sub-routine
DELFIELD(IENS,SUB,FIELD) ;Delete a field.
N FDA,MSG
S FDA(SUB,IENS,FIELD)="@"
D FILE^DIE("","FDA","MSG")
I $D(MSG) W !,"Error in delete",! D AWRITE^PXRMUTIL("MSG")
Q
;
;Cross-reference delete when deleting Taxonomy fields in a dialog
DELLOG(DA,FIELD,OLD,NEW) ;
I OLD="" Q
N IENS,POVIEN,PROCIEN
I FIELD=123 D Q
.I NEW=""!(NEW="N") D Q
..S IENS=DA_"," D DELFIELD(IENS,801.41,141)
..S IENS=DA_"," D DELFIELD(IENS,801.41,142)
.I NEW="D" S IENS=DA_"," D DELFIELD(IENS,801.41,142) Q
.I NEW="P" S IENS=DA_"," D DELFIELD(IENS,801.41,141)
Q
;
GETSTAT(TYPE) ;
N HIST,RESULT,STATUS
S RESULT=0
S IEN=$O(^PXRMD(801.45,"B",TYPE,"")) I IEN'>0 Q RESULT
I '$D(^PXRMD(801.45,IEN,1,"B",2)) S RESULT=1 Q RESULT
S HIST=$O(^PXRMD(801.45,IEN,1,"B",2,"")) I HIST'>0 S RESULT=1 Q RESULT
I $P($G(^PXRMD(801.45,IEN,1,HIST,0)),U,2)=1 S RESULT=1 Q RESULT
S RESULT=2
S STATUS=0 F S STATUS=$O(^PXRMD(801.45,IEN,1,"B",STATUS)) Q:STATUS'>0!(RESULT<2) I STATUS'=2 S RESULT=0
Q RESULT
;
;this returns the default values from file 801.45 for POV or Procedure
;codes.
;DEFAULT(TYPE,pointer to file 801.9)=default
;DEFAULT(TYPE,pointer to file 801.9,ADDFIND,n)=additional finding node
GETTAXDF(DEFAULT,TYPE,ISHIST) ;
N CNT,IEN,FIND,STATUS
S IEN=$O(^PXRMD(801.45,"B",TYPE,"")) I IEN'>0 Q
;get resolution status
S CNT=0 F S CNT=$O(^PXRMD(801.45,IEN,1,CNT)) Q:CNT'>0 D
.S STATUS=$P($G(^PXRMD(801.45,IEN,1,CNT,0)),U)
.I ISHIST=1,STATUS'=2 Q
.I ISHIST=0,STATUS=2 Q
.;get prefix and suffix text
.S DEFAULT(TYPE,"PREFIX")=$G(^PXRMD(801.45,IEN,1,CNT,3))
.S DEFAULT(TYPE,"SUFFIX")=$G(^PXRMD(801.45,IEN,1,CNT,4))
.;get additional findings
.S FIND=0 F S FIND=$O(^PXRMD(801.45,IEN,1,CNT,5,FIND)) Q:FIND'>0 D
..S DEFAULT(TYPE,"ADDFIND",FIND)=$G(^PXRMD(801.45,IEN,1,CNT,5,FIND,0))
Q
;
;Returns the default taxonomy checkbox header for the Encounter Type
GETTEXT(VALUES,TYPE) ;
;GETTEXT(VALUES,TYPE,CURR) ;
N ENCTYPE,IEN,TEXT
S TEXT=""
S TEXT=$G(VALUES(TYPE,"PREFIX"))_$G(VALUES(TYPE,"SUFFIX"))
Q TEXT
;
HASACT(TIEN) ;
N SYS,CODE,SDATE,EDATE,START,TODAY,FOUND,END
S TODAY=DT+1,FOUND=0
S SYS="" F S SYS=$O(^PXD(811.2,TIEN,20,"AUID",SYS)) Q:SYS=""!(FOUND=1) D
.S CODE="" F S CODE=$O(^PXD(811.2,TIEN,20,"AUID",SYS,CODE)) Q:CODE=""!(FOUND=1) D
..S SDATE=""
..F S SDATE=$O(^PXD(811.2,TIEN,20,"AUID",SYS,CODE,SDATE)) Q:SDATE=""!(FOUND=1) D
...S START=SDATE-1,EDATE=""
...F S EDATE=$O(^PXD(811.2,TIEN,20,"AUID",SYS,CODE,SDATE,EDATE)) Q:EDATE=""!(FOUND=1) D
....S END=$S(EDATE="DT":DT+1,1:EDATE+1) I DT>START,DT<END S FOUND=1 Q
Q FOUND
;
PRINT(TEXTIN,NIN) ;
N LINE,NOUT,TEXTOUT
D FORMAT^PXRMTEXT(1,75,NIN,.TEXTIN,.NOUT,.TEXTOUT)
D MES^XPDUTL(.TEXTOUT)
Q
;
;Builds a list of prompts associated with the taxonomy finding types
;Prompts the user to add the prompts to the dialog editor. Does not prompt if prompts
;are already defined to the element.
PROMPTS(DA,SEL,DEFAULT,FDA,IENCNT) ;
N CNT,CODE,DIR,DNUM,ENC,EXTVAL,FIELD,IEN,IENS,NAME,NODE,NUM,PROMPT,PROMPTS,START,VALUE,X,Y
I $D(^PXRMD(801.41,DA,10)) Q 0
S CODE="" F S CODE=$O(DEFAULT(CODE)) Q:CODE="" D
.I SEL="P",CODE="POV" Q
.I SEL="D",CODE="CPT" Q
.S CNT=0 F S CNT=$O(DEFAULT(CODE,"ADDFIND",CNT)) Q:CNT'>0 D
..S NODE=DEFAULT(CODE,"ADDFIND",CNT)
..S IEN=$P(NODE,U)
..I $D(^PXRMD(801.41,DA,10,"D",IEN))>0 Q
..I $D(PROMPTS(IEN))>0 I $L(PROMPTS(IEN),U)<$L(NODE,U) S PROMPTS(IEN)=NODE
..S PROMPTS(IEN)=NODE
;
I '$D(PROMPTS) Q 0
S START=+$O(^PXRMD(801.41,DA,10,""),-1)
S DNUM=0
W !,"Default prompts for the taxonomy:"
S IEN=0,CNT=0 F S IEN=$O(PROMPTS(IEN)) Q:IEN'>0 D
.S CNT=CNT+1,START=START+1,DNUM=DNUM+1
.S IENCNT=IENCNT+1,IENS="+"_IENCNT_","_DA_","
.S NAME=$P($G(^PXRMD(801.41,IEN,0)),U)
.S NODE=PROMPTS(IEN),CNT=$L(NODE,U)
.I $P(NODE,U,3)>0 Q
.S FDA(801.412,IENS,.01)=START
.S FDA(801.412,IENS,2)=IEN
.W !,"Prompt: "_NAME
.I CNT=1 Q
.F NUM=2:1:CNT D
..I NUM=3 Q
..I NUM=4 Q
..S VALUE=$P(NODE,U,NUM) I $G(VALUE)="" Q
..S FIELD=$S(NUM=2:9,NUM=4:.01,NUM=5:6,NUM=6:7,NUM=7:8,1:"") I $G(FIELD)="" Q
..S FDA(801.412,IENS,FIELD)=VALUE
..S PROMPT=$S(FIELD=.01:"Sequence",FIELD=6:"Override Prompt Caption",FIELD=7:"Start New Line",FIELD=8:"Exclude From PN Text",FIELD=9:"Required")
..I $G(PROMPT)="" Q
..I FIELD=6 S EXTVAL=VALUE
..I FIELD>6 S EXTVAL=$S(VALUE=1:"Yes",1:"No")
..W !," "_PROMPT_": "_EXTVAL
;
I CNT=0 W !,"None" Q 0
S DIR(0)="S^Y:Yes;N:No"
S DIR("A")="Add Prompts to the dialog"
S DIR("B")="Yes"
D ^DIR
I Y[U K FDA(801.412) Q 0
I Y="N" K FDA(801.412)
Q 1
;
;Prompts the user for values for the fields in the Taxonomy Fields multiple.
;Builds default values from existing values or from file 801.45
TAXDIR(FIELD,CODE,DA,ARRAY) ;
N DIR,CURVALUE,PROMPT,RESULT,SARRAY,TEMP,TYPE,X,Y
S CURVALUE=""
S DIR("A")=$S(CODE="POV":"Diagnosis Header",1:"Procedure Header")
S DIR(0)="F^1:80"
S TEMP=$S(CODE="POV":"diagnosis",1:"Procedure")
I +DA>0 S CURVALUE=$$GET1^DIQ(801.41,DA_",",FIELD)
I CURVALUE="" D
.S CURVALUE=$$GETTEXT(.ARRAY,CODE)
.I CURVALUE="" S CURVALUE="Selectable "_$S($E(TEMP)="d":TEMP_"es",1:TEMP_"s")_" codes"
S DIR("B")=CURVALUE
D ^DIR
Q Y
;
;main taxonomy fields editor entry point. Returns ^ or ^^ or 1 is fields are answer.
TAXDIAL(IEN,FIND) ;
;Protect FileMan variables
N D,D0,DA,DC,DDES,DE,DG,DH,DI,DIC,DIDEL,DIE,DIEDA,DIEL,DIEN,DIR,DIETMP
N DIEXREF,DIFLD,DIEIENS,DINUSE,DIP,DISYS,DK,DL,DM,DP,DQ,DR,DU
;
N DEF,DEFAULT,DXTYPE,FDA,FDAIEN,HTEXT,IENCNT,IENS,ISHIST,MSG,NODEIEN,NAME,NONE,PRTYPE,RESULT,STR,TAXIEN,TAXSEL,TDX,TPR,VALUE,X,Y
;
ENTAXDL ;
;
S RESULT=1
I FIND'["PXD(811.2" Q 0
S DA=IEN,TAXIEN=+FIND I TAXIEN'>0 Q 0
S ISHIST=$S($P($G(^PXRMD(801.41,IEN,1)),U,3)=2:1,1:0)
S TDX=$$TOK(TAXIEN,"POV")
S TPR=$$TOK(TAXIEN,"CPT")
S DEF=$P($G(^PXRMD(801.41,DA,"TAX")),U)
S DIR(0)="S^A:All;N:No Pick List" D HELP(.HTEXT,"")
I TDX=1,TPR=1 S DIR(0)="S^A:All;D:ICD Diagnoses Only;P:CPT Procedures Only;N:No Pick List" D HELP(.HTEXT,"PD")
I $P($G(^PXRMD(801.41,IEN,0)),U,4)="G" D
.I $G(DEF)="" S DEF="N"
.I TDX=1,TPR=1 S DIR(0)="S^D:ICD Diagnoses Only;P:CPT Procedures Only;N:No Pick List" D HELP(.HTEXT,"GPD") Q
.I TPR=1 S DIR(0)="S^P:CPT Procedures Only;N:No Pick List" D HELP(.HTEXT,"GP") Q
.S DIR(0)="S^D:ICD Diagnoses Only;N:No Pick List" D HELP(.HTEXT,"GD")
I DIR(0)'[DEF S DEF=""
S DIR("A")="Taxonomy Pick List"
S DIR("B")=$S(DEF]"":DEF,1:"A")
S DIR("?")="Select the pick list display value or '^' to quit. Enter ?? for detail help."
S DIR("??")=U_"D HELP^PXRMEUT(.HTEXT)"
D ^DIR
I Y[U Q Y
S VALUE=Y
S FDA(801.41,DA_",",123)=VALUE
I VALUE="N" G TAXUPD
I TDX=1 D GETTAXDF(.DEFAULT,"POV",ISHIST)
I TPR=1 D GETTAXDF(.DEFAULT,"CPT",ISHIST)
S IENCNT=0
I TDX=1,TPR=1,VALUE="A" D G TAXDIALX:RESULT="^^" G ENTAXDL:RESULT=U
.S RESULT=$$BLDFDA("POV",IEN,.FDA,.DEFAULT) I RESULT[U Q
.S RESULT=$$BLDFDA("CPT",IEN,.FDA,.DEFAULT)
;I TPR=1,VALUE="A" S RESULT=$$BLDFDA("CPT",IEN,.FDA,.DEFAULT) G TAXDIALX:RESULT="^^" G ENTAXDL:RESULT=U
;
S RESULT=$$PROMPTS(IEN,VALUE,.DEFAULT,.FDA,.IENCNT) I RESULT[U G TAXDIALX:RESULT="^^" G ENTAXDL:RESULT=U
K MSG
TAXUPD ;
D UPDATE^DIE("","FDA","","MSG")
I $D(MSG) W !,"Error in update",! D AWRITE^PXRMUTIL("MSG")
;
TAXDIALX ;
Q RESULT
;
;This routine is used to display Taxonomy codes in the List Manager view for Dialog Text.
;TODO should we display any codes in Dialog Text view for Additional Findings or Taxonomy Pick List of N, D, P?
TAXDISP(FIEN,SEQ,DIEN,NLINE,NODE,ADDFIND,ISMAIL) ;
N ARRAY,CNT,CODESYS,FILE,HIST,TIEN,TSEQ
N CNT,DTXT,FNODE,RSUB,TDX,TNAME,TPAR,TPR,TYP
N TCUR,TDTXT,TDHTXT,THIS,TPTXT,TPHTXT
S TIEN=$P(FIEN,";") Q:TIEN=""
S HIST=0,FILE=""
;Get associated codes
;
;Get taxonomy name
S TNAME=$P($G(^PXD(811.2,TIEN,0)),U,1)
;
;Check what type of taxonomy codes exist
S TDX=$$TOK(TIEN,"POV")
S TPR=$$TOK(TIEN,"CPT")
;
S TAXSEL=$P($G(^PXRMD(801.41,DIEN,"TAX")),U)
I ADDFIND=1 S TAXSEL="N"
;
I TDX D
.D BLDCODE("POV",.CODESYS)
.D CODES^PXRMDLLB(TIEN,.CODESYS,.CODES)
.I '$D(CODES) Q
.S TEXT=$J("",15)_$S(TAXSEL="N":"Diagnoses Codes:",TAXSEL="P":"Procedures Codes:",1:"Selectable Diagnoses Codes:"),TAB=18
.S STR=$$LJ^XLFSTR($G(TEXT),$S(ISMAIL=1:51,1:60))
.S STR=STR_"Activation Periods"
.S NLINE=NLINE+1
.S ^TMP(NODE,$J,NLINE,0)=STR
.D CODES(TIEN,.CODES,.NLINE,HIST,ISMAIL)
.S NLINE=NLINE+1
.S ^TMP(NODE,$J,NLINE,0)=$J("",79)
;
I TPR D
.K CODESYS,CODES
.D BLDCODE("CPT",.CODESYS)
.D CODES^PXRMDLLB(TIEN,.CODESYS,.CODES)
.I '$D(CODES) Q
.S TEXT=$J("",15)_$S(TAXSEL="N":"Procedures Codes:",TAXSEL="D":"Procedures Codes:",1:"Selectable Procedures codes:"),TAB=18
.S STR=$$LJ^XLFSTR($G(TEXT),$S(ISMAIL=1:51,1:60))
.S STR=STR_"Activation Periods"
.S NLINE=NLINE+1
.S ^TMP(NODE,$J,NLINE,0)=STR
.D CODES(TIEN,.CODES,.NLINE,HIST,ISMAIL)
.S NLINE=NLINE+1
.S ^TMP(NODE,$J,NLINE,0)=$J("",79)
Q
;
TAXEDITC(TIEN,TEXT) ;
N DARRAY,DIEN,HEADER,NAME,OCNT,OUTPUT,RARRAY,RESULT,TDX,TPR,TAXNODE
N TAXSEL
D FINDDIAL^PXRMFRPT(.DARRAY,"PXD(811.2,",TIEN)
S TEXT(1)="Taxonomy and/or the following dialog(s) have problems."
S TEXT(2)="Correct either the taxonomy or the following dialog(s):"
S CNT=2
I '$D(DARRAY) G TXEDITCX
I '$D(^PXD(811.2,TIEN,20,"AUID")) S TEXT(1)="Taxonomy does not contain codes marked to be used in a dialog. It is assigned to the following dialog(s)." D Q
.S CNT=1,NAME="" F S NAME=$O(DARRAY(NAME)) Q:NAME="" S CNT=CNT+1,TEXT(CNT)=" "_NAME
S TDX=$$TOK(TIEN,"POV"),TPR=$$TOK(TIEN,"CPT")
S NAME="" F S NAME=$O(DARRAY(NAME)) Q:NAME="" D
.S IEN=DARRAY(NAME) S RESULT=$$CHECKER(IEN,TIEN,"",.OUTPUT) I RESULT="" Q
.S TEXT(2)="See below for descriptions of the problem(s):"
.N LINE,NIN,NOUT,TEMP
.S NIN=$O(OUTPUT(""),-1)
.D FORMAT^PXRMTEXT(1,75,NIN,.OUTPUT,.NOUT,.TEMP)
.F LINE=1:1:NOUT S CNT=CNT+1,TEXT(CNT)=TEMP(LINE)
TXEDITCX ;
I CNT=2 K TEXT
K ^TMP($J,"DLG FIND")
Q
;
;change to use AUID cross-referenc instead of the selectable node, central location for checking what codes to use
;in a dialog for encounter type.
TOK(TIEN,TYPE) ;Check if selectable codes exist
I TYPE="POV" I $D(^PXD(811.2,TIEN,20,"AUID","ICD"))>0!($D(^PXD(811.2,TIEN,20,"AUID","10D"))>0) Q 1
I TYPE="CPT" I $D(^PXD(811.2,TIEN,20,"AUID","CPT"))>0!($D(^PXD(811.2,TIEN,20,"AUID","CPC"))>0) Q 1
Q 0
;
HELP(HTEXT,TYPE) ;
N CNT S CNT=1
S HTEXT(CNT)="Set the taxonomy pick list display for the codes marked to be used in a dialog."
I TYPE'["G" S CNT=CNT+1,HTEXT(CNT)="\\\\ A: To display a pick list for all codes "
I TYPE["G" D Q
.I "PD" D Q
..S CNT=CNT+1,HTEXT(CNT)="\\\\ D: To display a pick list for the diagnosis codes."
..S CNT=CNT+1,HTEXT(CNT)="\\\\ The procedure codes will automatically be filed to the encounter."
..S CNT=CNT+1,HTEXT(CNT)="\\\\ P: To display a pick list for the procedure codes."
..S CNT=CNT+1,HTEXT(CNT)="\\\\ The diagnosis codes will automatically be filed to the encounter."
..S CNT=CNT+1,HTEXT(CNT)="\\\\ N: To not display a pick list all codes will automatically be filed to the encounter."
I TYPE["D" D
.S CNT=CNT+1,HTEXT(CNT)="\\\\ D: To display a pick list for the diagnosis codes."
.S CNT=CNT+1,HTEXT(CNT)="\\\\ The procedure codes will automatically be filed to the encounter."
I TYPE["P" D
.S CNT=CNT+1,HTEXT(CNT)="\\\\ P: To display a pick list for the procedure codes."
.S CNT=CNT+1,HTEXT(CNT)="\\\\ The diagnosis codes will automatically be filed to the encounter."
S CNT=CNT+1,HTEXT(CNT)="\\\\ N: To not display a pick list, all codes will automatically be filed "
S CNT=CNT+1,HTEXT(CNT)="\\\\ to the encounter."
Q
;
PXRMDTAX ; SLC/AGP - Reminder Dialog Taxonomy Field editor/List Manager ;03/14/2014
+1 ;;2.0;CLINICAL REMINDERS;**26**;Feb 04, 2005;Build 404
+2 ;
+3 ;ADDTAXF1(FIELD,CODE,ARRAY) ;
ADDTAXF1(CODE,ARRAY) ;
+1 NEW CURVALUE,PROMPT,RESULT,SARRAY,TEMP,TYPE,X,Y
+2 SET CURVALUE=$$GETTEXT^PXRMDTAX(.ARRAY,CODE)
+3 ;I CURVALUE="" S CURVALUE="Selectable "_$S(FIELD=2:"current ",FIELD=3:"historical ",1:"")_$S($E(TEMP)="d":TEMP_"es",1:TEMP_"s")_" codes"
+4 QUIT CURVALUE
+5 ;
+6 ;central location for building array of codes when determine what codes go with an
+7 ;encounter type
BLDCODE(TYPE,CODESYS) ;
+1 IF TYPE="ALL"
SET (CODESYS("ICD"),CODESYS("10D"),CODESYS("CPT"),CODESYS("CPC"))=""
QUIT
+2 IF TYPE="POV"
SET (CODESYS("ICD"),CODESYS("10D"))=""
QUIT
+3 IF TYPE="CPT"
SET (CODESYS("CPT"),CODESYS("CPC"))=""
QUIT
+4 QUIT
+5 ;
+6 ;build FDA array for Taxonomy Fields multiple
BLDFDA(CODE,IEN,FDA,DEFAULT) ;
+1 NEW DA,ENCTYPE,FIELD,IENS,NODEIEN,RESULT,TEMP,VALUE,X
+2 SET X=$SELECT(CODE="POV":141,1:142)
+3 SET VALUE=$$TAXDIR(X,CODE,IEN,.DEFAULT)
IF VALUE[U
QUIT VALUE
+4 SET FDA(801.41,IEN_",",X)=VALUE
+5 QUIT VALUE
+6 ;
CHECKER(DIEN,TIEN,FIELD,OUTPUT) ;
+1 NEW CNT,FAIL,NAME,NODE,RESULT,TAXSEL,TDX,TDXNODE,TNAME,TPR,TPRNODE,TYPE
+2 SET FAIL=""
+3 SET NODE=$GET(^PXRMD(801.41,DIEN,0))
SET NAME=$PIECE(NODE,U)
SET TYPE=$SELECT($PIECE(NODE,U,4)="G":"Group",1:"Element")
+4 SET TNAME=$PIECE($GET(^PXD(811.2,TIEN,0)),U)
+5 IF $PIECE($GET(^PXD(811.2,TIEN,0)),U,6)=1
SET OUTPUT(1)="Dialog "_TYPE_" "_NAME_" contains an inactive taxonomy "_TNAME_"."
SET FAIL="W"
QUIT FAIL
+6 IF '$DATA(^PXD(811.2,TIEN,20,"AUID"))
SET OUTPUT(1)="Dialog "_TYPE_" "_NAME_" contains a taxonomy "_TNAME_" that does not have codes marked to be used in a dialog."
SET FAIL=$SELECT(FIELD="F":"F",1:"W")
IF FIELD'=""
QUIT FAIL
+7 ;
+8 SET TAXSEL=$PIECE($GET(^PXRMD(801.41,DIEN,"TAX")),U)
+9 SET TDX=$$TOK(TIEN,"POV")
SET TPR=$$TOK(TIEN,"CPT")
+10 ;I TYPE="Group",TDX,TPR,TAXSEL'["N" S OUTPUT(1)="Dialog "_TYPE_" "_NAME_" cannot have a taxonomy selection field value other than 'No Pick List'.",FAIL="F" Q FAIL
+11 ;.I TAXSEL'["N" S OUTPUT(1)="Dialog "_TYPE_" "_NAME_" cannot have a taxonomy selection field value other than 'No Pick List'.",FAIL="F"
+12 IF TAXSEL="N"
QUIT FAIL
+13 SET TDXNODE=$SELECT($PIECE($GET(^PXRMD(801.41,DIEN,"POV")),U)'="":1,1:0)
SET TPRNODE=$SELECT($PIECE($GET(^PXRMD(801.41,DIEN,"CPT")),U)'="":1,1:0)
+14 SET CNT=0
+15 IF TAXSEL="A"
IF TDX
IF TPR
Begin DoDot:1
+16 SET RESULT=$$CHCKCOMP(TDXNODE,TDX,"POV",NAME)
IF RESULT'=""
SET FAIL="W"
SET CNT=CNT+1
SET OUTPUT(CNT)=RESULT
+17 SET RESULT=$$CHCKCOMP(TPRNODE,TPR,"CPT",NAME)
IF RESULT'=""
SET FAIL="W"
SET CNT=CNT+1
SET OUTPUT(CNT)=RESULT
End DoDot:1
QUIT FAIL
+18 IF TAXSEL="D"
SET RESULT=$$CHCKCOMP(TDXNODE,TDX,"POV",NAME)
IF RESULT'=""
SET FAIL="W"
SET CNT=CNT+1
SET OUTPUT(CNT)=RESULT
+19 IF TAXSEL="P"
SET RESULT=$$CHCKCOMP(TPRNODE,TPR,"CPT",NAME)
IF RESULT'=""
SET FAIL="W"
SET CNT=CNT+1
SET OUTPUT(CNT)=RESULT
+20 IF $$HASACT(TIEN)=0
SET FAIL="W"
SET CNT=CNT+1
SET OUTPUT(CNT)="Taxonomy "_TNAME_" does not contain active codes for "_$$FMTE^XLFDT(DT)
+21 QUIT FAIL
+22 ;
CHCKCOMP(DNODE,TNODE,TYPE,NAME) ;
+1 NEW NODE
SET NODE=$SELECT(TYPE="POV":"diagnosis",1:"procedure")
+2 IF DNODE=1
IF TNODE=0
QUIT "Dialog element "_NAME_" "_NODE_" Header Text is defined, but the taxonomy does not have "_NODE_" codes marked to be used in a dialog."
+3 IF DNODE=0
IF TNODE=1
QUIT "Dialog element "_NAME_" "_NODE_" Header Text is not defined, but the taxonomy does have "_NODE_" codes marked to be used in a dialog."
+4 QUIT ""
+5 ;
+6 ;write out code display used by List Manager
CODES(TIEN,CODES,NLINE,HIST,ISMAIL) ;
+1 NEW BDATE,CODE,DATE,DATES,DESC,DTEXT,EDATE,NLINES,STR,SUB
+2 NEW TAB,TEXT,TEXTIN,TEXTOUT,X
+3 ;
+4 SET SUB=""
+5 FOR
SET SUB=$ORDER(CODES(SUB))
IF SUB=""
QUIT
Begin DoDot:1
+6 SET CODE=$PIECE(CODES(SUB),U,2)
SET DESC=$PIECE(CODES(SUB),U,3)
+7 SET BDATE=$$FMTE^XLFDT($PIECE($GET(CODE),":",2))
+8 SET EDATE=$SELECT($PIECE($GET(CODE),":",3)'="":$$FMTE^XLFDT($PIECE($GET(CODE),":",3)),1:"")
+9 SET DATE=BDATE_"-"_EDATE
+10 SET STR=$$LJ^XLFSTR($PIECE($GET(CODE),":"),8)
+11 SET STR=STR_DESC
+12 SET TEXTIN(1)=STR
+13 DO FORMAT^PXRMTEXT(1,$SELECT(ISMAIL:35,1:44),1,.TEXTIN,.NLINES,.TEXTOUT)
+14 FOR X=1:1:NLINES
Begin DoDot:2
+15 SET DTEXT=$SELECT(X=1:$$LJ^XLFSTR(TEXTOUT(X),$SELECT(ISMAIL=1:38,1:45))_DATE,1:TEXTOUT(X))
+16 SET NLINE=NLINE+1
+17 SET ^TMP(NODE,$JOB,NLINE,0)=$JUSTIFY("",15)_DTEXT
End DoDot:2
End DoDot:1
+18 QUIT
+19 ;
+20 ;general field delete sub-routine
DELFIELD(IENS,SUB,FIELD) ;Delete a field.
+1 NEW FDA,MSG
+2 SET FDA(SUB,IENS,FIELD)="@"
+3 DO FILE^DIE("","FDA","MSG")
+4 IF $DATA(MSG)
WRITE !,"Error in delete",!
DO AWRITE^PXRMUTIL("MSG")
+5 QUIT
+6 ;
+7 ;Cross-reference delete when deleting Taxonomy fields in a dialog
DELLOG(DA,FIELD,OLD,NEW) ;
+1 IF OLD=""
QUIT
+2 NEW IENS,POVIEN,PROCIEN
+3 IF FIELD=123
Begin DoDot:1
+4 IF NEW=""!(NEW="N")
Begin DoDot:2
+5 SET IENS=DA_","
DO DELFIELD(IENS,801.41,141)
+6 SET IENS=DA_","
DO DELFIELD(IENS,801.41,142)
End DoDot:2
QUIT
+7 IF NEW="D"
SET IENS=DA_","
DO DELFIELD(IENS,801.41,142)
QUIT
+8 IF NEW="P"
SET IENS=DA_","
DO DELFIELD(IENS,801.41,141)
End DoDot:1
QUIT
+9 QUIT
+10 ;
GETSTAT(TYPE) ;
+1 NEW HIST,RESULT,STATUS
+2 SET RESULT=0
+3 SET IEN=$ORDER(^PXRMD(801.45,"B",TYPE,""))
IF IEN'>0
QUIT RESULT
+4 IF '$DATA(^PXRMD(801.45,IEN,1,"B",2))
SET RESULT=1
QUIT RESULT
+5 SET HIST=$ORDER(^PXRMD(801.45,IEN,1,"B",2,""))
IF HIST'>0
SET RESULT=1
QUIT RESULT
+6 IF $PIECE($GET(^PXRMD(801.45,IEN,1,HIST,0)),U,2)=1
SET RESULT=1
QUIT RESULT
+7 SET RESULT=2
+8 SET STATUS=0
FOR
SET STATUS=$ORDER(^PXRMD(801.45,IEN,1,"B",STATUS))
IF STATUS'>0!(RESULT<2)
QUIT
IF STATUS'=2
SET RESULT=0
+9 QUIT RESULT
+10 ;
+11 ;this returns the default values from file 801.45 for POV or Procedure
+12 ;codes.
+13 ;DEFAULT(TYPE,pointer to file 801.9)=default
+14 ;DEFAULT(TYPE,pointer to file 801.9,ADDFIND,n)=additional finding node
GETTAXDF(DEFAULT,TYPE,ISHIST) ;
+1 NEW CNT,IEN,FIND,STATUS
+2 SET IEN=$ORDER(^PXRMD(801.45,"B",TYPE,""))
IF IEN'>0
QUIT
+3 ;get resolution status
+4 SET CNT=0
FOR
SET CNT=$ORDER(^PXRMD(801.45,IEN,1,CNT))
IF CNT'>0
QUIT
Begin DoDot:1
+5 SET STATUS=$PIECE($GET(^PXRMD(801.45,IEN,1,CNT,0)),U)
+6 IF ISHIST=1
IF STATUS'=2
QUIT
+7 IF ISHIST=0
IF STATUS=2
QUIT
+8 ;get prefix and suffix text
+9 SET DEFAULT(TYPE,"PREFIX")=$GET(^PXRMD(801.45,IEN,1,CNT,3))
+10 SET DEFAULT(TYPE,"SUFFIX")=$GET(^PXRMD(801.45,IEN,1,CNT,4))
+11 ;get additional findings
+12 SET FIND=0
FOR
SET FIND=$ORDER(^PXRMD(801.45,IEN,1,CNT,5,FIND))
IF FIND'>0
QUIT
Begin DoDot:2
+13 SET DEFAULT(TYPE,"ADDFIND",FIND)=$GET(^PXRMD(801.45,IEN,1,CNT,5,FIND,0))
End DoDot:2
End DoDot:1
+14 QUIT
+15 ;
+16 ;Returns the default taxonomy checkbox header for the Encounter Type
GETTEXT(VALUES,TYPE) ;
+1 ;GETTEXT(VALUES,TYPE,CURR) ;
+2 NEW ENCTYPE,IEN,TEXT
+3 SET TEXT=""
+4 SET TEXT=$GET(VALUES(TYPE,"PREFIX"))_$GET(VALUES(TYPE,"SUFFIX"))
+5 QUIT TEXT
+6 ;
HASACT(TIEN) ;
+1 NEW SYS,CODE,SDATE,EDATE,START,TODAY,FOUND,END
+2 SET TODAY=DT+1
SET FOUND=0
+3 SET SYS=""
FOR
SET SYS=$ORDER(^PXD(811.2,TIEN,20,"AUID",SYS))
IF SYS=""!(FOUND=1)
QUIT
Begin DoDot:1
+4 SET CODE=""
FOR
SET CODE=$ORDER(^PXD(811.2,TIEN,20,"AUID",SYS,CODE))
IF CODE=""!(FOUND=1)
QUIT
Begin DoDot:2
+5 SET SDATE=""
+6 FOR
SET SDATE=$ORDER(^PXD(811.2,TIEN,20,"AUID",SYS,CODE,SDATE))
IF SDATE=""!(FOUND=1)
QUIT
Begin DoDot:3
+7 SET START=SDATE-1
SET EDATE=""
+8 FOR
SET EDATE=$ORDER(^PXD(811.2,TIEN,20,"AUID",SYS,CODE,SDATE,EDATE))
IF EDATE=""!(FOUND=1)
QUIT
Begin DoDot:4
+9 SET END=$SELECT(EDATE="DT":DT+1,1:EDATE+1)
IF DT>START
IF DT<END
SET FOUND=1
QUIT
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+10 QUIT FOUND
+11 ;
PRINT(TEXTIN,NIN) ;
+1 NEW LINE,NOUT,TEXTOUT
+2 DO FORMAT^PXRMTEXT(1,75,NIN,.TEXTIN,.NOUT,.TEXTOUT)
+3 DO MES^XPDUTL(.TEXTOUT)
+4 QUIT
+5 ;
+6 ;Builds a list of prompts associated with the taxonomy finding types
+7 ;Prompts the user to add the prompts to the dialog editor. Does not prompt if prompts
+8 ;are already defined to the element.
PROMPTS(DA,SEL,DEFAULT,FDA,IENCNT) ;
+1 NEW CNT,CODE,DIR,DNUM,ENC,EXTVAL,FIELD,IEN,IENS,NAME,NODE,NUM,PROMPT,PROMPTS,START,VALUE,X,Y
+2 IF $DATA(^PXRMD(801.41,DA,10))
QUIT 0
+3 SET CODE=""
FOR
SET CODE=$ORDER(DEFAULT(CODE))
IF CODE=""
QUIT
Begin DoDot:1
+4 IF SEL="P"
IF CODE="POV"
QUIT
+5 IF SEL="D"
IF CODE="CPT"
QUIT
+6 SET CNT=0
FOR
SET CNT=$ORDER(DEFAULT(CODE,"ADDFIND",CNT))
IF CNT'>0
QUIT
Begin DoDot:2
+7 SET NODE=DEFAULT(CODE,"ADDFIND",CNT)
+8 SET IEN=$PIECE(NODE,U)
+9 IF $DATA(^PXRMD(801.41,DA,10,"D",IEN))>0
QUIT
+10 IF $DATA(PROMPTS(IEN))>0
IF $LENGTH(PROMPTS(IEN),U)<$LENGTH(NODE,U)
SET PROMPTS(IEN)=NODE
+11 SET PROMPTS(IEN)=NODE
End DoDot:2
End DoDot:1
+12 ;
+13 IF '$DATA(PROMPTS)
QUIT 0
+14 SET START=+$ORDER(^PXRMD(801.41,DA,10,""),-1)
+15 SET DNUM=0
+16 WRITE !,"Default prompts for the taxonomy:"
+17 SET IEN=0
SET CNT=0
FOR
SET IEN=$ORDER(PROMPTS(IEN))
IF IEN'>0
QUIT
Begin DoDot:1
+18 SET CNT=CNT+1
SET START=START+1
SET DNUM=DNUM+1
+19 SET IENCNT=IENCNT+1
SET IENS="+"_IENCNT_","_DA_","
+20 SET NAME=$PIECE($GET(^PXRMD(801.41,IEN,0)),U)
+21 SET NODE=PROMPTS(IEN)
SET CNT=$LENGTH(NODE,U)
+22 IF $PIECE(NODE,U,3)>0
QUIT
+23 SET FDA(801.412,IENS,.01)=START
+24 SET FDA(801.412,IENS,2)=IEN
+25 WRITE !,"Prompt: "_NAME
+26 IF CNT=1
QUIT
+27 FOR NUM=2:1:CNT
Begin DoDot:2
+28 IF NUM=3
QUIT
+29 IF NUM=4
QUIT
+30 SET VALUE=$PIECE(NODE,U,NUM)
IF $GET(VALUE)=""
QUIT
+31 SET FIELD=$SELECT(NUM=2:9,NUM=4:.01,NUM=5:6,NUM=6:7,NUM=7:8,1:"")
IF $GET(FIELD)=""
QUIT
+32 SET FDA(801.412,IENS,FIELD)=VALUE
+33 SET PROMPT=$SELECT(FIELD=.01:"Sequence",FIELD=6:"Override Prompt Caption",FIELD=7:"Start New Line",FIELD=8:"Exclude From PN Text",FIELD=9:"Required")
+34 IF $GET(PROMPT)=""
QUIT
+35 IF FIELD=6
SET EXTVAL=VALUE
+36 IF FIELD>6
SET EXTVAL=$SELECT(VALUE=1:"Yes",1:"No")
+37 WRITE !," "_PROMPT_": "_EXTVAL
End DoDot:2
End DoDot:1
+38 ;
+39 IF CNT=0
WRITE !,"None"
QUIT 0
+40 SET DIR(0)="S^Y:Yes;N:No"
+41 SET DIR("A")="Add Prompts to the dialog"
+42 SET DIR("B")="Yes"
+43 DO ^DIR
+44 IF Y[U
KILL FDA(801.412)
QUIT 0
+45 IF Y="N"
KILL FDA(801.412)
+46 QUIT 1
+47 ;
+48 ;Prompts the user for values for the fields in the Taxonomy Fields multiple.
+49 ;Builds default values from existing values or from file 801.45
TAXDIR(FIELD,CODE,DA,ARRAY) ;
+1 NEW DIR,CURVALUE,PROMPT,RESULT,SARRAY,TEMP,TYPE,X,Y
+2 SET CURVALUE=""
+3 SET DIR("A")=$SELECT(CODE="POV":"Diagnosis Header",1:"Procedure Header")
+4 SET DIR(0)="F^1:80"
+5 SET TEMP=$SELECT(CODE="POV":"diagnosis",1:"Procedure")
+6 IF +DA>0
SET CURVALUE=$$GET1^DIQ(801.41,DA_",",FIELD)
+7 IF CURVALUE=""
Begin DoDot:1
+8 SET CURVALUE=$$GETTEXT(.ARRAY,CODE)
+9 IF CURVALUE=""
SET CURVALUE="Selectable "_$SELECT($EXTRACT(TEMP)="d":TEMP_"es",1:TEMP_"s")_" codes"
End DoDot:1
+10 SET DIR("B")=CURVALUE
+11 DO ^DIR
+12 QUIT Y
+13 ;
+14 ;main taxonomy fields editor entry point. Returns ^ or ^^ or 1 is fields are answer.
TAXDIAL(IEN,FIND) ;
+1 ;Protect FileMan variables
+2 NEW D,D0,DA,DC,DDES,DE,DG,DH,DI,DIC,DIDEL,DIE,DIEDA,DIEL,DIEN,DIR,DIETMP
+3 NEW DIEXREF,DIFLD,DIEIENS,DINUSE,DIP,DISYS,DK,DL,DM,DP,DQ,DR,DU
+4 ;
+5 NEW DEF,DEFAULT,DXTYPE,FDA,FDAIEN,HTEXT,IENCNT,IENS,ISHIST,MSG,NODEIEN,NAME,NONE,PRTYPE,RESULT,STR,TAXIEN,TAXSEL,TDX,TPR,VALUE,X,Y
+6 ;
ENTAXDL ;
+1 ;
+2 SET RESULT=1
+3 IF FIND'["PXD(811.2"
QUIT 0
+4 SET DA=IEN
SET TAXIEN=+FIND
IF TAXIEN'>0
QUIT 0
+5 SET ISHIST=$SELECT($PIECE($GET(^PXRMD(801.41,IEN,1)),U,3)=2:1,1:0)
+6 SET TDX=$$TOK(TAXIEN,"POV")
+7 SET TPR=$$TOK(TAXIEN,"CPT")
+8 SET DEF=$PIECE($GET(^PXRMD(801.41,DA,"TAX")),U)
+9 SET DIR(0)="S^A:All;N:No Pick List"
DO HELP(.HTEXT,"")
+10 IF TDX=1
IF TPR=1
SET DIR(0)="S^A:All;D:ICD Diagnoses Only;P:CPT Procedures Only;N:No Pick List"
DO HELP(.HTEXT,"PD")
+11 IF $PIECE($GET(^PXRMD(801.41,IEN,0)),U,4)="G"
Begin DoDot:1
+12 IF $GET(DEF)=""
SET DEF="N"
+13 IF TDX=1
IF TPR=1
SET DIR(0)="S^D:ICD Diagnoses Only;P:CPT Procedures Only;N:No Pick List"
DO HELP(.HTEXT,"GPD")
QUIT
+14 IF TPR=1
SET DIR(0)="S^P:CPT Procedures Only;N:No Pick List"
DO HELP(.HTEXT,"GP")
QUIT
+15 SET DIR(0)="S^D:ICD Diagnoses Only;N:No Pick List"
DO HELP(.HTEXT,"GD")
End DoDot:1
+16 IF DIR(0)'[DEF
SET DEF=""
+17 SET DIR("A")="Taxonomy Pick List"
+18 SET DIR("B")=$SELECT(DEF]"":DEF,1:"A")
+19 SET DIR("?")="Select the pick list display value or '^' to quit. Enter ?? for detail help."
+20 SET DIR("??")=U_"D HELP^PXRMEUT(.HTEXT)"
+21 DO ^DIR
+22 IF Y[U
QUIT Y
+23 SET VALUE=Y
+24 SET FDA(801.41,DA_",",123)=VALUE
+25 IF VALUE="N"
GOTO TAXUPD
+26 IF TDX=1
DO GETTAXDF(.DEFAULT,"POV",ISHIST)
+27 IF TPR=1
DO GETTAXDF(.DEFAULT,"CPT",ISHIST)
+28 SET IENCNT=0
+29 IF TDX=1
IF TPR=1
IF VALUE="A"
Begin DoDot:1
+30 SET RESULT=$$BLDFDA("POV",IEN,.FDA,.DEFAULT)
IF RESULT[U
QUIT
+31 SET RESULT=$$BLDFDA("CPT",IEN,.FDA,.DEFAULT)
End DoDot:1
IF RESULT="^^"
GOTO TAXDIALX
IF RESULT=U
GOTO ENTAXDL
+32 ;I TPR=1,VALUE="A" S RESULT=$$BLDFDA("CPT",IEN,.FDA,.DEFAULT) G TAXDIALX:RESULT="^^" G ENTAXDL:RESULT=U
+33 ;
+34 SET RESULT=$$PROMPTS(IEN,VALUE,.DEFAULT,.FDA,.IENCNT)
IF RESULT[U
IF RESULT="^^"
GOTO TAXDIALX
IF RESULT=U
GOTO ENTAXDL
+35 KILL MSG
TAXUPD ;
+1 DO UPDATE^DIE("","FDA","","MSG")
+2 IF $DATA(MSG)
WRITE !,"Error in update",!
DO AWRITE^PXRMUTIL("MSG")
+3 ;
TAXDIALX ;
+1 QUIT RESULT
+2 ;
+3 ;This routine is used to display Taxonomy codes in the List Manager view for Dialog Text.
+4 ;TODO should we display any codes in Dialog Text view for Additional Findings or Taxonomy Pick List of N, D, P?
TAXDISP(FIEN,SEQ,DIEN,NLINE,NODE,ADDFIND,ISMAIL) ;
+1 NEW ARRAY,CNT,CODESYS,FILE,HIST,TIEN,TSEQ
+2 NEW CNT,DTXT,FNODE,RSUB,TDX,TNAME,TPAR,TPR,TYP
+3 NEW TCUR,TDTXT,TDHTXT,THIS,TPTXT,TPHTXT
+4 SET TIEN=$PIECE(FIEN,";")
IF TIEN=""
QUIT
+5 SET HIST=0
SET FILE=""
+6 ;Get associated codes
+7 ;
+8 ;Get taxonomy name
+9 SET TNAME=$PIECE($GET(^PXD(811.2,TIEN,0)),U,1)
+10 ;
+11 ;Check what type of taxonomy codes exist
+12 SET TDX=$$TOK(TIEN,"POV")
+13 SET TPR=$$TOK(TIEN,"CPT")
+14 ;
+15 SET TAXSEL=$PIECE($GET(^PXRMD(801.41,DIEN,"TAX")),U)
+16 IF ADDFIND=1
SET TAXSEL="N"
+17 ;
+18 IF TDX
Begin DoDot:1
+19 DO BLDCODE("POV",.CODESYS)
+20 DO CODES^PXRMDLLB(TIEN,.CODESYS,.CODES)
+21 IF '$DATA(CODES)
QUIT
+22 SET TEXT=$JUSTIFY("",15)_$SELECT(TAXSEL="N":"Diagnoses Codes:",TAXSEL="P":"Procedures Codes:",1:"Selectable Diagnoses Codes:")
SET TAB=18
+23 SET STR=$$LJ^XLFSTR($GET(TEXT),$SELECT(ISMAIL=1:51,1:60))
+24 SET STR=STR_"Activation Periods"
+25 SET NLINE=NLINE+1
+26 SET ^TMP(NODE,$JOB,NLINE,0)=STR
+27 DO CODES(TIEN,.CODES,.NLINE,HIST,ISMAIL)
+28 SET NLINE=NLINE+1
+29 SET ^TMP(NODE,$JOB,NLINE,0)=$JUSTIFY("",79)
End DoDot:1
+30 ;
+31 IF TPR
Begin DoDot:1
+32 KILL CODESYS,CODES
+33 DO BLDCODE("CPT",.CODESYS)
+34 DO CODES^PXRMDLLB(TIEN,.CODESYS,.CODES)
+35 IF '$DATA(CODES)
QUIT
+36 SET TEXT=$JUSTIFY("",15)_$SELECT(TAXSEL="N":"Procedures Codes:",TAXSEL="D":"Procedures Codes:",1:"Selectable Procedures codes:")
SET TAB=18
+37 SET STR=$$LJ^XLFSTR($GET(TEXT),$SELECT(ISMAIL=1:51,1:60))
+38 SET STR=STR_"Activation Periods"
+39 SET NLINE=NLINE+1
+40 SET ^TMP(NODE,$JOB,NLINE,0)=STR
+41 DO CODES(TIEN,.CODES,.NLINE,HIST,ISMAIL)
+42 SET NLINE=NLINE+1
+43 SET ^TMP(NODE,$JOB,NLINE,0)=$JUSTIFY("",79)
End DoDot:1
+44 QUIT
+45 ;
TAXEDITC(TIEN,TEXT) ;
+1 NEW DARRAY,DIEN,HEADER,NAME,OCNT,OUTPUT,RARRAY,RESULT,TDX,TPR,TAXNODE
+2 NEW TAXSEL
+3 DO FINDDIAL^PXRMFRPT(.DARRAY,"PXD(811.2,",TIEN)
+4 SET TEXT(1)="Taxonomy and/or the following dialog(s) have problems."
+5 SET TEXT(2)="Correct either the taxonomy or the following dialog(s):"
+6 SET CNT=2
+7 IF '$DATA(DARRAY)
GOTO TXEDITCX
+8 IF '$DATA(^PXD(811.2,TIEN,20,"AUID"))
SET TEXT(1)="Taxonomy does not contain codes marked to be used in a dialog. It is assigned to the following dialog(s)."
Begin DoDot:1
+9 SET CNT=1
SET NAME=""
FOR
SET NAME=$ORDER(DARRAY(NAME))
IF NAME=""
QUIT
SET CNT=CNT+1
SET TEXT(CNT)=" "_NAME
End DoDot:1
QUIT
+10 SET TDX=$$TOK(TIEN,"POV")
SET TPR=$$TOK(TIEN,"CPT")
+11 SET NAME=""
FOR
SET NAME=$ORDER(DARRAY(NAME))
IF NAME=""
QUIT
Begin DoDot:1
+12 SET IEN=DARRAY(NAME)
SET RESULT=$$CHECKER(IEN,TIEN,"",.OUTPUT)
IF RESULT=""
QUIT
+13 SET TEXT(2)="See below for descriptions of the problem(s):"
+14 NEW LINE,NIN,NOUT,TEMP
+15 SET NIN=$ORDER(OUTPUT(""),-1)
+16 DO FORMAT^PXRMTEXT(1,75,NIN,.OUTPUT,.NOUT,.TEMP)
+17 FOR LINE=1:1:NOUT
SET CNT=CNT+1
SET TEXT(CNT)=TEMP(LINE)
End DoDot:1
TXEDITCX ;
+1 IF CNT=2
KILL TEXT
+2 KILL ^TMP($JOB,"DLG FIND")
+3 QUIT
+4 ;
+5 ;change to use AUID cross-referenc instead of the selectable node, central location for checking what codes to use
+6 ;in a dialog for encounter type.
TOK(TIEN,TYPE) ;Check if selectable codes exist
+1 IF TYPE="POV"
IF $DATA(^PXD(811.2,TIEN,20,"AUID","ICD"))>0!($DATA(^PXD(811.2,TIEN,20,"AUID","10D"))>0)
QUIT 1
+2 IF TYPE="CPT"
IF $DATA(^PXD(811.2,TIEN,20,"AUID","CPT"))>0!($DATA(^PXD(811.2,TIEN,20,"AUID","CPC"))>0)
QUIT 1
+3 QUIT 0
+4 ;
HELP(HTEXT,TYPE) ;
+1 NEW CNT
SET CNT=1
+2 SET HTEXT(CNT)="Set the taxonomy pick list display for the codes marked to be used in a dialog."
+3 IF TYPE'["G"
SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ A: To display a pick list for all codes "
+4 IF TYPE["G"
Begin DoDot:1
+5 IF "PD"
Begin DoDot:2
+6 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ D: To display a pick list for the diagnosis codes."
+7 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ The procedure codes will automatically be filed to the encounter."
+8 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ P: To display a pick list for the procedure codes."
+9 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ The diagnosis codes will automatically be filed to the encounter."
+10 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ N: To not display a pick list all codes will automatically be filed to the encounter."
End DoDot:2
QUIT
End DoDot:1
QUIT
+11 IF TYPE["D"
Begin DoDot:1
+12 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ D: To display a pick list for the diagnosis codes."
+13 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ The procedure codes will automatically be filed to the encounter."
End DoDot:1
+14 IF TYPE["P"
Begin DoDot:1
+15 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ P: To display a pick list for the procedure codes."
+16 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ The diagnosis codes will automatically be filed to the encounter."
End DoDot:1
+17 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ N: To not display a pick list, all codes will automatically be filed "
+18 SET CNT=CNT+1
SET HTEXT(CNT)="\\\\ to the encounter."
+19 QUIT
+20 ;