PXRMPINF ;SLC/PKR - Routines relating to patient information. ;07/01/2020
;;2.0;CLINICAL REMINDERS;**12,17,24,45,42**;Feb 04, 2005;Build 245
;
;===============
DATACHG ;This entry point is called whenever patient data has changed.
;It is attached to the following event points:
;PXK VISIT DATA EVENT via PXRM PATIENT DATA CHANGE
;
I '$D(^TMP("PXKCO",$J)) Q
N EVENT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
S EVENT=$$NEWEVENT("PXRM PXK EVENT",$NA(^TMP("PXKCO",$J)),.ZTSAVE)
S ZTRTN="DATACHGR^PXRMPINF"
S ZTDESC="Clinical Reminders PXK VISIT DATA EVENT handler"
S ZTDTH=$H
S ZTIO=""
D ^%ZTLOAD
Q
;
;===============
DATACHGR ;Process data from PXK VISIT DATA EVENT
N DATA,DFN,DGBL,NODE,PXRMDFN,VIEN,VISIT,VF,VFL,VGBL
S ZTREQ="@"
;Look for PXK VISIT DATA EVENT data.
S VISIT=$O(^XTMP(EVENT,0))
S VIEN=$O(^XTMP(EVENT,VISIT,"VST",""))
S NODE=$O(^XTMP(EVENT,VISIT,"VST",VIEN,""))
S DATA=$G(^XTMP(EVENT,VISIT,"VST",VIEN,NODE,"AFTER"))
I DATA="" S DATA=$G(^XTMP(EVENT,VISIT,"VST",VIEN,NODE,"BEFORE"))
S DFN=$P(DATA,U,5)
;Build the list of V Files.
S VF=""
F S VF=$O(^XTMP(EVENT,VISIT,VF)) Q:VF="" D
. S DGBL=$S(VF="CPT":"PXD(811.2,",VF="HF":"AUTTHF(",VF="IMM":"AUTTIMM(",VF="PED":"AUTTEDT(",VF="POV":"PXD(811.2,",VF="SK":"AUTTSK(",VF="XAM":"AUTTEXAM(",1:"")
. S VGBL=$S(VF="CPT":"AUPNVCPT(",VF="HF":"AUPNVHF(",VF="IMM":"AUPNVIMM(",VF="PED":"AUPNVPED(",VF="POV":"AUPNVPOV(",VF="SK":"AUPNVSK(",VF="XAM":"AUPNVXAM(",1:"")
. S VFL(VF)=DGBL_U_VGBL
;Call the routines that need to process the data.
D UPDPAT^PXRMMST(EVENT,DFN,VISIT,.VFL)
D SUICIDE^PXRMNTFY(EVENT,DFN,VISIT)
D:'$$ISHIST^PXRMVSIT(VISIT) WH^PXRMNTFY(EVENT,DFN,VISIT)
K ^XTMP(EVENT)
Q
;
;===============
DEM(DFN,TODAY,DEMARR) ;Load the patient demographics into DEMARR
;The patient's age is calculated using whatever date is passed as
;TODAY. If there is a date of death and it is greater than TODAY
;then set the date of death to null. Direct read of patient file
;supported DBIA #10035. DATE OF BIRTH and SEX are required fields
;in the patient file.
N TEMP
K DEMARR
I $L(DFN)'>0 S DEMARR("PATIENT")="" Q
S TEMP=$G(^DPT(DFN,0))
I TEMP="" S DEMARR("PATIENT")="" Q
S DEMARR("PATIENT")=$P(TEMP,U,1)
S DEMARR("SEX")=$P(TEMP,U,2)
S DEMARR("DOB")=$P(TEMP,U,3)
S DEMARR("SSN")=$P(TEMP,U,9)
S DEMARR("DOD")=$P($G(^DPT(DFN,.35)),U,1)
I DEMARR("DOD")>TODAY S DEMARR("DOD")=""
S DEMARR("DFN")=DFN
S DEMARR("SIG")=$P($G(^DPT(DFN,.24)),U,4)
S DEMARR("AGE")=$$AGE^PXRMAGE(DEMARR("DOB"),DEMARR("DOD"),TODAY)
;DBIA #1096
S TEMP=$O(^DGPM("ATID1",DFN,""))
I TEMP'="" S TEMP=9999999.999999-TEMP
S DEMARR("LAD")=TEMP
;Save the global demographic variables for reminder test.
I $G(PXRMDEBG) D
. K ^TMP("PXRMDEM",$J)
. N SUB
. S SUB=""
. F S SUB=$O(DEMARR(SUB)) Q:SUB="" S ^TMP("PXRMDEM",$J,SUB)=DEMARR(SUB)
Q
;
;===============
NEWEVENT(EVENT,DATALOC,ZTSAVE) ;Generate a new node in ^XTMP to store data for
;later processing
N RETURN
S RETURN=EVENT_$J_" "_$$NOW^XLFDT
;Make sure sub-script is unique.
F Q:'$D(^XTMP(RETURN)) I $D(^XTMP(RETURN)) H 1 S RETURN=EVENT_$J_" "_$$NOW^XLFDT
K ^XTMP(RETURN)
S ^XTMP(RETURN,0)=$$FMADD^XLFDT($$NOW^XLFDT,0,12)_U_DT
M ^XTMP(RETURN)=@DATALOC
S ZTSAVE("EVENT")=""
S ZTSAVE("XTMP(")=""
Q RETURN
;
;===============
PLIST ;This entry point is called whenever patient data has changed.
;It is attached to the following event points:
;GMPL EVENT via PXRM PATIENT PROBLEM DATA CHANGE
;
I '$D(DFN)!('$D(GMPIFN)) Q
N EVENT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
S ZTSAVE("DFN")=""
S ZTSAVE("GMPIFN")=""
S ZTRTN="PLISTR^PXRMPINF"
S ZTDESC="Clinical Reminders GMPL EVENT handler"
S ZTDTH=$H
S ZTIO=""
D ^%ZTLOAD
Q
;
;===============
PLISTR ;Process data from GMPL EVENT
;For diagnoses added to the problem list via the Encounter
;form, both DATACHG and PLIST line tags are executed
;in that order
S ZTREQ="@"
;Call the routines that need to process the data.
D WH^PXRMNTFY("",DFN,"",GMPIFN)
Q
;
;===============
PTFCHG ;This entry point is called whenever patient data has changed.
;It is attached to the following event points:
;DG PTF ICD DIAGNOSIS NOTIFIER via PXRM PATIENT PTF DATA CHANGE
I '$D(^TMP("DG PTF ICD NOTIFIER",$J)) Q
N EVENT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
S EVENT=$$NEWEVENT("PXRM PTF EVENT",$NA(^TMP("DG PTF ICD NOTIFIER",$J)),.ZTSAVE)
S ZTRTN="PTFCHGR^PXRMPINF"
S ZTDESC="Clinical Reminders DG PTF ICD DIAGNOSIS NOTIFIER handler"
S ZTDTH=$H
S ZTIO=""
D ^%ZTLOAD
Q
;
;===============
PTFCHGR ;Process data from DG PTF ICD DIAGNOSIS NOTIFIER
S ZTREQ="@"
N DFN
S DFN=$G(^XTMP(EVENT,"DFN"))
D WH^PXRMNTFY(EVENT,DFN,"","")
K ^XTMP(EVENT)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMPINF 4779 printed Dec 13, 2024@01:48:32 Page 2
PXRMPINF ;SLC/PKR - Routines relating to patient information. ;07/01/2020
+1 ;;2.0;CLINICAL REMINDERS;**12,17,24,45,42**;Feb 04, 2005;Build 245
+2 ;
+3 ;===============
DATACHG ;This entry point is called whenever patient data has changed.
+1 ;It is attached to the following event points:
+2 ;PXK VISIT DATA EVENT via PXRM PATIENT DATA CHANGE
+3 ;
+4 IF '$DATA(^TMP("PXKCO",$JOB))
QUIT
+5 NEW EVENT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+6 SET EVENT=$$NEWEVENT("PXRM PXK EVENT",$NAME(^TMP("PXKCO",$JOB)),.ZTSAVE)
+7 SET ZTRTN="DATACHGR^PXRMPINF"
+8 SET ZTDESC="Clinical Reminders PXK VISIT DATA EVENT handler"
+9 SET ZTDTH=$HOROLOG
+10 SET ZTIO=""
+11 DO ^%ZTLOAD
+12 QUIT
+13 ;
+14 ;===============
DATACHGR ;Process data from PXK VISIT DATA EVENT
+1 NEW DATA,DFN,DGBL,NODE,PXRMDFN,VIEN,VISIT,VF,VFL,VGBL
+2 SET ZTREQ="@"
+3 ;Look for PXK VISIT DATA EVENT data.
+4 SET VISIT=$ORDER(^XTMP(EVENT,0))
+5 SET VIEN=$ORDER(^XTMP(EVENT,VISIT,"VST",""))
+6 SET NODE=$ORDER(^XTMP(EVENT,VISIT,"VST",VIEN,""))
+7 SET DATA=$GET(^XTMP(EVENT,VISIT,"VST",VIEN,NODE,"AFTER"))
+8 IF DATA=""
SET DATA=$GET(^XTMP(EVENT,VISIT,"VST",VIEN,NODE,"BEFORE"))
+9 SET DFN=$PIECE(DATA,U,5)
+10 ;Build the list of V Files.
+11 SET VF=""
+12 FOR
SET VF=$ORDER(^XTMP(EVENT,VISIT,VF))
if VF=""
QUIT
Begin DoDot:1
+13 SET DGBL=$SELECT(VF="CPT":"PXD(811.2,",VF="HF":"AUTTHF(",VF="IMM":"AUTTIMM(",VF="PED":"AUTTEDT(",VF="POV":"PXD(811.2,",VF="SK":"AUTTSK(",VF="XAM":"AUTTEXAM(",1:"")
+14 SET VGBL=$SELECT(VF="CPT":"AUPNVCPT(",VF="HF":"AUPNVHF(",VF="IMM":"AUPNVIMM(",VF="PED":"AUPNVPED(",VF="POV":"AUPNVPOV(",VF="SK":"AUPNVSK(",VF="XAM":"AUPNVXAM(",1:"")
+15 SET VFL(VF)=DGBL_U_VGBL
End DoDot:1
+16 ;Call the routines that need to process the data.
+17 DO UPDPAT^PXRMMST(EVENT,DFN,VISIT,.VFL)
+18 DO SUICIDE^PXRMNTFY(EVENT,DFN,VISIT)
+19 if '$$ISHIST^PXRMVSIT(VISIT)
DO WH^PXRMNTFY(EVENT,DFN,VISIT)
+20 KILL ^XTMP(EVENT)
+21 QUIT
+22 ;
+23 ;===============
DEM(DFN,TODAY,DEMARR) ;Load the patient demographics into DEMARR
+1 ;The patient's age is calculated using whatever date is passed as
+2 ;TODAY. If there is a date of death and it is greater than TODAY
+3 ;then set the date of death to null. Direct read of patient file
+4 ;supported DBIA #10035. DATE OF BIRTH and SEX are required fields
+5 ;in the patient file.
+6 NEW TEMP
+7 KILL DEMARR
+8 IF $LENGTH(DFN)'>0
SET DEMARR("PATIENT")=""
QUIT
+9 SET TEMP=$GET(^DPT(DFN,0))
+10 IF TEMP=""
SET DEMARR("PATIENT")=""
QUIT
+11 SET DEMARR("PATIENT")=$PIECE(TEMP,U,1)
+12 SET DEMARR("SEX")=$PIECE(TEMP,U,2)
+13 SET DEMARR("DOB")=$PIECE(TEMP,U,3)
+14 SET DEMARR("SSN")=$PIECE(TEMP,U,9)
+15 SET DEMARR("DOD")=$PIECE($GET(^DPT(DFN,.35)),U,1)
+16 IF DEMARR("DOD")>TODAY
SET DEMARR("DOD")=""
+17 SET DEMARR("DFN")=DFN
+18 SET DEMARR("SIG")=$PIECE($GET(^DPT(DFN,.24)),U,4)
+19 SET DEMARR("AGE")=$$AGE^PXRMAGE(DEMARR("DOB"),DEMARR("DOD"),TODAY)
+20 ;DBIA #1096
+21 SET TEMP=$ORDER(^DGPM("ATID1",DFN,""))
+22 IF TEMP'=""
SET TEMP=9999999.999999-TEMP
+23 SET DEMARR("LAD")=TEMP
+24 ;Save the global demographic variables for reminder test.
+25 IF $GET(PXRMDEBG)
Begin DoDot:1
+26 KILL ^TMP("PXRMDEM",$JOB)
+27 NEW SUB
+28 SET SUB=""
+29 FOR
SET SUB=$ORDER(DEMARR(SUB))
if SUB=""
QUIT
SET ^TMP("PXRMDEM",$JOB,SUB)=DEMARR(SUB)
End DoDot:1
+30 QUIT
+31 ;
+32 ;===============
NEWEVENT(EVENT,DATALOC,ZTSAVE) ;Generate a new node in ^XTMP to store data for
+1 ;later processing
+2 NEW RETURN
+3 SET RETURN=EVENT_$JOB_" "_$$NOW^XLFDT
+4 ;Make sure sub-script is unique.
+5 FOR
if '$DATA(^XTMP(RETURN))
QUIT
IF $DATA(^XTMP(RETURN))
HANG 1
SET RETURN=EVENT_$JOB_" "_$$NOW^XLFDT
+6 KILL ^XTMP(RETURN)
+7 SET ^XTMP(RETURN,0)=$$FMADD^XLFDT($$NOW^XLFDT,0,12)_U_DT
+8 MERGE ^XTMP(RETURN)=@DATALOC
+9 SET ZTSAVE("EVENT")=""
+10 SET ZTSAVE("XTMP(")=""
+11 QUIT RETURN
+12 ;
+13 ;===============
PLIST ;This entry point is called whenever patient data has changed.
+1 ;It is attached to the following event points:
+2 ;GMPL EVENT via PXRM PATIENT PROBLEM DATA CHANGE
+3 ;
+4 IF '$DATA(DFN)!('$DATA(GMPIFN))
QUIT
+5 NEW EVENT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+6 SET ZTSAVE("DFN")=""
+7 SET ZTSAVE("GMPIFN")=""
+8 SET ZTRTN="PLISTR^PXRMPINF"
+9 SET ZTDESC="Clinical Reminders GMPL EVENT handler"
+10 SET ZTDTH=$HOROLOG
+11 SET ZTIO=""
+12 DO ^%ZTLOAD
+13 QUIT
+14 ;
+15 ;===============
PLISTR ;Process data from GMPL EVENT
+1 ;For diagnoses added to the problem list via the Encounter
+2 ;form, both DATACHG and PLIST line tags are executed
+3 ;in that order
+4 SET ZTREQ="@"
+5 ;Call the routines that need to process the data.
+6 DO WH^PXRMNTFY("",DFN,"",GMPIFN)
+7 QUIT
+8 ;
+9 ;===============
PTFCHG ;This entry point is called whenever patient data has changed.
+1 ;It is attached to the following event points:
+2 ;DG PTF ICD DIAGNOSIS NOTIFIER via PXRM PATIENT PTF DATA CHANGE
+3 IF '$DATA(^TMP("DG PTF ICD NOTIFIER",$JOB))
QUIT
+4 NEW EVENT,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+5 SET EVENT=$$NEWEVENT("PXRM PTF EVENT",$NAME(^TMP("DG PTF ICD NOTIFIER",$JOB)),.ZTSAVE)
+6 SET ZTRTN="PTFCHGR^PXRMPINF"
+7 SET ZTDESC="Clinical Reminders DG PTF ICD DIAGNOSIS NOTIFIER handler"
+8 SET ZTDTH=$HOROLOG
+9 SET ZTIO=""
+10 DO ^%ZTLOAD
+11 QUIT
+12 ;
+13 ;===============
PTFCHGR ;Process data from DG PTF ICD DIAGNOSIS NOTIFIER
+1 SET ZTREQ="@"
+2 NEW DFN
+3 SET DFN=$GET(^XTMP(EVENT,"DFN"))
+4 DO WH^PXRMNTFY(EVENT,DFN,"","")
+5 KILL ^XTMP(EVENT)
+6 QUIT
+7 ;