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

PXRMIOPT.m

Go to the documentation of this file.
PXRMIOPT ;SLC/PKR - Computed finding in/out patient status. ;02/06/2019
 ;;2.0;CLINICAL REMINDERS;**42**;Feb 04, 2005;Build 245
 ;
 ;====================
IOPT(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,FIDATA,TEXT) ;Routine for the computed
 ;finding VA-INPATIENT/OUTPATIENT FINDINGS.
 N ABBR,ABLIST,DEFARR,FIEN,FIEVAL,FILENUM,FIMOD,FIMODS,FIMODV
 N FINDING,INOUT,ROOT,TFINDING
 ;
 S TFINDING=$P(TEST,U,1)
 S INOUT=$P(TEST,U,2)
 S FIMODS=$P(TEST,U,3)
 I INOUT="" S INOUT="INP"
 S (NFOUND,TEST)=0
 I TFINDING="" Q
 I (INOUT'="INP"),(INOUT'="OUT") Q
 ;
 S ABBR=$P(TFINDING,".",1),FINDING=$P(TFINDING,".",2)
 D BLDALIST^PXRMVPTR(811.902,.01,.ABLIST)
 I '$D(ABLIST(ABBR)) Q
 S FILENUM=$P(ABLIST(ABBR),U,1)
 S FIEN=+$$FIND1^DIC(FILENUM,"","ABX",FINDING)
 I FIEN=0 Q
 S ROOT=$P($$ROOT^DILFD(FILENUM),U,2)
 S DEFARR(20,1,0)=FIEN_";"_ROOT
 S $P(DEFARR(20,1,0),U,9)=BDT
 S $P(DEFARR(20,1,0),U,11)=EDT
 S $P(DEFARR(20,1,0),U,14)=NGET
 ;For health factors, Within Category Rank defaults to 0.
 S $P(DEFARR(20,1,0),U,10)=0
 ;If a Finding Modifier was passed set it.
 I FIMODS'="" D
 . S FIMOD=$P(FIMODS,":",1)
 . S FIMODV=$P(FIMODS,":",2)
 . I FIMOD="USE INACTIVE PROBLEMS" S $P(DEFARR(20,1,0),U,9)=FIMODV
 . I FIMOD="WITHIN CATEGORY RANK" S $P(DEFARR(20,1,0),U,10)=FIMODV
 . I FIMOD="MH SCALE" S $P(DEFARR(20,1,0),U,12)=FIMODV
 . I FIMOD="RX TYPE" S $P(DEFARR(20,1,0),U,13)=FIMODV
 . I FIMOD="USE START DATE" S $P(DEFARR(20,1,0),U,15)=FIMODV
 . I FIMOD="INCLUDE VISIT DATA" S $P(DEFARR(20,1,0),U,16)=FIMODV
 S DEFARR("E",ROOT,FIEN,1)=""
 D EVAL^PXRMEVFI(DFN,.DEFARR,.FIEVAL)
 I FIEVAL(1)=0 Q
 ;
 N DATAINP,DATEINP,FINAME,IND,INPT,JND,JNDS,KND,MSG,NFINP,TESTINP,TEXTINP
 S TESTINP=""
 D WASINP^PXRMPDEM(DFN,99,BDT,EDT,.NFINP,.TESTINP,.DATEINP,.DATAINP,.TEXTINP)
 I (NFINP=0),(INOUT="INP") Q
 I (NFINP=0),(INOUT="OUT") D  Q
 . S IND=0
 . F  S IND=+$O(FIEVAL(1,IND)) Q:IND=0  D
 .. I FIEVAL(1,IND)=1 S NFOUND=NFOUND+1,DATE(NFOUND)=FIEVAL(1,IND,"DATE"),TEST(NFOUND)=1
 S FINAME=ABBR_"."_$$GET1^DIQ(FILENUM,FIEN_",",.01,"","","MSG")
 S (IND,NFOUND)=0
 F   S IND=+$O(FIEVAL(1,IND)) Q:IND=0  D
 . I FIEVAL(1,IND)=0 Q
 . S INPT=0
 . F JND=1:1:NFINP D
 .. S INPT=((FIEVAL(1,IND,"DATE"))'<(DATAINP(JND,"ADMISSION DATE")))&((FIEVAL(1,IND,"DATE"))'>(DATAINP(JND,"DISCHARGE DATE")))
 .. I INPT=1 S JNDS=JND,JND=NFINP
 .;If INPT is true then the finding occurred during an inpatient stay.
 . I ((INOUT="INP")&(INPT))!((INOUT="OUT")&('INPT))&(NFOUND<NGET) D
 .. S NFOUND=NFOUND+1
 .. S TEST(NFOUND)=1
 .. S DATE(NFOUND)=FIEVAL(1,IND,"DATE")
 .. I $G(PXRMDEBG)=1 K FIEVAL(1,IND,"CSUB")
 .. S KND=1
 .. F  S KND=$O(FIEVAL(1,IND,KND)) Q:KND=""  M FIDATA(NFOUND,KND)=FIEVAL(1,IND,KND)
 .. I INOUT="INP" S TEXT(NFOUND)=TEXTINP(JNDS)_"\\"_FINAME_" "_$$EDATE^PXRMDATE(FIEVAL(1,IND,"DATE"))
 .. I INOUT="OUT" S TEXT(NFOUND)="This instance of "_FINAME_" occurred outside of all inpatient stays."
 Q
 ;