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

PXRMMSER.m

Go to the documentation of this file.
PXRMMSER ;SLC/PKR,AJB - Computed findings for military service information. ;02/08/2024
 ;;2.0;CLINICAL REMINDERS;**11,12,21,24,26,42,88**;Feb 04, 2005;Build 13
 ;Reference       ICR#
 ;MSDATA^DGMSE    5354
 ;OEIF^DGMSE      5354
 ;
 ;===============
AORANGE(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will be true if the agent orange exposure registration
 ;date is in the date range specified by Beginning Date/Time
 ;and Ending Date/Time. VA-AGENT ORANGE EXPOSURE.
 N RDATE
 S NFOUND=0
 D GETSVCD(DFN)
 S TEST=^TMP($J,"SVC",DFN,2)
 I 'TEST Q
 S RDATE=+$P(^TMP($J,"SVC",DFN,2,1),U,1)
 I (RDATE=0)!(RDATE<BDT)!(RDATE>EDT) S TEST=0 Q
 S NFOUND=1
 S TEST(NFOUND)=1,DATE(NFOUND)=RDATE
 S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"LOCATION"))=$P(^TMP($J,"SVC",DFN,2,5),U,2)
 S TEXT(NFOUND)="Agent orange exposure registration date: "_$$FMTE^XLFDT(RDATE,"5Z")_"; location: "_DATA(NFOUND,"LOCATION")
 Q
 ;
 ;===============
COMBAT(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will be true if combat service is found in the
 ;date range the date range specified by Beginning Date/Time
 ;and Ending Date/Time. VA-COMBAT SERVICE.
 N FDATE,TDATE
 S NFOUND=0
 D GETSVCD(DFN)
 S TEST=^TMP($J,"SVC",DFN,5)
 I 'TEST Q
 S FDATE=$P(^TMP($J,"SVC",DFN,5,1),U,1)
 S TDATE=$P(^TMP($J,"SVC",DFN,5,2),U,1)
 I $$OVERLAP^PXRMINDX(FDATE,TDATE,BDT,EDT)'="O" S TEST=0 Q
 S NFOUND=1
 S TEST(NFOUND)=1,DATE(NFOUND)=FDATE
 S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"LOCATION"))=$P(^TMP($J,"SVC",DFN,5,3),U,2)
 S TEXT(NFOUND)="Combat service from "_$$FMTE^XLFDT(FDATE,"5Z")_" to "_$$FMTE^XLFDT(TDATE,"5Z")_"; location: "_DATA(NFOUND,"LOCATION")
 Q
 ;
 ;===============
CVELIG(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;Computed finding for
 ;combat vet eligibility data. VA-COMBAT VET ELIGIBILITY.
 N CV,EDATE,ELIG,RESULT
 ;DBIA #4156
 S RESULT=$$CVEDT^DGCV(DFN,$$NOW^PXRMDATE)
 ;RESULT=(1,0,-1)^End Date (if populated, otherwise null)^CV
 ;      (piece 1)  1 - qualifies as a CV
 ;                 0 - does not qualify as a CV
 ;                -1 - bad DFN or date
 ;      (piece 3)  1 - vet was eligible on date specified (or DT)      
 ;                 0 - vet was not eligible on date specified (or DT)
 S CV=$P(RESULT,U,1),EDATE=$P(RESULT,U,2),ELIG=$P(RESULT,U,3)
 I 'CV S NFOUND=0 Q
 S NFOUND=1
 S TEST(NFOUND)=CV,DATE(NFOUND)=$$NOW^PXRMDATE
 S TEXT(NFOUND)="End date is "_$$FMTE^XLFDT(EDATE,"5Z")
 S DATA(NFOUND,"END DATE")=EDATE
 S DATA(NFOUND,"VALUE")=$S(ELIG:"ELIGIBLE",1:"EXPIRED")
 S DATA(NFOUND,"STATUS")=DATA(NFOUND,"VALUE")
 Q
 ;
 ;===============
DISCHDT(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
 ;This computed finding returns the service separation date.
 ;CF.VA-SERVICE SEPARATION DATES
 N IND
 D MSDATA(DFN,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT,1)
 F IND=1:1:NFOUND S DATA(IND,"VALUE")=DATE(IND)
 Q
 ;
 ;===============
ELIG(DFN,TEST,DATE,DATA,TEXT) ;
 ;This computed finding gets a list of the patient's eligibilities
 ;using ELIG^VADPT. The Computed Finding Parameter can be used to
 ;check for a particular eligibility.
 ;CF.VA-ELIGIBILITY
 N DONE,CFPARAM,DEFTEXT,IND,P1,P2,PARAM,PS1,PS2,PSUB,SUB,SUB1,SUB2
 N TEMP,TPARAM,VAEL,VAERR,VAL
 S CFPARAM=TEST
 I CFPARAM="" S TEST=0 Q
 S PARAM=$P(CFPARAM,"|",1)
 S DEFTEXT=$P(CFPARAM,"|",2)
 S DATE=$$NOW^PXRMDATE
 D ELIG^VADPT
 ;Store secondary eligibilities by name.
 S IND=0
 F  S IND=+$O(VAEL(1,IND)) Q:IND=0  D
 . S TEMP=$P(VAEL(1,IND),U,2)
 . S VAEL("SE",TEMP)=1
 ;Initialize undefined VAEL elements in CFPARAM.
 S (DONE,P1)=0
 S TPARAM=$TR(PARAM,"""","")
 F  Q:DONE  D
 . S P1=$F(TPARAM,"VAEL(",P1)
 . I P1=0 S DONE=1 Q
 . S P2=$F(TPARAM,")",P1)
 . S SUB=$E(TPARAM,P1,P2-2)
 . I SUB'["," D  Q
 .. I '$D(VAEL(SUB)) S VAEL(SUB)=""
 . S SUB1=$P(SUB,",",1),SUB2=$P(SUB,",",2)
 . I '$D(VAEL(SUB1,SUB2)) S VAEL(SUB1,SUB2)=""
 I $G(PXRMDEBG)=1 M ^TMP("PXRMELIG",$J)=VAEL
 I VAERR=1 S TEST=0 Q
 S TEST=0
 I @PARAM D
 . N PSUB
 . I DEFTEXT'="" S TEXT=DEFTEXT_"\\"_" CFPARAM="_PARAM
 . E  S TEXT="CFPARAM="_PARAM
 . S TEST=1
 . S (DONE,P1,PS1)=0
 . F  Q:DONE  D
 .. S P1=$F(TPARAM,"VAEL(",P1)
 .. I P1=0 S DONE=1 Q
 .. S P2=$F(TPARAM,")",P1)
 .. S SUB=$E(TPARAM,P1,P2-2)
 .. S PS1=$F(PARAM,"VAEL(",PS1)
 .. S PS2=$F(PARAM,")",PS1)
 .. S PSUB=$E(PARAM,PS1,PS2-2)
 .. S VAL=$S(SUB'[",":VAEL(SUB),1:VAEL($P(SUB,",",1),$P(SUB,",",2)))
 .. S TEXT=TEXT_"\\"_" VAEL("_PSUB_")="_VAL
 D KVAR^VADPT
 Q
 ;
 ;===============
GETSVCD(DFN) ;Get the SVC^VADPT service data.
 I $D(^TMP($J,"SVC",DFN)) Q
 N VAERR,VAROOT
 S VAROOT="^TMP($J,""SVC"",DFN)"
 D SVC^VADPT
 D KVAR^VADPT
 Q
 ;
 ;===============
MSDATA(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT,SEPDTR) ;This computed
 ;finding will return service branch information.
 ;CF.VA-SERVICE BRANCH.
 ;DBIA #5354
 N ENTRYDTA,MSDATA,NEPS
 D MSDATA^DGMSE(DFN,.NEPS,.ENTRYDTA,.MSDATA)
 I NEPS=0 S NFOUND=0 Q
 N BRANCH,DISTYPE,ENTRYDT,ENTRYDTO,IND,NOW
 N SCOMP,SDIR,SEPDT,SEPDTC,SEPDTO
 S NOW=$$NOW^PXRMDATE
 S SDIR=$S(NGET>0:-1,1:1)
 S NGET=$S(NGET<0:-NGET,1:NGET)
 S NFOUND=0,ENTRYDT=""
 F  S ENTRYDT=$O(ENTRYDTA(ENTRYDT),SDIR) Q:(ENTRYDT="")!(NFOUND=NGET)  D
 . S IND=ENTRYDTA(ENTRYDT)
 . S SEPDT=MSDATA(IND,"SEPARATION DATE")
 .;Check for separation date required.
 . I SEPDTR,SEPDT="" Q
 . I SEPDTR,(SEPDT>EDT) Q
 .;If there is no Separation Date use the evaluation date and time.
 . S SEPDTC=$S(SEPDT'="":SEPDT,1:NOW)
 . I $$OVERLAP^PXRMINDX(ENTRYDT,SEPDTC,BDT,EDT)'="O" Q
 . S NFOUND=NFOUND+1
 . S TEST(NFOUND)=1
 . S DATE(NFOUND)=MSDATA(IND,"DATE")
 . S BRANCH=MSDATA(IND,"BRANCH")
 . I BRANCH="" S BRANCH="<NO DATA>"
 . S DATA(NFOUND,"BRANCH")=BRANCH
 . S SCOMP=MSDATA(IND,"SERVICE COMPONENT")
 . S SCOMP=$S(SCOMP="":"<NO DATA>",1:SCOMP)
 . S DATA(NFOUND,"SERVICE COMPONENT")=SCOMP
 . S DISTYPE=MSDATA(IND,"DISCHARGE TYPE")
 . S DISTYPE=$S(DISTYPE="":"<NO DATA>",1:DISTYPE)
 . S DATA(NFOUND,"DISCHARGE TYPE")=DISTYPE
 . S ENTRYDTO=$$FMTE^XLFDT(ENTRYDT,"5Z")
 . S SEPDTO=$S(SEPDT="":"<NO DATA>",1:$$FMTE^XLFDT(SEPDT,"5Z"))
 . S TEXT(NFOUND)="Service from "_ENTRYDTO_" to "_SEPDTO_" in "_BRANCH_"; service component "_SCOMP_"; discharge "_DISTYPE_"."
 Q
 ;
 ;===============
OEF(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will return OEF service information in the date range
 ;specified by Beginning Date/Time and Ending Date/Time.
 ;VA-OEF SERVICE.
 N FDATE,IND,SDIR,TDATE,TEMP
 S NFOUND=0
 S SDIR=$S(NGET<0:1,1:-1)
 S NGET=$S(NGET<0:-NGET,1:NGET)
 D GETSVCD(DFN)
 I ^TMP($J,"SVC",DFN,12)=0 Q
 S IND=""
 F  S IND=$O(^TMP($J,"SVC",DFN,12,IND)) Q:IND=""  D
 . S FDATE=$P(^TMP($J,"SVC",DFN,12,IND,2),U,1)
 . I FDATE="" Q
 . S TDATE=$P(^TMP($J,"SVC",DFN,12,IND,3),U,1)
 . I $$OVERLAP^PXRMINDX(FDATE,TDATE,BDT,EDT)'="O" Q
 . S TEMP(FDATE,"TEST")=1
 . S TEMP(FDATE,"DATA","LOCATION")=$P(^TMP($J,"SVC",DFN,12,IND,1),U,2)
 . S TEMP(FDATE,"TEXT")="OEF service from "_$$FMTE^XLFDT(FDATE,"5Z")_" to "_$$FMTE^XLFDT(TDATE,"5Z")_"; location: "_TEMP(FDATE,"DATA","LOCATION")
 S FDATE=""
 F  S FDATE=$O(TEMP(FDATE),SDIR) Q:(FDATE="")!(NFOUND=NGET)  D
 . S NFOUND=NFOUND+1
 . S TEST(NFOUND)=TEMP(FDATE,"TEST"),DATE(NFOUND)=FDATE
 . S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"LOCATION"))=TEMP(FDATE,"DATA","LOCATION")
 . S TEXT(NFOUND)=TEMP(FDATE,"TEXT")
 Q
 ;
 ;===============
OEIF(NGET,BDT,EDT,TGLIST,PARAM) ;List computed finding to build patient
 ;list based on OEF/OIF/UNK data.
 ;VA-OEF/OIF
 N DA,DATE,DFN,FDATE,LOC,LOCATION,NFOUND,TDATE
 K ^TMP($J,TGLIST)
 ;DBIA #5354
 D OEIF^DGMSE(BDT,EDT,"OEIF")
 S DATE=$$NOW^PXRMDATE
 S NGET=$S(NGET<0:-NGET,1:NGET)
 S LOCATION=$G(PARAM)
 I LOCATION="" S LOCATION="ANY"
 S DFN=""
 F  S DFN=$O(^TMP($J,"OEIF",DFN)) Q:DFN=""  D
 . S FDATE=""
 . F  S FDATE=$O(^TMP($J,"OEIF",DFN,FDATE)) Q:FDATE=""  D
 .. S TDATE=""
 .. F  S TDATE=$O(^TMP($J,"OEIF",DFN,FDATE,TDATE)) Q:TDATE=""  D
 ... S LOC=""
 ... F  S LOC=$O(^TMP($J,"OEIF",DFN,FDATE,TDATE,LOC)) Q:LOC=""  D
 .... S NFOUND=+$O(^TMP($J,TGLIST,DFN,""))
 .... I NFOUND=NGET Q
 .... I (LOCATION["ANY")!(LOCATION[LOC) D
 ..... S DA=""
 ..... F  S DA=$O(^TMP($J,"OEIF",DFN,FDATE,TDATE,LOC,DA)) Q:DA=""  D
 ...... S NFOUND=NFOUND+1
 ...... S ^TMP($J,TGLIST,DFN,NFOUND)=DFN_";"_DA_U_DATE_U_2_U_LOC_U_TDATE_";"_FDATE
 K ^TMP($J,"OEIF")
 Q
 ;
 ;===============
OIF(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will return OIF service information in the date range
 ;specified by Beginning Date/Time and Ending Date/Time.
 ;VA-OIF SERVICE.
 N FDATE,IND,SDIR,TDATE,TEMP
 S NFOUND=0
 S SDIR=$S(NGET<0:1,1:-1)
 S NGET=$S(NGET<0:-NGET,1:NGET)
 D GETSVCD(DFN)
 I ^TMP($J,"SVC",DFN,11)=0 Q
 S IND=""
 F  S IND=$O(^TMP($J,"SVC",DFN,11,IND)) Q:IND=""  D
 . S FDATE=$P(^TMP($J,"SVC",DFN,11,IND,2),U,1)
 . I FDATE="" Q
 . S TDATE=$P(^TMP($J,"SVC",DFN,11,IND,3),U,1)
 . I $$OVERLAP^PXRMINDX(FDATE,TDATE,BDT,EDT)'="O" Q
 . S TEMP(FDATE,"TEST")=1
 . S TEMP(FDATE,"DATA","LOCATION")=$P(^TMP($J,"SVC",DFN,11,IND,1),U,2)
 . S TEMP(FDATE,"TEXT")="OIF service from "_$$FMTE^XLFDT(FDATE,"5Z")_" to "_$$FMTE^XLFDT(TDATE,"5Z")_"; location: "_TEMP(FDATE,"DATA","LOCATION")
 S FDATE=""
 F  S FDATE=$O(TEMP(FDATE),SDIR) Q:(FDATE="")!(NFOUND=NGET)  D
 . S NFOUND=NFOUND+1
 . S TEST(NFOUND)=TEMP(FDATE,"TEST"),DATE(NFOUND)=FDATE
 . S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"LOCATION"))=TEMP(FDATE,"DATA","LOCATION")
 . S TEXT(NFOUND)=TEMP(FDATE,"TEXT")
 Q
 ;
 ;===============
PHEART(DFN,TEST,DATE,VALUE,TEXT) ;Single value computed finding for
 ;purple heart data. VA-PURPLE HEART.
 N CV,EDATE,ELIG,RESULT
 D GETSVCD(DFN)
 S TEST=^TMP($J,"SVC",DFN,9)
 I 'TEST Q
 S DATE=$$NOW^PXRMDATE
 S VALUE=""
 S TEXT="Patient is a Purple Heart recipient."
 Q
 ;
 ;===============
POW(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will be true if the patient was a POW in the date range
 ;specified by Beginning Date/Time and Ending Date/Time.
 ;VA-POW.
 N FDATE,TDATE
 S NFOUND=0
 D GETSVCD(DFN)
 S TEST=^TMP($J,"SVC",DFN,4)
 I 'TEST Q
 S FDATE=$P(^TMP($J,"SVC",DFN,4,1),U,1)
 S TDATE=$P(^TMP($J,"SVC",DFN,4,2),U,1)
 I $$OVERLAP^PXRMINDX(FDATE,TDATE,BDT,EDT)'="O" S TEST=0 Q
 S NFOUND=1
 S TEST(NFOUND)=1,DATE(NFOUND)=FDATE
 S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"LOCATION"))=$P(^TMP($J,"SVC",DFN,4,3),U,2)
 S TEXT(NFOUND)="Patient was a POW from "_$$FMTE^XLFDT(FDATE,"5Z")_" to "_$$FMTE^XLFDT(TDATE,"5Z")_"; location: "_DATA(NFOUND,"LOCATION")
 Q
 ;
 ;===============
RADEXP(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;;This computed
 ;finding will be true if the radiation exposure registration
 ;date is in the date range specified by Beginning Date/Time
 ;and Ending Date/Time. DVA-RADIATION EXPOSURE.
 N RDATE
 S NFOUND=0
 D GETSVCD(DFN)
 S TEST=^TMP($J,"SVC",DFN,3)
 I 'TEST Q
 S RDATE=$P(^TMP($J,"SVC",DFN,3,1),U,1)
 I (RDATE<BDT)!(RDATE>EDT) S TEST=0 Q
 S NFOUND=1
 S TEST(NFOUND)=1,DATE(NFOUND)=RDATE
 S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"EXPOSURE METHOD"))=$P(^TMP($J,"SVC",DFN,3,2),U,2)
 S TEXT(NFOUND)="Radiation exposure registration date: "_$$FMTE^XLFDT(RDATE,"5Z")_"; exposure method: "_DATA(NFOUND,"EXPOSURE METHOD")
 Q
 ;
 ;===============
SBRANCH(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will return service branch information.
 ;CF.VA-SERVICE BRANCH.
 N IND
 D MSDATA(DFN,NGET,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT,0)
 F IND=1:1:NFOUND S DATA(IND,"VALUE")=DATA(IND,"BRANCH")
 Q
 ;
 ;===============
UNKOEIF(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed
 ;finding will return unknown OEF/OIF service information in the date
 ;range specified by Beginning Date/Time and Ending Date/Time.
 ;VA-UNKNOWN OEF/OIF SERVICE.
 N FDATE,IND,SDIR,TDATE,TEMP
 S NFOUND=0
 S SDIR=$S(NGET<0:1,1:-1)
 S NGET=$S(NGET<0:-NGET,1:NGET)
 D GETSVCD(DFN)
 I ^TMP($J,"SVC",DFN,13)=0 Q
 S IND=""
 F  S IND=$O(^TMP($J,"SVC",DFN,13,IND)) Q:IND=""  D
 . S FDATE=$P(^TMP($J,"SVC",DFN,13,IND,2),U,1)
 . I FDATE="" Q
 . S TDATE=$P(^TMP($J,"SVC",DFN,13,IND,3),U,1)
 . I $$OVERLAP^PXRMINDX(FDATE,TDATE,BDT,EDT)'="O" Q
 . S TEMP(FDATE,"TEST")=1
 . S TEMP(FDATE,"DATA","LOCATION")=$P(^TMP($J,"SVC",DFN,13,IND,1),U,2)
 . S TEMP(FDATE,"TEXT")="OEF/OIF service from "_$$FMTE^XLFDT(FDATE,"5Z")_" to "_$$FMTE^XLFDT(TDATE,"5Z")_"; location: "_TEMP(FDATE,"DATA","LOCATION")
 S FDATE=""
 F  S FDATE=$O(TEMP(FDATE),SDIR) Q:(FDATE="")!(NFOUND=NGET)  D
 . S NFOUND=NFOUND+1
 . S TEST(NFOUND)=TEMP(FDATE,"TEST"),DATE(NFOUND)=FDATE
 . S (DATA(NFOUND,"VALUE"),DATA(NFOUND,"LOCATION"))=TEMP(FDATE,"DATA","LOCATION")
 . S TEXT(NFOUND)=TEMP(FDATE,"TEXT")
 Q
 ;
 ;===============
VETERAN(DFN,TEST,DATE,VALUE,TEXT) ;Computed finding for checking if a
 ;patient is a veteran. VA-VETERAN.
 N VAEL
 S DATE=$$NOW^PXRMDATE
 D ELIG^VADPT
 S TEST=VAEL(4)
 S VALUE=""
 D KVAR^VADPT
 Q
 ;
 ;===============
VIET(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;This computed will be
 ;true if Vietnam service in the date range specified by BDT and EDT
 ;is found. Note even though it is a multi structure it can only
 ;return one occurrence. VA-VIETNAM SERVICE.
 N FDATE,TDATE
 S NFOUND=0
 D GETSVCD(DFN)
 S TEST=^TMP($J,"SVC",DFN,1)
 I 'TEST Q
 S FDATE=$P(^TMP($J,"SVC",DFN,1,1),U,1)
 S TDATE=$P(^TMP($J,"SVC",DFN,1,2),U,1)
 I $$OVERLAP^PXRMINDX(FDATE,TDATE,BDT,EDT)'="O" S TEST=0 Q
 S NFOUND=1
 S TEST(NFOUND)=1,DATE(NFOUND)=FDATE
 S TEXT(NFOUND)="Vietnam service from "_$$FMTE^XLFDT(FDATE,"5Z")_" to "_$$FMTE^XLFDT(TDATE,"5Z")
 Q
 ;