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

PXRMVLST.m

Go to the documentation of this file.
  1. PXRMVLST ;SLC/PKR - Validate a reminder definition for building a patient list. ;09/07/2010
  1. ;;2.0;CLINICAL REMINDERS;**4,18**;Feb 04, 2005;Build 152
  1. ;==================================================
  1. CCF(FINDING) ;Check a computed finding to see if it can be used for building
  1. ;a list.
  1. N IEN,TEMP,TEXT,TYPE,VALID
  1. S VALID=1
  1. S IEN=$P(FINDING,";",1)
  1. S TEMP=$G(^PXRMD(811.4,IEN,0))
  1. I TEMP="" D Q 0
  1. . S TEXT="Trying to use computed finding number "_IEN_" it does not exist!"
  1. . D EN^DDIOL(TEXT)
  1. S TYPE=$P(TEMP,U,5)
  1. I TYPE="" S TYPE="S"
  1. I TYPE'="L" D
  1. . S VALID=0
  1. . S TEXT(1)="Computed finding "_$P(TEMP,U,1)_" is type "_TYPE_"."
  1. . S TEXT(2)="It cannot be used for building patient lists!"
  1. . D EN^DDIOL(.TEXT)
  1. Q VALID
  1. ;
  1. ;==================================================
  1. CTERM(DEFARR,FINUM,FINDING) ;Check terms for computed findings and
  1. ;health factors to see if they are valid for building a list.
  1. N IEN,IND,TEXT,VALID,WCR
  1. S IEN=$P(FINDING,";",1)
  1. I '$D(^PXRMD(811.5,IEN,0)) D Q 0
  1. . S TEXT="Trying to use term number "_IEN_" it does not exist!"
  1. . D EN^DDIOL(TEXT)
  1. S VALID=1
  1. I $D(^PXRMD(811.5,IEN,20,"E","PXRMD(811.4,")) D
  1. . S IND=0
  1. . F S IND=$O(^PXRMD(811.5,IEN,20,"E","PXRMD(811.4,",IND)) Q:IND="" D
  1. .. S VALID=$$CCF(IND)
  1. .. I 'VALID D
  1. ... S TEXT="The computed finding is used in term "_$P(^PXRMD(811.5,IEN,0),U,1)_"."
  1. ... D EN^DDIOL(TEXT)
  1. Q VALID
  1. ;
  1. ;==================================================
  1. HF(DEFARR,FINUM) ;
  1. ;If a health factor is used its Within Category Rank must be 0.
  1. N WCR,TEXT
  1. S WCR=$P(DEFARR(20,FINUM,0),U,10)
  1. I WCR=0 Q 1
  1. S TEXT="Finding "_FINUM_" is a health factor and its Within Category Rank is not 0!"
  1. D EN^DDIOL(TEXT)
  1. Q 0
  1. ;
  1. ;==================================================
  1. VDEF(RIEN) ;Check a reminder definition and see if it is valid for
  1. ;use in creating a patient list.
  1. N AGEFI,AGR,AT,DEFARR,FFL,FI,FIL,FILIST,FINDING,FINUM,FREQ,FUNCTION
  1. N FUNN,IND,OPER,MAXAGE,MINAGE,NUMAFI,PCLOG,PFSTACK,ROUTINE
  1. N SAAFI,SEXFI,SSTACK,TEMP,TEXT,TYPE,VALID,VF
  1. I RIEN="" Q 0
  1. I '$D(^PXD(811.9,RIEN)) D Q 0
  1. . S TEXT="The reminder does not exist!"
  1. . D EN^DDIOL(TEXT)
  1. ;
  1. ;See if the reminder is inactive.
  1. I $P($G(^PXD(811.9,RIEN,0)),U,6) D Q 0
  1. . S TEXT="This reminder is inactive!"
  1. . D EN^DDIOL(TEXT)
  1. ;
  1. D DEF^PXRMLDR(RIEN,.DEFARR)
  1. S PCLOG=DEFARR(31)
  1. I PCLOG="" D Q 0
  1. . S TEXT="This reminder does not contain any patient cohort logic!"
  1. . D EN^DDIOL(TEXT)
  1. ;
  1. ;The cohort logic cannot contain the old-style MRD.
  1. I $G(^PXD(811.9,RIEN,30))["MRD" D Q 0
  1. . S TEXT="The patient cohort logic cannot contain the old-style MRD!"
  1. . D EN^DDIOL(TEXT)
  1. ;
  1. ;The cohort logic cannot start with a not.
  1. I $E(PCLOG,1)="'" D Q 0
  1. . S TEXT="The patient cohort logic cannot start with a not!"
  1. . D EN^DDIOL(TEXT)
  1. ;
  1. ;The cohort logic cannot contain or not.
  1. ;Change any !(' to !' before checking.
  1. S TEMP=$TR(PCLOG,"(","")
  1. S TEMP=$TR(TEMP,")","")
  1. I TEMP["!'" D Q 0
  1. . S TEXT="The patient cohort logic cannot contain or not!"
  1. . D EN^DDIOL(TEXT)
  1. ;
  1. S OPER="!&~"
  1. S PCLOG=$$STRREP^PXRMUTIL(PCLOG,"&'","~")
  1. D POSTFIX^PXRMSTAC(PCLOG,OPER,.PFSTACK)
  1. D CFSAA^PXRMPLST(.PFSTACK)
  1. M SSTACK=PFSTACK
  1. S (AGEFI,SAAFI,SEXFI)=0
  1. F IND=1:1:PFSTACK(0) D
  1. . S TEMP=$$POP^PXRMSTAC(.PFSTACK)
  1. . I TEMP="AGE" S AGEFI=IND
  1. . I TEMP="SAA" S SAAFI=IND
  1. . I TEMP="SEX" S SEXFI=IND
  1. . I TEMP="'SEX" S SEXFI=IND
  1. ;
  1. ;If AGE is defined then make sure a baseline age range is defined.
  1. I (AGEFI)!(SAAFI) D
  1. . S (AGR,IND)=0
  1. . F S IND=+$O(DEFARR(7,IND)) Q:IND=0 D
  1. .. S TEMP=DEFARR(7,IND,0)
  1. .. I $P(TEMP,U,2)'="" S AGR=1
  1. .. I $P(TEMP,U,3)'="" S AGR=1
  1. ;
  1. S TEMP=DEFARR(40)
  1. S NUMAFI=+$P(TEMP,U,1)
  1. S FILIST=$P(TEMP,U,2)
  1. I (AGEFI!SAAFI),('AGR&(NUMAFI=0)) D Q 0
  1. . S TEXT(1)="Age is used in the cohort logic and neither a baseline age range or any age"
  1. . S TEXT(2)="findings have been defined!"
  1. . D EN^DDIOL(.TEXT)
  1. ;
  1. ;SEX cannot be the first element unless it is followed by & AGE.
  1. I (SEXFI=1),('SAAFI) D Q 0
  1. . S TEXT="SEX must be followed by & AGE when it starts the patient cohort logic!"
  1. . D EN^DDIOL(TEXT)
  1. ;If SEX is defined and there is not a combined sex & age finding then
  1. ;a sex must be defined and the logical operator cannot be an or.
  1. S VALID=1
  1. I (SEXFI),('SAAFI) D
  1. . I $P(^PXD(811.9,RIEN,0),U,9)="" D
  1. .. S VALID=0
  1. .. S TEXT(1)="Sex is used in the patient cohort logic and no sex is defined in the reminder"
  1. .. S TEXT(2)="definition!"
  1. .. D EN^DDIOL(.TEXT)
  1. . I VALID D
  1. .. S TEMP=SSTACK(SEXFI+1)
  1. .. I TEMP="!" D
  1. ... S VALID=0
  1. ... S TEXT="SEX cannot be used in conjunction with the or operator!"
  1. ... D EN^DDIOL(TEXT)
  1. I 'VALID Q VALID
  1. ;
  1. ;Check the age findings and see if any of them set the frequency to
  1. ;0Y. If they do they cannot have an associated age range.
  1. F IND=1:1:NUMAFI D
  1. . S FINUM=$P(FILIST,";",IND)
  1. . S TEMP=$S(FINUM["FF":DEFARR(25,FINUM,0),1:DEFARR(20,FINUM,0))
  1. . S MINAGE=$P(TEMP,U,2)
  1. . S MAXAGE=$P(TEMP,U,3)
  1. . S FREQ=$P(TEMP,U,4)
  1. . I FREQ="0Y",((MINAGE'="")!(MAXAGE'="")) D
  1. .. S VALID=0
  1. .. S TEXT(1)="Finding "_FINUM_" sets the frequency to 0Y and also sets an age range."
  1. .. S TEXT(2)="An age range is not allowed with a frequency of 0Y!"
  1. .. D EN^DDIOL(.TEXT)
  1. ;
  1. ;Build a list of all the findings that affect whether or not the
  1. ;patient is in the cohort and check to see if any of them use a
  1. ;computed finding. If they use a computed finding then it must be
  1. ;a list type. Health factors must have within category rank of 0.
  1. F IND=1:1:SSTACK(0) D
  1. . I (SSTACK(IND)["FI") D
  1. .. S FINUM=$G(SSTACK(IND+1))
  1. .. S FIL(FINUM)=""
  1. . I (SSTACK(IND)["FF") D
  1. .. S FINUM=$G(SSTACK(IND+1))
  1. .. S FFL(FINUM)="FF"_FINUM
  1. ;Add any age findings to the list.
  1. F IND=1:1:NUMAFI D
  1. . S TEMP=$P(FILIST,";",IND)
  1. . I TEMP=+TEMP S FIL(TEMP)=""
  1. . I TEMP["FF" S FFL($P(TEMP,"FF",2))=TEMP
  1. ;Add findings used by function findings to the list.
  1. S IND=0
  1. F S IND=$O(FFL(IND)) Q:IND="" D
  1. . S FUNN=0
  1. . S FUNN=$O(DEFARR(25,FFL(IND),5,FUNN)) Q:FUNN="" D
  1. .. S FUNCTION=$P(DEFARR(25,FFL(IND),5,FUNN,0),U,2)
  1. .. S ROUTINE=$P(^PXRMD(802.4,FUNCTION,0),U,1)
  1. .. S ROUTINE=$TR(ROUTINE,"_","")
  1. .. S FI=0
  1. .. F S FI=$O(DEFARR(25,FFL(IND),5,FUNN,20,FI)) Q:FI="" D
  1. ... S FINUM=DEFARR(25,FFL(IND),5,FUNN,20,FI,0)
  1. ...;Determine if this subscript is a finding or not before checking
  1. ...;if the finding exists.
  1. ... S AT=$$ARGTYPE^PXRMFFAT(ROUTINE,FI)
  1. ... I AT'="F" Q
  1. ... S FIL(FINUM)=""
  1. ... I '$D(DEFARR(20,FINUM)) D Q
  1. .... S VALID=0
  1. .... S TEXT="Finding "_FINUM_" is used in FF("_IND_") and it does not exist!"
  1. .... D EN^DDIOL(TEXT)
  1. I 'VALID Q VALID
  1. S IND=0
  1. F S IND=$O(FIL(IND)) Q:IND="" D
  1. . S FINDING=$P($G(DEFARR(20,IND,0)),U,1)
  1. . I FINDING="" D Q
  1. .. S VALID=0
  1. .. S TEXT="Finding number "_IND_" does not exist!"
  1. .. D EN^DDIOL(TEXT)
  1. . S TEMP=$P(FINDING,";",2)
  1. . S TYPE=$S(TEMP="AUTTHF(":"HF",TEMP="PXRMD(811.4,":"CF",TEMP="PXRMD(811.5,":"TERM",1:"REG")
  1. . I TYPE="REG" Q
  1. . I TYPE="CF" S VF=$$CCF(FINDING)
  1. . I TYPE="HF" S VF=$$HF(.DEFARR,IND)
  1. . I TYPE="TERM" S VF=$$CTERM(.DEFARR,IND,FINDING)
  1. . I VF=0 D
  1. .. S VALID=0
  1. .. S TEXT="Finding number "_IND_" is the problem finding."
  1. .. D EN^DDIOL(TEXT)
  1. Q VALID
  1. ;