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

PXRMPTL.m

Go to the documentation of this file.
  1. PXRMPTL ;SLC/DLT,PKR,PJH - Print Clinical Reminders logic ;05/09/2022
  1. ;;2.0;CLINICAL REMINDERS;**4,12,18,65**;Feb 04, 2005;Build 438
  1. ;
  1. ;====================================================
  1. BLDFLST(RITEM,FL) ;Build the list of findings defined for this reminder.
  1. N IC,TEMP,GLOB,SUB,NAME
  1. ;Build a list of findings.
  1. S IC=0
  1. F S IC=$O(^PXD(811.9,RITEM,20,IC)) Q:+IC=0 D
  1. . S TEMP=$P(^PXD(811.9,RITEM,20,IC,0),U)
  1. . S GLOB=$P(TEMP,";",2),SUB=$P(TEMP,";")
  1. . S NAME=$S(GLOB="":"???",1:$P($G(@(U_GLOB_SUB_",0)")),U))
  1. . S FL(IC)=NAME
  1. Q
  1. ;
  1. ;====================================================
  1. CDUE(CDUE,FL,NL,ARRAY) ;Expand the custom date due string into ARRAY.
  1. N FILIST,FREQLIST,FUNCTION,IND,OPLIST,NARGS
  1. D PARSE^PXRMCDUE(CDUE,.FUNCTION,.NARGS,.FILIST,.FREQLIST,.OPLIST)
  1. S ARRAY(1)=FUNCTION_"(",NL=1
  1. F IND=1:1:NARGS D
  1. . S NL=NL+1
  1. . S ARRAY(NL)=FL(FILIST(IND))_OPLIST(IND)_FREQLIST(IND)
  1. . I IND<NARGS S ARRAY(NL)=ARRAY(NL)_", "
  1. S NL=NL+1,ARRAY(NL)=")"
  1. Q
  1. ;
  1. ;====================================================
  1. COHORT(DA) ;
  1. N ARRAY,CNT,LINE,NODE,NLINES,OUTPUT
  1. F NODE=60,61,65,66,70,71,75,76,83,84,93,94 I $D(^PXD(811.9,DA,NODE))>0 D
  1. . I NODE=60 W !,"General Patient Cohort Found Text:"
  1. . I NODE=61 W !,"General Patient Cohort Not Found Text:"
  1. . I NODE=65 W !,"General Resolution Found Text:"
  1. . I NODE=66 W !,"General Resolution Not Found Text:"
  1. . I NODE=70 W !,"Summary Patient Cohort Found Text:"
  1. . I NODE=71 W !,"Summary Patient Cohort Not Found Text:"
  1. . I NODE=75 W !,"Summary Resolution Found Text:"
  1. . I NODE=76 W !,"Summary Resolution Not Found Text:"
  1. . I NODE=83 W !,"Contraindicated True Text:"
  1. . I NODE=84 W !,"Contraindicated False Text:"
  1. . I NODE=93 W !,"Refused True Text:"
  1. . I NODE=94 W !,"Refused False Text:"
  1. . S (CNT,LINE)=0 F S LINE=$O(^PXD(811.9,DA,NODE,LINE)) Q:LINE="" D
  1. .. S CNT=CNT+1 S ARRAY(CNT)=$G(^PXD(811.9,DA,NODE,LINE,0))
  1. . I $D(ARRAY)>0 D FORMAT^PXRMTEXT(5,78,CNT,.ARRAY,.NLINES,.OUTPUT)
  1. . I NLINES>0 F CNT=1:1:NLINES W !,OUTPUT(CNT)
  1. . W !
  1. Q
  1. ;
  1. ;====================================================
  1. DISLOG ;Display the patient cohort, resolution logic, and custom date due.
  1. ;Determine if this is a default adhoc logic or user modified logic
  1. N CDUE,CUSTOM,FL,IND,LARRAY,LOGSTR,MAXLEN,NLOGLIN,NPL
  1. N PARRAY,RITEM,SEP
  1. S MAXLEN=72
  1. ;Build the list of findings for this reminder.
  1. S RITEM=D0
  1. D BLDFLST(RITEM,.FL)
  1. ;
  1. ;Get the cohort logic string.
  1. S LOGSTR=$G(^PXD(811.9,RITEM,30))
  1. ;Otherwise use internal cohort logic
  1. I LOGSTR="" S LOGSTR=$G(^PXD(811.9,RITEM,31)),CUSTOM=0
  1. E S CUSTOM=1
  1. ;
  1. ;Remove any (0)! and (1)& entries
  1. S LOGSTR=$$REMOVE(LOGSTR)
  1. ;
  1. ;Break the logic string into an array using the Boolean operators
  1. ;and the comma as separators.
  1. S SEP="'!&<>=,"
  1. S NLOGLIN=$$STRARR(LOGSTR,SEP,.LARRAY)
  1. ;
  1. ;Print the cohort logic.
  1. I CUSTOM W "Customized PATIENT COHORT LOGIC to see if the Reminder applies to a patient:"
  1. E W "Default PATIENT COHORT LOGIC to see if the Reminder applies to a patient:"
  1. S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. ;
  1. ;Expand the logic and print it.
  1. D EXPAND(NLOGLIN,.LARRAY,.FL,"FI(",")")
  1. S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. W !!,"Expanded PATIENT COHORT LOGIC:"
  1. F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. ;
  1. ;Get the resolution logic string.
  1. S LOGSTR=$G(^PXD(811.9,RITEM,34))
  1. ;Otherwise use internal resolution logic
  1. I LOGSTR="" S LOGSTR=$G(^PXD(811.9,RITEM,35)),CUSTOM=0
  1. E S CUSTOM=1
  1. ;
  1. ;Remove any (0)! and (1)& entries
  1. S LOGSTR=$$REMOVE(LOGSTR)
  1. ;
  1. ;Break the logic string into an array using the Boolean operators
  1. ;and the comma as separators.
  1. S NLOGLIN=$$STRARR(LOGSTR,SEP,.LARRAY)
  1. ;
  1. ;Print the resolution logic.
  1. W !!
  1. I CUSTOM W "Customized RESOLUTION LOGIC defines findings that resolve the Reminder:"
  1. E W "Default RESOLUTION LOGIC defines findings that resolve the Reminder:"
  1. S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. ;
  1. ;Expand the logic and print it.
  1. D EXPAND(NLOGLIN,.LARRAY,.FL,"FI(",")")
  1. S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. W !!,"Expanded RESOLUTION LOGIC:"
  1. F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. ;
  1. ;Display the custom date due string.
  1. S CDUE=$G(^PXD(811.9,D0,45))
  1. I CDUE'="" D
  1. . W !!,"CUSTOM DATE DUE:"
  1. . W !," ",CDUE
  1. . D CDUE(CDUE,.FL,.NLOGLIN,.LARRAY)
  1. . S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. . W !!,"Expanded CUSTOM DATE DUE:"
  1. . F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. ;
  1. ;Get the contraindicated logic string.
  1. S LOGSTR=$G(^PXD(811.9,RITEM,80))
  1. I LOGSTR'="" D
  1. .;Remove any (0)! and (1)& entries
  1. . S LOGSTR=$$REMOVE(LOGSTR)
  1. . ;
  1. . ;Break the logic string into an array using the Boolean operators
  1. . ;and the comma as separators.
  1. . S NLOGLIN=$$STRARR(LOGSTR,SEP,.LARRAY)
  1. .;
  1. .;Print the contraindicated logic.
  1. . W !!,"CONTRAINDICATED LOGIC"
  1. . S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. . F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. . ;
  1. . ;Expand the logic and print it.
  1. . D EXPAND(NLOGLIN,.LARRAY,.FL,"FI(",")")
  1. . S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. . W !!,"Expanded CONTRAINDICATED LOGIC:"
  1. . F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. ;
  1. ;Get the refused logic string.
  1. S LOGSTR=$G(^PXD(811.9,RITEM,90))
  1. I LOGSTR'="" D
  1. .;Remove any (0)! and (1)& entries
  1. . S LOGSTR=$$REMOVE(LOGSTR)
  1. . ;
  1. . ;Break the logic string into an array using the Boolean operators
  1. . ;and the comma as separators.
  1. . S NLOGLIN=$$STRARR(LOGSTR,SEP,.LARRAY)
  1. .;
  1. .;Print the contraindicated logic.
  1. . W !!,"REFUSED LOGIC"
  1. . S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. . F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. . ;
  1. . ;Expand the logic and print it.
  1. . D EXPAND(NLOGLIN,.LARRAY,.FL,"FI(",")")
  1. . S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. . W !!,"Expanded REFUSED LOGIC:"
  1. . F IND=1:1:NPL W !,?1,PARRAY(IND)
  1. Q
  1. ;
  1. ;====================================================
  1. DISLOGF(RITEM,FINDING,FL,PARRAY) ;Expand FUNCTION FINDING logic and
  1. ;return the result in PARRAY.
  1. N ARGNUM,AT,C1,FARG,FUN,FUNCTION,FUNSTR,IND,ISFUN,MAXLEN,LARRAY
  1. N NAME,NLOGLIN,NPL,NUM,SEP,TEMP
  1. S MAXLEN=72
  1. K PARRAY
  1. ;Get the function string.
  1. S FUNSTR=$G(^PXD(811.9,RITEM,25,FINDING,3))
  1. I FUNSTR="" Q
  1. ;
  1. ;Establish the list of separators that can be used in the logic
  1. ;string and take it apart.
  1. S SEP="'!&=><,()+-"
  1. S NLOGLIN=$$STRARR(FUNSTR,SEP,.LARRAY)
  1. ;Replace argument numbers with the finding.
  1. S FARG=0
  1. F IND=1:1:NLOGLIN D
  1. . S TEMP=LARRAY(IND)
  1. . I TEMP="" Q
  1. . S FUN=$P(TEMP,"(",1)
  1. . S ISFUN=$S(FUN="":0,$D(^PXRMD(802.4,"B",FUN)):1,1:0)
  1. . I ISFUN S FARG=1,FUNCTION=$TR(FUN,"_",""),ARGNUM=0 Q
  1. . I FARG D
  1. .. S C1=$E(TEMP,1)
  1. .. I (C1="C")!(C1="R") S TEMP=$E(TEMP,2,15)
  1. .. S NUM=+TEMP
  1. .. S ARGNUM=ARGNUM+1
  1. .. S AT=$$ARGTYPE^PXRMFFAT(FUNCTION,ARGNUM)
  1. .. I AT="F" D
  1. ... S NAME=$S($D(FL(NUM)):FL(NUM),1:"???")
  1. ... I (C1="C")!(C1="R") S NAME=":"_NAME
  1. ... S LARRAY(IND)=$$STRREP^PXRMUTIL(LARRAY(IND),NUM,NAME)
  1. ..E S LARRAY(IND)=TEMP
  1. . I TEMP[")" S FARG=0
  1. ;Format the array for printing.
  1. S NPL=$$FMTARR(MAXLEN,NLOGLIN,.LARRAY,.PARRAY)
  1. Q
  1. ;
  1. ;====================================================
  1. EXPAND(NL,ARRAY,FL,LT,RT) ;Insert findings in FI(n) format. Each element
  1. ;of ARRAY will contain no more than one FI.
  1. N FIE,FIS,FNUM,LEN,NAME,STRING
  1. F IND=1:1:NL D
  1. . S STRING=ARRAY(IND)
  1. . S FIS=$F(STRING,LT)
  1. . I FIS=0 Q
  1. . S LEN=$L(STRING)
  1. . S FIE=$F(STRING,RT,FIS)-2
  1. . S FNUM=$E(STRING,FIS,FIE)
  1. . S NAME=$S($D(FL(FNUM)):FL(FNUM),1:"???")
  1. . S ARRAY(IND)=$E(STRING,1,FIS-1)_NAME_$E(STRING,FIE+1,LEN)
  1. Q
  1. ;
  1. ;====================================================
  1. FMTARR(MAXLEN,NE,INARRAY,OUTARRAY) ;Load the output array.
  1. N IC,LINNUM,SLEN
  1. K OUTARRY
  1. S OUTARRAY(1)=""
  1. S LINNUM=1
  1. F IC=1:1:NE D
  1. . S SLEN=$L(OUTARRAY(LINNUM))+$L(INARRAY(IC))
  1. . I SLEN>MAXLEN D
  1. .. S LINNUM=LINNUM+1
  1. .. S OUTARRAY(LINNUM)=INARRAY(IC)
  1. . E S OUTARRAY(LINNUM)=OUTARRAY(LINNUM)_INARRAY(IC)
  1. Q LINNUM
  1. ;
  1. ;====================================================
  1. STRARR(STRING,SEP,ARRAY) ;Break STRING into an array using SEP.
  1. N CHAR,IC,LINNUM,NE,SLEN,TEMP
  1. K OUTARRAY
  1. ;Break string into pieces using SEP.
  1. S SLEN=$L(STRING)
  1. S LINNUM=0,TEMP=""
  1. F IC=1:1:SLEN D
  1. . S CHAR=$E(STRING,IC,IC)
  1. . S TEMP=TEMP_CHAR
  1. . I SEP[CHAR D
  1. .. S LINNUM=LINNUM+1
  1. .. S ARRAY(LINNUM)=TEMP
  1. .. S TEMP=""
  1. S LINNUM=LINNUM+1
  1. S ARRAY(LINNUM)=TEMP
  1. Q LINNUM
  1. ;
  1. ;====================================================
  1. REMOVE(STRING) ;Remove leading (n) entries
  1. I ($E(STRING,1,4)="(0)!")!($E(STRING,1,4)="(1)&") S $E(STRING,1,4)=""
  1. Q STRING
  1. ;