VPSPDO1 ;DALOI/KML,WOIFO/BT - PDO OUTPUT DISPLAY - ALLERGIES ;11/20/11 15:30
;;1.0;VA POINT OF SERVICE (KIOSKS);**3**;Oct 21, 2011;Build 64
;;Per VHA Directive 2004-038, this routine should not be modified.
;
Q
;IA #10103 - supported use of XLFDT functions
;IA #10104 - supported use of XLFSTR function
;
; The VPSPDO* procedures produce 2 separate displays of the PDO output
; which are the PATIENT ENTERED ALLERGY MEDICATION REVIEW and the PATIENT FACILITATED ALLERGY MEDICATION REVIEW
; which can be invoked by CPRS TIU components and as an RPC to be called by Vetlink staff-facing interface
; the GET procedure below determines which version of the PDO output to display
;
GET(PDO,VPSNUM,VPSTYP) ; RPC: VPS GET MRAR PDO
; INPUT
; PDO : the name of global array where each line of the MRAR output will be stored (e.g., "^TMP(""VPSPDO1"",$J)"
; VPSNUM : Parameter Value - patient SSN OR DFN OR ICN OR VIC/CAC (REQUIRED)
; VPSTYP : Parameter TYPE - SSN or DFN OR ICN OR VIC/CAC (REQUIRED)
; OUTPUT
; PDO : the name of global array where each line of the MRAR output will be stored
;
;Store Displayed MRAR data into global array PDO
S PDO=$NA(^TMP("VPSPDO1",$J))
K @PDO
S VPSNUM=$G(VPSNUM)
S VPSTYP=$G(VPSTYP)
N VPSDFN S VPSDFN=$$VALIDATE^VPSRPC1(VPSTYP,VPSNUM)
I VPSDFN<1 S @PDO@(1,0)=$P(VPSDFN,U,2)
I VPSDFN>0 D GETPDO(VPSDFN,PDO)
Q
;
TIU(PTIEN,PDOARY) ;TIU DOCUMENT: |VPS MRAR PDO|
; TIU OBJECT : S X=$$TIU^VPSPDO1(DFN,"^TMP(""VPSPDO1"",$J)")
;
; INPUT
; PTIEN : PATIENT DFN
; PDOARY : the name of global array where each line of the TIU will be stored
;
;Store Displayed MRAR data into global array where the name is assigned to PDOARY (eg: "^TMP(""VPSPDO1"",$J)")
D GETPDO(PTIEN,PDOARY)
Q "~@"_$NA(@PDOARY)
;
GETPDO(PTIEN,PDOARY) ;
; INPUT
; PTIEN : PATIENT DFN
; PDOARY : the name of global array where each line of the TIU will be stored
;
; -- create VPS pdo object
N PDOOREF S PDOOREF=$$NEW^VPSOBJ(PTIEN,PDOARY)
;
; -- initialize PDO object with date of Last Mrar and Staff flag
Q:'$$INITPDO(PDOOREF)
;
; -- Okay to Invoke PDO ?
Q:'$$OKINVK(PDOOREF)
;
; -- date/time stamp the PDO FIRST INVOKED or PDO INVOKED DT field
Q:'$$UPDINVK(PDOOREF,$$NOW^XLFDT())
;
; -- Generate PDO in temp global
D START(PDOOREF)
;
; -- clean up PDO object
D CLOSE^VPSOBJ(PDOOREF)
Q
;
INITPDO(OREF) ; initialize PDO object with date of LAST MRAR, STAFF flag
; INPUT
; OREF : Object Reference for the VPS PDO object
; RETURN
; 1 if successfull otherwise 0
;
; -- validate patient MRAR
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
I 'PTIEN D SETERR^VPSOBJ(OREF,"Invalid Patient IEN") Q 0
I '$D(^VPS(853.5,PTIEN)) D SETERR^VPSOBJ(OREF,"This patient has no MRAR data.") Q 0
;
N LASTMRAR S LASTMRAR=$O(^VPS(853.5,PTIEN,"MRAR","B",""),-1)
I 'LASTMRAR D SETERR^VPSOBJ(OREF,"This patient has no MRAR transaction.") Q 0
;
; -- set last mrar
D SETLSTMR^VPSOBJ(OREF,LASTMRAR)
;
; -- If field .13 (Interface module = "S" then data comes from staff-facing interfacing otherwise from patient-facing (kiosk))
N STAFF S STAFF=$S($$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",.13,"I")="S":1,1:0)
D SETSTAFF^VPSOBJ(OREF,STAFF)
;
Q (LASTMRAR>0)
;
OKINVK(OREF) ;Okay to Invoke PDO ?
; INPUT
; OREF : Object Reference for the VPS PDO object
; RETURN
; 1 if successfull otherwise 0
;
; -- get the PDO invocable period
N PERIOD S PERIOD=$$GETINVPR(OREF)
Q:'PERIOD 0
;
; -- how old is the last mrar
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
N TRNDT S TRNDT=$$DT^XLFDT() ; IA #10103
N AGE S AGE=$$FMDIFF^XLFDT(TRNDT,$P(LASTMRAR,"."),1)
;
; -- okay if the last mrar in the invocable period
Q 1
N OK S OK=(AGE'>PERIOD)
I 'OK D SETERR^VPSOBJ(OREF,"The last MRAR for this patient is too old. Last MRAR Date = "_$$FMTE^XLFDT(LASTMRAR,5)_". PDO Invocable Period = "_PERIOD)
Q OK
;
GETINVPR(OREF) ;get the PDO invocable period
; INPUT
; OREF : Object Reference for the VPS PDO object
; RETURN
; PDO invocable period if successfull otherwise 0
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
; -- Check make sure last mrar transaction contain either Kiosk Group or Clinic.
; These values will be used to retrieve the invocable period in file 853
N KIOSKGRP S KIOSKGRP=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",.03,"I")
N CLINIC S CLINIC=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",.04,"I")
N NOREQFLD S NOREQFLD=(KIOSKGRP="")&(CLINIC="")
I NOREQFLD D SETERR^VPSOBJ(OREF,"The last MRAR for this patient has undefined Kiosk Group and undefined Clinic. Either Kiosk Group or Clinic must exist")
Q:NOREQFLD 0
;
; -- Get invocable period based on Kiosk Group and/or CLinic
N KGPER,KGTRXDT S KGPER=$$GETPER("D",KIOSKGRP,.KGTRXDT)
N CLPER,CLTRXDT S CLPER=$$GETPER("C",CLINIC,.CLTRXDT)
;
; -- Get the period that was set last (most current)
N PERIOD S PERIOD=$S(KGTRXDT>CLTRXDT:KGPER,1:CLPER)
S:'PERIOD PERIOD=3 ; default is 3 days
Q PERIOD
;
GETPER(IDX,VAL,PRMTRXDT) ;Get invocable period based on Kiosk Group and/or CLinic
; INPUT
; IDX : Index name to get the IEN of Kiosk Group or Clinic in File 853
; VAL : either the Kiosk group or the Clinic IEN
; OUTPUT
; PRMTRXDT : The last transaction date in file 853 that contains Invocable period
; RETURN
; Invocable Period
;
S PRMTRXDT=0
N PERIOD S PERIOD=0
; KDC 10/31/2014
I IDX=""!(VAL="") Q PERIOD
N PRMIEN S PRMIEN=$O(^VPS(853,IDX,VAL,0))
Q:'PRMIEN PERIOD
;
S PRMTRXDT=99999999
F S PRMTRXDT=$O(^VPS(853,PRMIEN,"PARAM",PRMTRXDT),-1) Q:'PRMTRXDT D Q:PERIOD
. S PERIOD=$P($G(^VPS(853,PRMIEN,"PARAM",PRMTRXDT,1)),U)
S:PRMTRXDT=99999999 PRMTRXDT=0
Q PERIOD
;
UPDINVK(OREF,DTSTAMP) ;update the PDO FIRST INVOKED or PDO INVOKED DT field
; INPUT
; OREF : Object Reference for the VPS PDO object
; DTSTAMP : Date/Time Stamp the PDO FIRST INVOKED or PDO INVOKED DT field
; RETURN
; 1 if successfull otherwise 0
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
;
; -- Get First Invoked Date
N FINVKDT S FINVKDT=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",70,"I")
;
; -- if PDO FIRST INVOKED doesn't exist set it otherwise set the PDO NEXT INVOKED
N VPSFDA,VPSERR
I FINVKDT="" S VPSFDA(853.51,LASTMRAR_","_PTIEN_",",70)=DTSTAMP
I FINVKDT'="" S VPSFDA(853.51,LASTMRAR_","_PTIEN_",",73)=DTSTAMP
D FILE^DIE("","VPSFDA","VPSERR")
Q:'$D(VPSERR) 1
;
; -- filing error
N ERRNUM S ERRNUM=$O(VPSERR("DIERR",0))
D SETERR^VPSOBJ(OREF,VPSERR("DIERR",ERRNUM,"TEXT",1))
Q 0
;
START(OREF) ;allergy and medications section of the PDO output specifically for the PATIENT ENTERED ALLERGY MEDICATION REVIEW
; INPUT
; OREF : Object Reference for the VPS PDO object
;
; -- Header lines
N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
D HDR(OREF)
;
; -- Review conducted with lines
D:STAFF CNDWTH(OREF)
;
; -- Allergies section
D ADDCJ^VPSOBJ(OREF,"*** ALLERGIES *** ALLERGIES ***")
D ALRLOCAL(OREF) ; build local vista allergy
D ALRREMTE(OREF) ; build remote (cdw) allergy
D ADDALLER(OREF) ; build additional allergy
D GETCH^VPSPDO2(OREF) ; build allergy changes since last mrar
;
; -- MEDICATIONS Section
N MEDITMS ; array represents the list of medications - built by MEDS and used by MEDCHNG to display only the changes
D MEDHDR^VPSPDO1M(OREF) ; build medication header section
D MEDS^VPSPDO1M(OREF,.MEDITMS) ; build medication section
D ADDMEDS^VPSPDO3M(OREF) ; build additional medication section
D MEDCHNG^VPSPDO2M(OREF,.MEDITMS) ; build Medication Changes Since section
Q
;
HDR(OREF) ; produce TIU Note header lines
; INPUT
; OREF : Object Reference for the VPS PDO object
;
N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
N LMRARDT S LMRARDT=$$GETLSTMR^VPSOBJ(OREF)
I 'STAFF D ADDLJ^VPSOBJ(OREF,"Patient Entered Allergy Medication Review : "_$$FMTE^XLFDT(LMRARDT))
I STAFF D ADDLJ^VPSOBJ(OREF,"PATIENT FACILITATED ALLERGY MEDICATION REVIEW: "_$$FMTE^XLFDT(LMRARDT))
D ADDUNDLN^VPSOBJ(OREF)
Q
;
CNDWTH(OREF) ; produce Review conducted with lines
; INPUT
; OREF : Object Reference for the VPS PDO object
;
; join conducted with items into a string
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
;
N STRING S STRING=""
N CNDWTH S CNDWTH=0
;
F S CNDWTH=$O(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"MRARWITH",CNDWTH)) Q:'CNDWTH D
. S STRING=STRING_$$GET1^DIQ(853.5121,CNDWTH_","_LASTMRAR_","_PTIEN_",",.01,"E")_", "
S:STRING'="" STRING=$E(STRING,1,$L(STRING)-2)
;
; display conducted with line
D ADDLJ^VPSOBJ(OREF,"REVIEW CONDUCTED WITH: "_STRING)
D ADDUNDLN^VPSOBJ(OREF)
Q
;
ALRLOCAL(OREF) ;produce local allergy section
; INPUT
; OREF : Object Reference for the VPS PDO object
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
;
N BL F BL=1:1:2 D ADDBLANK^VPSOBJ(OREF)
N LOCAL S LOCAL=$D(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY","LOCAL"))
I LOCAL D
. D ADDLJ^VPSOBJ(OREF,"Allergy Response Key")
. D ADDLJ^VPSOBJ(OREF,"Y = Allergic")
. D ADDLJ^VPSOBJ(OREF,"N = Not Allergic")
. D ADDLJ^VPSOBJ(OREF,"? = Unsure")
. D ADDLJ^VPSOBJ(OREF,"X = No Response (incomplete session/no answer)")
. N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
. I STAFF D ADDLJ^VPSOBJ(OREF,">> indicates MARK FOR FOLLOW UP")
. D ADDBLANK^VPSOBJ(OREF)
. D ADDCJ^VPSOBJ(OREF,"Local Allergies")
. D BLD(OREF,"LOCAL")
I 'LOCAL D
. D ADDCJ^VPSOBJ(OREF,"Local Allergies")
. D ADDLJ^VPSOBJ(OREF,"Patient has NKDA at this VA.")
Q
;
ALRREMTE(OREF) ; produce remote allergies section
; INPUT
; OREF : Object Reference for the VPS PDO object
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
;
D ADDBLANK^VPSOBJ(OREF)
D ADDCJ^VPSOBJ(OREF,"Remote Allergies")
N REMOTE S REMOTE=$D(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY","REMOTE"))
I REMOTE D BLD(OREF,"REMOTE")
I 'REMOTE D
. D ADDLJ^VPSOBJ(OREF,"Patient has NKDA at any remote VA.")
. D ADDBLANK^VPSOBJ(OREF)
Q
;
ADDALLER(OREF) ; build additional allergies section
; INPUT
; OREF : Object Reference for the VPS PDO object
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
;
N ALLRADD S ALLRADD=$D(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGYADD"))
N REMOTE S REMOTE=$D(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY","REMOTE"))
N NKDA S NKDA=($$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",20,"I"))
N DONTKNOW S DONTKNOW=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN,19) ; patient could have also selected the structured response, "I don't know what my other allergies are".
D SETDKNW^VPSOBJ(OREF,DONTKNOW)
;
I ALLRADD D BLDADD^VPSPDO2(OREF) ; build additional allergies section
I STAFF,'ALLRADD,'REMOTE,NKDA D ADDLJ^VPSOBJ(OREF,"Patient has NKDA confirmed no additional allergies present.")
Q
;
BLD(OREF,TYPE) ; build local and remote allergy sections for Patient Entered allergy medication review note
; INPUT:
; OREF : Object Reference for the VPS PDO object
; TYPE : "LOCAL" or "REMOTE"
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
;
N HDR S HDR=0
N NOALLER S NOALLER=1
N ALRID,ALRIEN S (ALRID,ALRIEN)=0
;
F S ALRID=$O(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY",TYPE,ALRID)) Q:'ALRID F S ALRIEN=$O(^(ALRID,ALRIEN)) Q:'ALRIEN D
. ; initialze object with allergy name, patient response, station, mark for followup
. Q:'$$ALLRFLD(OREF,TYPE,ALRIEN) ; quit if allergy name is null (vecna needs to send a name)
. ;
. S NOALLER=0 ; indicate that there is allergy
. D BLDALR(OREF,ALRIEN,TYPE) ; build the allergy array to be used in CHANGES SINCE algorithm
. ;
. I 'HDR S HDR=1 D ADALHDR(OREF,TYPE) ; Add header for allergy items (do only once)
. D ADALFLDS(OREF,TYPE) ; add other allergy fields
;
I NOALLER D
. I TYPE="LOCAL" D ADDLJ^VPSOBJ(OREF,"Patient has NKDA at this VA.")
. I TYPE'="LOCAL" D ADDLJ^VPSOBJ(OREF,"Patient has NKDA at any remote VA.")
Q
;
ALLRFLD(OREF,TYPE,ALRIEN) ; Initialize allergy name, patient response, station, mark for followup
; INPUT
; OREF : Object Reference for the VPS PDO object
; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
; ALRIEN : Allergy IEN
;
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
;
; -- Initialize allergy name
N ALLRNM
I TYPE="LOCAL" D
. S ALLRNM=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.02,"I")
. S ALLRNM=$$GET1^DIQ(120.8,ALLRNM_",",.02,"E") ; LOCAL ALLERGY ID
I TYPE'="LOCAL" S ALLRNM=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.05) ; REMOTE ALLERGY NAME
Q:ALLRNM="" 0 ; quit if allergy name is null (vecna needs to send a name)
D SETALRNM^VPSOBJ(OREF,ALLRNM)
;
; -- Initialize Patient Response
N PATRESP S PATRESP=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.06,"I") ; PATIENT RESPONSE which could be "YES", "NO", "NOT SURE", "NO RESPONSE"
S PATRESP=$S(PATRESP="U":"?",1:PATRESP)
D SETPATRP^VPSOBJ(OREF,PATRESP)
;
; -- Initialize Station
N STATION S STATION=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.09,"E")
D SETSTATN^VPSOBJ(OREF,STATION)
;
; -- Initialize Mark for follow-up
N MARKFOL S MARKFOL=""
I STAFF S MARKFOL=$S($$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",16)]"":">>",1:"") ; mark for follow-up for patient facilitated output
D SETMKFOL^VPSOBJ(OREF,MARKFOL)
Q 1
;
BLDALR(OREF,ALRIEN,TYPE) ; build the allergy array to be used in CHANGES SINCE algorithm
; INPUT
; OREF : Object Reference for the VPS PDO object
; ALRIEN : Allergy IEN in File 853.52
; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
;
N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
N PTIEN S PTIEN=$$GETDFN^VPSOBJ(OREF)
N LASTMRAR S LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
N ALLRNM S ALLRNM=$$GETALRNM^VPSOBJ(OREF) ;Allergy Name must exist before calling this procedure, caller will validate
;
N ALLRITMS,REACT
S ALLRITMS(ALLRNM)=""
N REACTIEN S REACTIEN=0
;
F S REACTIEN=$O(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY",ALRIEN,"REACTIONS",REACTIEN)) Q:'REACTIEN D
. S REACT(REACTIEN)=$$GETREACT(TYPE,REACTIEN,ALRIEN,LASTMRAR,PTIEN)_" " ; get reaction name
. S ALLRITMS(ALLRNM,REACTIEN)=REACT(REACTIEN)
;
I $D(ALLRITMS(ALLRNM)) D ; pull reaction info for this allergy
. N COL D GETFORMT^VPSOBJ(OREF,.COL)
. N REACTLN D REACT^VPSPUTL1(STAFF,LASTMRAR,PTIEN,ALRIEN,.COL,.REACT,.REACTLN)
. M ALLRITMS(ALLRNM,"REACTLN")=REACTLN
. K REACTLN
;
D SETALLR^VPSOBJ(OREF,.ALLRITMS)
K ALLRITMS
Q
;
GETREACT(TYPE,REACTIEN,ALRIEN,LASTMRAR,PTIEN) ; get reaction name
; INPUT
; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
; REACTIEN : Allergy Reaction IEN in File 853.57
; ALRIEN : Allergy IEN in File 853.52
; LASTMRAR : Date of Last MRAR
; PTIEN : Patient DFN
;
N IENS S IENS=REACTIEN_","_ALRIEN_","_LASTMRAR_","_PTIEN_","
N REACTNM S REACTNM=""
I TYPE="LOCAL" S REACTNM=$$GET1^DIQ(853.57,IENS,.02,"E")
I TYPE'="LOCAL" S REACTNM=$$GET1^DIQ(853.57,IENS,.04)
Q REACTNM
;
ADALHDR(OREF,TYPE) ; Add header for allergy items (do only once)
; INPUT
; OREF : Object Reference for the VPS PDO object
; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
;
N COL D GETFORMT^VPSOBJ(OREF,.COL)
N VPSX S VPSX=""
S VPSX=$$SETFLD^VPSPUTL1("",VPSX,COL("PATRESP"))
S VPSX=$$SETFLD^VPSPUTL1("Name",VPSX,COL("ALLERNM"))
S VPSX=$$SETFLD^VPSPUTL1("Reaction",VPSX,COL("REACTION"))
I TYPE="REMOTE" S VPSX=$$SETFLD^VPSPUTL1("Site",VPSX,COL("SITE"))
D ADDPDO^VPSOBJ(OREF,VPSX)
Q
;
ADALFLDS(OREF,TYPE) ; add other allergy fields
; INPUT
; OREF : Object Reference for the VPS PDO object
; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
;
N STAFF S STAFF=$$GETSTAFF^VPSOBJ(OREF)
N ALRNM S ALRNM=$$GETALRNM^VPSOBJ(OREF)
N PATRESP S PATRESP=$$GETPATRP^VPSOBJ(OREF)
N STATION S STATION=$$GETSTATN^VPSOBJ(OREF)
N MARKFOL S MARKFOL=$$GETMKFOL^VPSOBJ(OREF)
N ALLR D GETALLR^VPSOBJ(OREF,.ALLR)
N REACTLN M REACTLN=ALLR(ALRNM,"REACTLN")
N COL D GETFORMT^VPSOBJ(OREF,.COL)
;
N VPSX S VPSX=""
I STAFF S VPSX=$$SETFLD^VPSPUTL1(MARKFOL,VPSX,COL("FOLLOWUP")) ; include MARK FOR FOLLOW-UP indicator only for staff-facing output
I STAFF S VPSX=$$SETFLD^VPSPUTL1(PATRESP,VPSX,COL("PATRESP")) ; include patient structured response in both remote and local allergy sections for staff-facing output
I 'STAFF,TYPE="LOCAL" S VPSX=$$SETFLD^VPSPUTL1(PATRESP,VPSX,COL("PATRESP")) ; only include patient structured response for local allergy section for patient-facing output
S VPSX=$$SETFLD^VPSPUTL1(ALRNM,VPSX,COL("ALLERNM"))
S VPSX=$$SETFLD^VPSPUTL1($G(REACTLN(1)),VPSX,COL("REACTION"))
I TYPE="REMOTE" S VPSX=$$SETFLD^VPSPUTL1(STATION,VPSX,COL("SITE"))
D ADDPDO^VPSOBJ(OREF,VPSX)
;
; -- Add rest of reaction list
N RSS S RSS=1
S VPSX=""
F S RSS=$O(REACTLN(RSS)) Q:'RSS D
. S VPSX=$$SETFLD^VPSPUTL1(REACTLN(RSS),VPSX,COL("REACTION"))
. D ADDPDO^VPSOBJ(OREF,VPSX)
;
D ADDBLANK^VPSOBJ(OREF) ; add a blank line between allergy sets
Q
;
; Health Summary entry point
HS ;
N TARGET,I
S TARGET="^TMP(""VPSPDO1"",$J)"
S I=$$TIU(DFN,TARGET)
S I=0
F S I=$O(@TARGET@(I)) Q:'I W !,@TARGET@(I,0)
W !!
S GMTSQIT=""
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVPSPDO1 17707 printed Nov 22, 2024@17:53:08 Page 2
VPSPDO1 ;DALOI/KML,WOIFO/BT - PDO OUTPUT DISPLAY - ALLERGIES ;11/20/11 15:30
+1 ;;1.0;VA POINT OF SERVICE (KIOSKS);**3**;Oct 21, 2011;Build 64
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;IA #10103 - supported use of XLFDT functions
+6 ;IA #10104 - supported use of XLFSTR function
+7 ;
+8 ; The VPSPDO* procedures produce 2 separate displays of the PDO output
+9 ; which are the PATIENT ENTERED ALLERGY MEDICATION REVIEW and the PATIENT FACILITATED ALLERGY MEDICATION REVIEW
+10 ; which can be invoked by CPRS TIU components and as an RPC to be called by Vetlink staff-facing interface
+11 ; the GET procedure below determines which version of the PDO output to display
+12 ;
GET(PDO,VPSNUM,VPSTYP) ; RPC: VPS GET MRAR PDO
+1 ; INPUT
+2 ; PDO : the name of global array where each line of the MRAR output will be stored (e.g., "^TMP(""VPSPDO1"",$J)"
+3 ; VPSNUM : Parameter Value - patient SSN OR DFN OR ICN OR VIC/CAC (REQUIRED)
+4 ; VPSTYP : Parameter TYPE - SSN or DFN OR ICN OR VIC/CAC (REQUIRED)
+5 ; OUTPUT
+6 ; PDO : the name of global array where each line of the MRAR output will be stored
+7 ;
+8 ;Store Displayed MRAR data into global array PDO
+9 SET PDO=$NAME(^TMP("VPSPDO1",$JOB))
+10 KILL @PDO
+11 SET VPSNUM=$GET(VPSNUM)
+12 SET VPSTYP=$GET(VPSTYP)
+13 NEW VPSDFN
SET VPSDFN=$$VALIDATE^VPSRPC1(VPSTYP,VPSNUM)
+14 IF VPSDFN<1
SET @PDO@(1,0)=$PIECE(VPSDFN,U,2)
+15 IF VPSDFN>0
DO GETPDO(VPSDFN,PDO)
+16 QUIT
+17 ;
TIU(PTIEN,PDOARY) ;TIU DOCUMENT: |VPS MRAR PDO|
+1 ; TIU OBJECT : S X=$$TIU^VPSPDO1(DFN,"^TMP(""VPSPDO1"",$J)")
+2 ;
+3 ; INPUT
+4 ; PTIEN : PATIENT DFN
+5 ; PDOARY : the name of global array where each line of the TIU will be stored
+6 ;
+7 ;Store Displayed MRAR data into global array where the name is assigned to PDOARY (eg: "^TMP(""VPSPDO1"",$J)")
+8 DO GETPDO(PTIEN,PDOARY)
+9 QUIT "~@"_$NAME(@PDOARY)
+10 ;
GETPDO(PTIEN,PDOARY) ;
+1 ; INPUT
+2 ; PTIEN : PATIENT DFN
+3 ; PDOARY : the name of global array where each line of the TIU will be stored
+4 ;
+5 ; -- create VPS pdo object
+6 NEW PDOOREF
SET PDOOREF=$$NEW^VPSOBJ(PTIEN,PDOARY)
+7 ;
+8 ; -- initialize PDO object with date of Last Mrar and Staff flag
+9 if '$$INITPDO(PDOOREF)
QUIT
+10 ;
+11 ; -- Okay to Invoke PDO ?
+12 if '$$OKINVK(PDOOREF)
QUIT
+13 ;
+14 ; -- date/time stamp the PDO FIRST INVOKED or PDO INVOKED DT field
+15 if '$$UPDINVK(PDOOREF,$$NOW^XLFDT())
QUIT
+16 ;
+17 ; -- Generate PDO in temp global
+18 DO START(PDOOREF)
+19 ;
+20 ; -- clean up PDO object
+21 DO CLOSE^VPSOBJ(PDOOREF)
+22 QUIT
+23 ;
INITPDO(OREF) ; initialize PDO object with date of LAST MRAR, STAFF flag
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; RETURN
+4 ; 1 if successfull otherwise 0
+5 ;
+6 ; -- validate patient MRAR
+7 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+8 IF 'PTIEN
DO SETERR^VPSOBJ(OREF,"Invalid Patient IEN")
QUIT 0
+9 IF '$DATA(^VPS(853.5,PTIEN))
DO SETERR^VPSOBJ(OREF,"This patient has no MRAR data.")
QUIT 0
+10 ;
+11 NEW LASTMRAR
SET LASTMRAR=$ORDER(^VPS(853.5,PTIEN,"MRAR","B",""),-1)
+12 IF 'LASTMRAR
DO SETERR^VPSOBJ(OREF,"This patient has no MRAR transaction.")
QUIT 0
+13 ;
+14 ; -- set last mrar
+15 DO SETLSTMR^VPSOBJ(OREF,LASTMRAR)
+16 ;
+17 ; -- If field .13 (Interface module = "S" then data comes from staff-facing interfacing otherwise from patient-facing (kiosk))
+18 NEW STAFF
SET STAFF=$SELECT($$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",.13,"I")="S":1,1:0)
+19 DO SETSTAFF^VPSOBJ(OREF,STAFF)
+20 ;
+21 QUIT (LASTMRAR>0)
+22 ;
OKINVK(OREF) ;Okay to Invoke PDO ?
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; RETURN
+4 ; 1 if successfull otherwise 0
+5 ;
+6 ; -- get the PDO invocable period
+7 NEW PERIOD
SET PERIOD=$$GETINVPR(OREF)
+8 if 'PERIOD
QUIT 0
+9 ;
+10 ; -- how old is the last mrar
+11 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+12 ; IA #10103
NEW TRNDT
SET TRNDT=$$DT^XLFDT()
+13 NEW AGE
SET AGE=$$FMDIFF^XLFDT(TRNDT,$PIECE(LASTMRAR,"."),1)
+14 ;
+15 ; -- okay if the last mrar in the invocable period
+16 QUIT 1
+17 NEW OK
SET OK=(AGE'>PERIOD)
+18 IF 'OK
DO SETERR^VPSOBJ(OREF,"The last MRAR for this patient is too old. Last MRAR Date = "_$$FMTE^XLFDT(LASTMRAR,5)_". PDO Invocable Period = "_PERIOD)
+19 QUIT OK
+20 ;
GETINVPR(OREF) ;get the PDO invocable period
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; RETURN
+4 ; PDO invocable period if successfull otherwise 0
+5 ;
+6 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+7 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+8 ; -- Check make sure last mrar transaction contain either Kiosk Group or Clinic.
+9 ; These values will be used to retrieve the invocable period in file 853
+10 NEW KIOSKGRP
SET KIOSKGRP=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",.03,"I")
+11 NEW CLINIC
SET CLINIC=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",.04,"I")
+12 NEW NOREQFLD
SET NOREQFLD=(KIOSKGRP="")&(CLINIC="")
+13 IF NOREQFLD
DO SETERR^VPSOBJ(OREF,"The last MRAR for this patient has undefined Kiosk Group and undefined Clinic. Either Kiosk Group or Clinic must exist")
+14 if NOREQFLD
QUIT 0
+15 ;
+16 ; -- Get invocable period based on Kiosk Group and/or CLinic
+17 NEW KGPER,KGTRXDT
SET KGPER=$$GETPER("D",KIOSKGRP,.KGTRXDT)
+18 NEW CLPER,CLTRXDT
SET CLPER=$$GETPER("C",CLINIC,.CLTRXDT)
+19 ;
+20 ; -- Get the period that was set last (most current)
+21 NEW PERIOD
SET PERIOD=$SELECT(KGTRXDT>CLTRXDT:KGPER,1:CLPER)
+22 ; default is 3 days
if 'PERIOD
SET PERIOD=3
+23 QUIT PERIOD
+24 ;
GETPER(IDX,VAL,PRMTRXDT) ;Get invocable period based on Kiosk Group and/or CLinic
+1 ; INPUT
+2 ; IDX : Index name to get the IEN of Kiosk Group or Clinic in File 853
+3 ; VAL : either the Kiosk group or the Clinic IEN
+4 ; OUTPUT
+5 ; PRMTRXDT : The last transaction date in file 853 that contains Invocable period
+6 ; RETURN
+7 ; Invocable Period
+8 ;
+9 SET PRMTRXDT=0
+10 NEW PERIOD
SET PERIOD=0
+11 ; KDC 10/31/2014
+12 IF IDX=""!(VAL="")
QUIT PERIOD
+13 NEW PRMIEN
SET PRMIEN=$ORDER(^VPS(853,IDX,VAL,0))
+14 if 'PRMIEN
QUIT PERIOD
+15 ;
+16 SET PRMTRXDT=99999999
+17 FOR
SET PRMTRXDT=$ORDER(^VPS(853,PRMIEN,"PARAM",PRMTRXDT),-1)
if 'PRMTRXDT
QUIT
Begin DoDot:1
+18 SET PERIOD=$PIECE($GET(^VPS(853,PRMIEN,"PARAM",PRMTRXDT,1)),U)
End DoDot:1
if PERIOD
QUIT
+19 if PRMTRXDT=99999999
SET PRMTRXDT=0
+20 QUIT PERIOD
+21 ;
UPDINVK(OREF,DTSTAMP) ;update the PDO FIRST INVOKED or PDO INVOKED DT field
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; DTSTAMP : Date/Time Stamp the PDO FIRST INVOKED or PDO INVOKED DT field
+4 ; RETURN
+5 ; 1 if successfull otherwise 0
+6 ;
+7 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+8 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+9 ;
+10 ; -- Get First Invoked Date
+11 NEW FINVKDT
SET FINVKDT=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",70,"I")
+12 ;
+13 ; -- if PDO FIRST INVOKED doesn't exist set it otherwise set the PDO NEXT INVOKED
+14 NEW VPSFDA,VPSERR
+15 IF FINVKDT=""
SET VPSFDA(853.51,LASTMRAR_","_PTIEN_",",70)=DTSTAMP
+16 IF FINVKDT'=""
SET VPSFDA(853.51,LASTMRAR_","_PTIEN_",",73)=DTSTAMP
+17 DO FILE^DIE("","VPSFDA","VPSERR")
+18 if '$DATA(VPSERR)
QUIT 1
+19 ;
+20 ; -- filing error
+21 NEW ERRNUM
SET ERRNUM=$ORDER(VPSERR("DIERR",0))
+22 DO SETERR^VPSOBJ(OREF,VPSERR("DIERR",ERRNUM,"TEXT",1))
+23 QUIT 0
+24 ;
START(OREF) ;allergy and medications section of the PDO output specifically for the PATIENT ENTERED ALLERGY MEDICATION REVIEW
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ;
+4 ; -- Header lines
+5 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+6 DO HDR(OREF)
+7 ;
+8 ; -- Review conducted with lines
+9 if STAFF
DO CNDWTH(OREF)
+10 ;
+11 ; -- Allergies section
+12 DO ADDCJ^VPSOBJ(OREF,"*** ALLERGIES *** ALLERGIES ***")
+13 ; build local vista allergy
DO ALRLOCAL(OREF)
+14 ; build remote (cdw) allergy
DO ALRREMTE(OREF)
+15 ; build additional allergy
DO ADDALLER(OREF)
+16 ; build allergy changes since last mrar
DO GETCH^VPSPDO2(OREF)
+17 ;
+18 ; -- MEDICATIONS Section
+19 ; array represents the list of medications - built by MEDS and used by MEDCHNG to display only the changes
NEW MEDITMS
+20 ; build medication header section
DO MEDHDR^VPSPDO1M(OREF)
+21 ; build medication section
DO MEDS^VPSPDO1M(OREF,.MEDITMS)
+22 ; build additional medication section
DO ADDMEDS^VPSPDO3M(OREF)
+23 ; build Medication Changes Since section
DO MEDCHNG^VPSPDO2M(OREF,.MEDITMS)
+24 QUIT
+25 ;
HDR(OREF) ; produce TIU Note header lines
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ;
+4 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+5 NEW LMRARDT
SET LMRARDT=$$GETLSTMR^VPSOBJ(OREF)
+6 IF 'STAFF
DO ADDLJ^VPSOBJ(OREF,"Patient Entered Allergy Medication Review : "_$$FMTE^XLFDT(LMRARDT))
+7 IF STAFF
DO ADDLJ^VPSOBJ(OREF,"PATIENT FACILITATED ALLERGY MEDICATION REVIEW: "_$$FMTE^XLFDT(LMRARDT))
+8 DO ADDUNDLN^VPSOBJ(OREF)
+9 QUIT
+10 ;
CNDWTH(OREF) ; produce Review conducted with lines
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ;
+4 ; join conducted with items into a string
+5 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+6 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+7 ;
+8 NEW STRING
SET STRING=""
+9 NEW CNDWTH
SET CNDWTH=0
+10 ;
+11 FOR
SET CNDWTH=$ORDER(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"MRARWITH",CNDWTH))
if 'CNDWTH
QUIT
Begin DoDot:1
+12 SET STRING=STRING_$$GET1^DIQ(853.5121,CNDWTH_","_LASTMRAR_","_PTIEN_",",.01,"E")_", "
End DoDot:1
+13 if STRING'=""
SET STRING=$EXTRACT(STRING,1,$LENGTH(STRING)-2)
+14 ;
+15 ; display conducted with line
+16 DO ADDLJ^VPSOBJ(OREF,"REVIEW CONDUCTED WITH: "_STRING)
+17 DO ADDUNDLN^VPSOBJ(OREF)
+18 QUIT
+19 ;
ALRLOCAL(OREF) ;produce local allergy section
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ;
+4 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+5 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+6 ;
+7 NEW BL
FOR BL=1:1:2
DO ADDBLANK^VPSOBJ(OREF)
+8 NEW LOCAL
SET LOCAL=$DATA(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY","LOCAL"))
+9 IF LOCAL
Begin DoDot:1
+10 DO ADDLJ^VPSOBJ(OREF,"Allergy Response Key")
+11 DO ADDLJ^VPSOBJ(OREF,"Y = Allergic")
+12 DO ADDLJ^VPSOBJ(OREF,"N = Not Allergic")
+13 DO ADDLJ^VPSOBJ(OREF,"? = Unsure")
+14 DO ADDLJ^VPSOBJ(OREF,"X = No Response (incomplete session/no answer)")
+15 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+16 IF STAFF
DO ADDLJ^VPSOBJ(OREF,">> indicates MARK FOR FOLLOW UP")
+17 DO ADDBLANK^VPSOBJ(OREF)
+18 DO ADDCJ^VPSOBJ(OREF,"Local Allergies")
+19 DO BLD(OREF,"LOCAL")
End DoDot:1
+20 IF 'LOCAL
Begin DoDot:1
+21 DO ADDCJ^VPSOBJ(OREF,"Local Allergies")
+22 DO ADDLJ^VPSOBJ(OREF,"Patient has NKDA at this VA.")
End DoDot:1
+23 QUIT
+24 ;
ALRREMTE(OREF) ; produce remote allergies section
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ;
+4 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+5 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+6 ;
+7 DO ADDBLANK^VPSOBJ(OREF)
+8 DO ADDCJ^VPSOBJ(OREF,"Remote Allergies")
+9 NEW REMOTE
SET REMOTE=$DATA(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY","REMOTE"))
+10 IF REMOTE
DO BLD(OREF,"REMOTE")
+11 IF 'REMOTE
Begin DoDot:1
+12 DO ADDLJ^VPSOBJ(OREF,"Patient has NKDA at any remote VA.")
+13 DO ADDBLANK^VPSOBJ(OREF)
End DoDot:1
+14 QUIT
+15 ;
ADDALLER(OREF) ; build additional allergies section
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ;
+4 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+5 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+6 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+7 ;
+8 NEW ALLRADD
SET ALLRADD=$DATA(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGYADD"))
+9 NEW REMOTE
SET REMOTE=$DATA(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY","REMOTE"))
+10 NEW NKDA
SET NKDA=($$GET1^DIQ(853.51,LASTMRAR_","_PTIEN_",",20,"I"))
+11 ; patient could have also selected the structured response, "I don't know what my other allergies are".
NEW DONTKNOW
SET DONTKNOW=$$GET1^DIQ(853.51,LASTMRAR_","_PTIEN,19)
+12 DO SETDKNW^VPSOBJ(OREF,DONTKNOW)
+13 ;
+14 ; build additional allergies section
IF ALLRADD
DO BLDADD^VPSPDO2(OREF)
+15 IF STAFF
IF 'ALLRADD
IF 'REMOTE
IF NKDA
DO ADDLJ^VPSOBJ(OREF,"Patient has NKDA confirmed no additional allergies present.")
+16 QUIT
+17 ;
BLD(OREF,TYPE) ; build local and remote allergy sections for Patient Entered allergy medication review note
+1 ; INPUT:
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; TYPE : "LOCAL" or "REMOTE"
+4 ;
+5 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+6 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+7 ;
+8 NEW HDR
SET HDR=0
+9 NEW NOALLER
SET NOALLER=1
+10 NEW ALRID,ALRIEN
SET (ALRID,ALRIEN)=0
+11 ;
+12 FOR
SET ALRID=$ORDER(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY",TYPE,ALRID))
if 'ALRID
QUIT
FOR
SET ALRIEN=$ORDER(^(ALRID,ALRIEN))
if 'ALRIEN
QUIT
Begin DoDot:1
+13 ; initialze object with allergy name, patient response, station, mark for followup
+14 ; quit if allergy name is null (vecna needs to send a name)
if '$$ALLRFLD(OREF,TYPE,ALRIEN)
QUIT
+15 ;
+16 ; indicate that there is allergy
SET NOALLER=0
+17 ; build the allergy array to be used in CHANGES SINCE algorithm
DO BLDALR(OREF,ALRIEN,TYPE)
+18 ;
+19 ; Add header for allergy items (do only once)
IF 'HDR
SET HDR=1
DO ADALHDR(OREF,TYPE)
+20 ; add other allergy fields
DO ADALFLDS(OREF,TYPE)
End DoDot:1
+21 ;
+22 IF NOALLER
Begin DoDot:1
+23 IF TYPE="LOCAL"
DO ADDLJ^VPSOBJ(OREF,"Patient has NKDA at this VA.")
+24 IF TYPE'="LOCAL"
DO ADDLJ^VPSOBJ(OREF,"Patient has NKDA at any remote VA.")
End DoDot:1
+25 QUIT
+26 ;
ALLRFLD(OREF,TYPE,ALRIEN) ; Initialize allergy name, patient response, station, mark for followup
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
+4 ; ALRIEN : Allergy IEN
+5 ;
+6 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+7 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+8 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+9 ;
+10 ; -- Initialize allergy name
+11 NEW ALLRNM
+12 IF TYPE="LOCAL"
Begin DoDot:1
+13 SET ALLRNM=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.02,"I")
+14 ; LOCAL ALLERGY ID
SET ALLRNM=$$GET1^DIQ(120.8,ALLRNM_",",.02,"E")
End DoDot:1
+15 ; REMOTE ALLERGY NAME
IF TYPE'="LOCAL"
SET ALLRNM=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.05)
+16 ; quit if allergy name is null (vecna needs to send a name)
if ALLRNM=""
QUIT 0
+17 DO SETALRNM^VPSOBJ(OREF,ALLRNM)
+18 ;
+19 ; -- Initialize Patient Response
+20 ; PATIENT RESPONSE which could be "YES", "NO", "NOT SURE", "NO RESPONSE"
NEW PATRESP
SET PATRESP=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.06,"I")
+21 SET PATRESP=$SELECT(PATRESP="U":"?",1:PATRESP)
+22 DO SETPATRP^VPSOBJ(OREF,PATRESP)
+23 ;
+24 ; -- Initialize Station
+25 NEW STATION
SET STATION=$$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",.09,"E")
+26 DO SETSTATN^VPSOBJ(OREF,STATION)
+27 ;
+28 ; -- Initialize Mark for follow-up
+29 NEW MARKFOL
SET MARKFOL=""
+30 ; mark for follow-up for patient facilitated output
IF STAFF
SET MARKFOL=$SELECT($$GET1^DIQ(853.52,ALRIEN_","_LASTMRAR_","_PTIEN_",",16)]"":">>",1:"")
+31 DO SETMKFOL^VPSOBJ(OREF,MARKFOL)
+32 QUIT 1
+33 ;
BLDALR(OREF,ALRIEN,TYPE) ; build the allergy array to be used in CHANGES SINCE algorithm
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; ALRIEN : Allergy IEN in File 853.52
+4 ; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
+5 ;
+6 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+7 NEW PTIEN
SET PTIEN=$$GETDFN^VPSOBJ(OREF)
+8 NEW LASTMRAR
SET LASTMRAR=$$GETLSTMR^VPSOBJ(OREF)
+9 ;Allergy Name must exist before calling this procedure, caller will validate
NEW ALLRNM
SET ALLRNM=$$GETALRNM^VPSOBJ(OREF)
+10 ;
+11 NEW ALLRITMS,REACT
+12 SET ALLRITMS(ALLRNM)=""
+13 NEW REACTIEN
SET REACTIEN=0
+14 ;
+15 FOR
SET REACTIEN=$ORDER(^VPS(853.5,PTIEN,"MRAR",LASTMRAR,"ALLERGY",ALRIEN,"REACTIONS",REACTIEN))
if 'REACTIEN
QUIT
Begin DoDot:1
+16 ; get reaction name
SET REACT(REACTIEN)=$$GETREACT(TYPE,REACTIEN,ALRIEN,LASTMRAR,PTIEN)_" "
+17 SET ALLRITMS(ALLRNM,REACTIEN)=REACT(REACTIEN)
End DoDot:1
+18 ;
+19 ; pull reaction info for this allergy
IF $DATA(ALLRITMS(ALLRNM))
Begin DoDot:1
+20 NEW COL
DO GETFORMT^VPSOBJ(OREF,.COL)
+21 NEW REACTLN
DO REACT^VPSPUTL1(STAFF,LASTMRAR,PTIEN,ALRIEN,.COL,.REACT,.REACTLN)
+22 MERGE ALLRITMS(ALLRNM,"REACTLN")=REACTLN
+23 KILL REACTLN
End DoDot:1
+24 ;
+25 DO SETALLR^VPSOBJ(OREF,.ALLRITMS)
+26 KILL ALLRITMS
+27 QUIT
+28 ;
GETREACT(TYPE,REACTIEN,ALRIEN,LASTMRAR,PTIEN) ; get reaction name
+1 ; INPUT
+2 ; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
+3 ; REACTIEN : Allergy Reaction IEN in File 853.57
+4 ; ALRIEN : Allergy IEN in File 853.52
+5 ; LASTMRAR : Date of Last MRAR
+6 ; PTIEN : Patient DFN
+7 ;
+8 NEW IENS
SET IENS=REACTIEN_","_ALRIEN_","_LASTMRAR_","_PTIEN_","
+9 NEW REACTNM
SET REACTNM=""
+10 IF TYPE="LOCAL"
SET REACTNM=$$GET1^DIQ(853.57,IENS,.02,"E")
+11 IF TYPE'="LOCAL"
SET REACTNM=$$GET1^DIQ(853.57,IENS,.04)
+12 QUIT REACTNM
+13 ;
ADALHDR(OREF,TYPE) ; Add header for allergy items (do only once)
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
+4 ;
+5 NEW COL
DO GETFORMT^VPSOBJ(OREF,.COL)
+6 NEW VPSX
SET VPSX=""
+7 SET VPSX=$$SETFLD^VPSPUTL1("",VPSX,COL("PATRESP"))
+8 SET VPSX=$$SETFLD^VPSPUTL1("Name",VPSX,COL("ALLERNM"))
+9 SET VPSX=$$SETFLD^VPSPUTL1("Reaction",VPSX,COL("REACTION"))
+10 IF TYPE="REMOTE"
SET VPSX=$$SETFLD^VPSPUTL1("Site",VPSX,COL("SITE"))
+11 DO ADDPDO^VPSOBJ(OREF,VPSX)
+12 QUIT
+13 ;
ADALFLDS(OREF,TYPE) ; add other allergy fields
+1 ; INPUT
+2 ; OREF : Object Reference for the VPS PDO object
+3 ; TYPE : Type of Allergy data(LOCAL VISTA /REMOTE - CDW)
+4 ;
+5 NEW STAFF
SET STAFF=$$GETSTAFF^VPSOBJ(OREF)
+6 NEW ALRNM
SET ALRNM=$$GETALRNM^VPSOBJ(OREF)
+7 NEW PATRESP
SET PATRESP=$$GETPATRP^VPSOBJ(OREF)
+8 NEW STATION
SET STATION=$$GETSTATN^VPSOBJ(OREF)
+9 NEW MARKFOL
SET MARKFOL=$$GETMKFOL^VPSOBJ(OREF)
+10 NEW ALLR
DO GETALLR^VPSOBJ(OREF,.ALLR)
+11 NEW REACTLN
MERGE REACTLN=ALLR(ALRNM,"REACTLN")
+12 NEW COL
DO GETFORMT^VPSOBJ(OREF,.COL)
+13 ;
+14 NEW VPSX
SET VPSX=""
+15 ; include MARK FOR FOLLOW-UP indicator only for staff-facing output
IF STAFF
SET VPSX=$$SETFLD^VPSPUTL1(MARKFOL,VPSX,COL("FOLLOWUP"))
+16 ; include patient structured response in both remote and local allergy sections for staff-facing output
IF STAFF
SET VPSX=$$SETFLD^VPSPUTL1(PATRESP,VPSX,COL("PATRESP"))
+17 ; only include patient structured response for local allergy section for patient-facing output
IF 'STAFF
IF TYPE="LOCAL"
SET VPSX=$$SETFLD^VPSPUTL1(PATRESP,VPSX,COL("PATRESP"))
+18 SET VPSX=$$SETFLD^VPSPUTL1(ALRNM,VPSX,COL("ALLERNM"))
+19 SET VPSX=$$SETFLD^VPSPUTL1($GET(REACTLN(1)),VPSX,COL("REACTION"))
+20 IF TYPE="REMOTE"
SET VPSX=$$SETFLD^VPSPUTL1(STATION,VPSX,COL("SITE"))
+21 DO ADDPDO^VPSOBJ(OREF,VPSX)
+22 ;
+23 ; -- Add rest of reaction list
+24 NEW RSS
SET RSS=1
+25 SET VPSX=""
+26 FOR
SET RSS=$ORDER(REACTLN(RSS))
if 'RSS
QUIT
Begin DoDot:1
+27 SET VPSX=$$SETFLD^VPSPUTL1(REACTLN(RSS),VPSX,COL("REACTION"))
+28 DO ADDPDO^VPSOBJ(OREF,VPSX)
End DoDot:1
+29 ;
+30 ; add a blank line between allergy sets
DO ADDBLANK^VPSOBJ(OREF)
+31 QUIT
+32 ;
+33 ; Health Summary entry point
HS ;
+1 NEW TARGET,I
+2 SET TARGET="^TMP(""VPSPDO1"",$J)"
+3 SET I=$$TIU(DFN,TARGET)
+4 SET I=0
+5 FOR
SET I=$ORDER(@TARGET@(I))
if 'I
QUIT
WRITE !,@TARGET@(I,0)
+6 WRITE !!
+7 SET GMTSQIT=""
+8 QUIT