PXRMPINF ;SLC/PKR - Routines relating to patient information. ;23-Mar-2015 10:39;DU
;;2.0;CLINICAL REMINDERS;**1001,12,17,24,1005**;Feb 04, 2005;Build 23
;
;IHS/MSC/MGH Patch 1001 IHS is not currently using military sexual trauma
;======================================================
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="PXRM PXK EVENT"_$J_" "_$$NOW^XLFDT
;Make sure EVENT is unique.
I $D(^XTMP(EVENT)) H 1 S EVENT="PXRM PXK EVENT"_$J_" "_$$NOW^XLFDT
K ^XTMP(EVENT)
S ^XTMP(EVENT,0)=$$FMADD^XLFDT(DT,3)_U_DT
M ^XTMP(EVENT)=^TMP("PXKCO",$J)
L +^XTMP(EVENT):DILOCKTM
S ZTSAVE("EVENT")=""
S ZTSAVE("XTMP(")=""
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.
;IHS/MSC/MGH Patch 1001 IHS is not currently using military sexual trauma or suicide
;D UPDPAT^PXRMMST(EVENT,DFN,VISIT,.VFL)
;D SUICIDE^PXRMNTFY(EVENT,DFN,VISIT)
;L -^XTMP(EVENT)
;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)
;IHS/MSC/MGH PATCH 1001 Add in HRCN
S DEMARR("HRCN")=$$HRCN^PXRMXXT(DFN,+$G(DUZ(2)))
S DEMARR("DOD")=$P($G(^DPT(DFN,.35)),U,1)
I DEMARR("DOD")>TODAY S DEMARR("DOD")=""
S DEMARR("DFN")=DFN
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
Q
;
PXRMPINF ;SLC/PKR - Routines relating to patient information. ;23-Mar-2015 10:39;DU
+1 ;;2.0;CLINICAL REMINDERS;**1001,12,17,24,1005**;Feb 04, 2005;Build 23
+2 ;
+3 ;IHS/MSC/MGH Patch 1001 IHS is not currently using military sexual trauma
+4 ;======================================================
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="PXRM PXK EVENT"_$JOB_" "_$$NOW^XLFDT
+7 ;Make sure EVENT is unique.
+8 IF $DATA(^XTMP(EVENT))
HANG 1
SET EVENT="PXRM PXK EVENT"_$JOB_" "_$$NOW^XLFDT
+9 KILL ^XTMP(EVENT)
+10 SET ^XTMP(EVENT,0)=$$FMADD^XLFDT(DT,3)_U_DT
+11 MERGE ^XTMP(EVENT)=^TMP("PXKCO",$JOB)
+12 LOCK +^XTMP(EVENT):DILOCKTM
+13 SET ZTSAVE("EVENT")=""
+14 SET ZTSAVE("XTMP(")=""
+15 SET ZTRTN="DATACHGR^PXRMPINF"
+16 SET ZTDESC="Clinical Reminders PXK VISIT DATA EVENT handler"
+17 SET ZTDTH=$HOROLOG
+18 SET ZTIO=""
+19 DO ^%ZTLOAD
+20 QUIT
+21 ;
+22 ;======================================================
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 ;IHS/MSC/MGH Patch 1001 IHS is not currently using military sexual trauma or suicide
+18 ;D UPDPAT^PXRMMST(EVENT,DFN,VISIT,.VFL)
+19 ;D SUICIDE^PXRMNTFY(EVENT,DFN,VISIT)
+20 ;L -^XTMP(EVENT)
+21 ;K ^XTMP(EVENT)
+22 QUIT
+23 ;
+24 ;======================================================
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 ;IHS/MSC/MGH PATCH 1001 Add in HRCN
+16 SET DEMARR("HRCN")=$$HRCN^PXRMXXT(DFN,+$GET(DUZ(2)))
+17 SET DEMARR("DOD")=$PIECE($GET(^DPT(DFN,.35)),U,1)
+18 IF DEMARR("DOD")>TODAY
SET DEMARR("DOD")=""
+19 SET DEMARR("DFN")=DFN
+20 SET DEMARR("AGE")=$$AGE^PXRMAGE(DEMARR("DOB"),DEMARR("DOD"),TODAY)
+21 ;DBIA #1096
+22 SET TEMP=$ORDER(^DGPM("ATID1",DFN,""))
+23 IF TEMP'=""
SET TEMP=9999999.999999-TEMP
+24 SET DEMARR("LAD")=TEMP
+25 QUIT
+26 ;