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

BTIUVAMI.m

Go to the documentation of this file.
BTIUVAMI ; IHS/MSC/JS - AMI TOOL OBJECT ;28-Mar-2014 17:04;DU
 ;;1.0;TEXT INTEGRATION UTILITIES;**1012,1013**;MAR 20, 2013;Build 33
 ;
 Q
 ;
VAMI(DFN,TARGET,VIEN) ; EHR p12
 ;
 ; -- check environment variables --
 I $T(GETVAR^CIAVMEVT)="" S @TARGET@(1,0)="Invalid context variables" Q "~@"_$NA(@TARGET)
 I $G(TARGET)="" Q " "
 K @TARGET
 ; -- get patient visit --
 S VIEN=$G(VIEN)
 I VIEN'="" G GETAMI
 NEW VST
 S VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
 I VST="" S @TARGET@(1,0)="Invalid visit" Q "~@"_$NA(@TARGET)
 S VIEN=+$$VSTR2VIS^BEHOENCX(DFN,VST) I VST<1 S @TARGET@(1,0)="Invalid context variables" Q "~@"_$NA(@TARGET)
 I $G(VIEN)="" S @TARGET@(1,0)="Invalid visit" Q "~@"_$NA(@TARGET)
 ;
GETAMI ; -- check/get V AMI file #9000010.62 visit entry --
 NEW AMIEN,CNT,FNUM,VAMIARR,VAMIERR
 S AMIEN=""
 S CNT=0
 F  S AMIEN=$O(^AUPNVAMI("AD",VIEN,AMIEN)) Q:AMIEN=""  D
 .D GETS
 I 'CNT S @TARGET@(1,0)="No AMI data found for this visit"
 Q "~@"_$NA(@TARGET)
 ;
GETS ; -- check/retrieve file entry(s) --
 I AMIEN="" S @TARGET@(1,0)="No V AMI entry for patient visit" Q "~@"_$NA(@TARGET)
 I '$D(^AUPNVAMI(AMIEN)) S @TARGET@(1,0)="No V AMI entry for patient visit" Q "~@"_$NA(@TARGET)
 I $P($G(^AUPNVAMI(AMIEN,5)),U,1) Q  ; EIE
 S FNUM=$$FNUM
 I FNUM=0 S @TARGET@(1,0)="Server error: "_$G(FILERR("DIERR",1))_U_$G(FILERR("DIERR",1,"TEXT",1)) K FILERR Q "~@"_$NA(@TARGET)
 D GETS^DIQ(FNUM,AMIEN_",","**","IE","VAMIARR","VAMIERR") ;  retrieve file entry data
 I $D(VAMIERR) D   Q "~@"_$NA(@TARGET)
 .S @TARGET@(1,0)="Server error occurred: "_$G(VAMIERR("DIERR",1))_U_$G(VAMIERR("DIERR",1,"TEXT",1))
 D PRINT(AMIEN)
 I CNT=0 S @TARGET@(1,0)="No V AMI visit record"
 Q
 ;
 ; -- print/display the AMI TOOL entry data --
PRINT(AMIEN) ;
 NEW SPACE,ARRIVED,PATNAME,ONSETDT,PROVNAME,ONSETBY,ARRCOM,FIBCOM,EKGCOM,FINDCOM
 N FIBBY,SYMCOM,EKGDONE,STRPAD,Z
 S $P(SPACE," ",1)=""
 S $P(STRPAD," ",3)=""
 S ARRIVED=$G(VAMIARR(FNUM,AMIEN_",",".01","E")) ;.01       ARRIVAL DATE/TIME (RD), [0;1]
 S PATNAME=$G(VAMIARR(FNUM,AMIEN_",",".02","E")) ;.02       PATIENT NAME (RP9000001'I), [0;2]
 S ONSETDT=$G(VAMIARR(FNUM,AMIEN_",",".04","E")) ;.04       ONSET SYMPTOMS (D), [0;4]
 S ONSETBY=$G(VAMIARR(FNUM,AMIEN_",",".06","E")) ;.06       ONSET SYMPTOMS BY (P200'), [0;6]
 S EKGDONE=$G(VAMIARR(FNUM,AMIEN_",",".07","E")) ;.07       EKG DONE (DATE/TIME), [0;7]
 S PROVNAME=$G(VAMIARR(FNUM,AMIEN_",","1202","E")) ;1202    ORDERING PROVIDER (*P200'X), [12;2]
 S CNT=CNT+1
 S @TARGET@(CNT,0)="---  Chest Pain  ---"
 S CNT=CNT+1
 S @TARGET@(CNT,0)=SPACE
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Arrived at:          "_$G(ARRIVED)
 ;SYMPTOMS #9000010.622 - ONSET SYMPTOMS TEXT SUB-FILE FIELD #2.01
 NEW NODE,STRING,SSY
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Onset of symptoms:   "_$G(ONSETDT)
 S CNT=CNT+1
 S @TARGET@(CNT,0)="Onset of symptoms entered by: "_$G(ONSETBY)
 S CNT=CNT+1
 S @TARGET@(CNT,0)=SPACE
 S CNT=CNT+1
 I $D(^AUPNVAMI(AMIEN,15))>1 S @TARGET@(CNT,0)="Symptoms:"
 S STRING="",NODE=0
 S NODE=0 F  S NODE=$O(^AUPNVAMI(AMIEN,15,NODE)) Q:'+NODE  D
 .S SSY=NODE_","_AMIEN
 .S STRING=$$GET1^DIQ(9000010.6215,SSY,.019)
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=STRPAD_STRING
 .Q
 ;I $D(VAMIARR(FNUM,AMIEN_",","2")) D  ;  2        ONSET SYMPTOMS TEXT
 I $D(^AUPNVAMI(AMIEN,2))>1 D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="Onset Symptoms Comments:"
 .N NUM S NUM=""
 .F  S NUM=$O(VAMIARR(FNUM,AMIEN_",","2",NUM)) Q:NUM=""  D
 ..Q:NUM'?1N.N
 ..S SYMCOM=$G(VAMIARR(FNUM,AMIEN_",","2",NUM))
 ..I $G(SYMCOM)]"" D
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)=SYMCOM
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 I $G(EKGDONE)]"" D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="EKG done (Date/Time):   "_$G(EKGDONE)
 ;
 ;EKG #9000010.6214 - EKG FINDINGS SUB-FILE FIELD #1400
 NEW NODE,STRING,NARR,EIEN
 S STRING="",NODE=""
 S NODE=0 F  S NODE=$O(^AUPNVAMI(AMIEN,14,NODE)) Q:'+NODE  D
 .S EIEN=NODE_","_AMIEN
 .S STRING=$$GET1^DIQ(9000010.6214,EIEN,.07) ;               .07  EVENT DATE/TIME (D), [0;7]
 .I $G(STRING)]"" D
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)="EKG Findings Date/Time: "_$G(STRING)
 .S STRING=$$GET1^DIQ(9000010.6214,EIEN,.02) ;               .01  EKG FINDINGS CONCEPT ID (F), [0;1]
 .S NARR=$$GET1^DIQ(9000010.6214,EIEN,.03)
 .I NARR="" S NARR=$P($$DESC^BSTSAPI(STRING_"^^1"),U,2)
 .I NARR'="" S NARR=NARR_" ("_STRING_")" D
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)="Interpretation:"
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)=$G(NARR)
 .S STRING=$$GET1^DIQ(9000010.6214,EIEN,.06) ;               .06  INTERPRETED BY (P200'), [0;6]
 .I $G(STRING)]"" D
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)="Interpreted by: "_$G(STRING)
 .S Z=0 F  S Z=$O(^AUPNVAMI(AMIEN,14,NODE,1,Z)) Q:'+Z  D
 ..S STRING=$G(^AUPNVAMI(AMIEN,14,NODE,1,Z,0))
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)=STRING
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 .Q
 I $D(VAMIARR(FNUM,AMIEN_",","3")) I $G(VAMIARR(FNUM,AMIEN_",","3",1))]"" D  ; 3    EKG COMMENT
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="EKG Comments:"
 .N NUM S NUM=""
 .F  S NUM=$O(VAMIARR(FNUM,AMIEN_",","3",NUM)) Q:NUM=""  D
 ..Q:NUM'?1N.N
 ..S EKGCOM=$G(VAMIARR(FNUM,AMIEN_",","3",NUM))
 ..I $G(EKGCOM)]"" D
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)=EKGCOM
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 ;PROTOCOLS #9000010.6213 - PROTOCOL STANDING ORDERS SUB-FILE FIELD #1300
 I $D(VAMIARR(9000010.6213)) D
 .NEW STRING,NODE,PROTO,PROTODT,PROTOBY,PROCOM
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="Standing Orders/Protocols Initiated:"
 .S STRING="",NODE=""
 .F  S NODE=$O(VAMIARR(9000010.6213,NODE)) Q:NODE=""  D
 ..S CNT=CNT+1
 ..S PROTO=$G(VAMIARR(9000010.6213,NODE,".01","E")) ;                 .01  PROTOCOL STANDING ORDERS (F), [0;1]
 ..S PROTODT=$G(VAMIARR(9000010.6213,NODE,".02","E")) ;               .02  EVENT DATE/TIME (D), [0;2]
 ..S PROTOBY=$G(VAMIARR(9000010.6213,NODE,".04","E")) ;               .04  ENTERED BY (P200'), [0;4]
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)=$G(PROTO)_"  "_$G(PROTODT)_" by "_$G(PROTOBY)
 ..I $D(VAMIARR(9000010.6213,NODE,1)) D  ; 1                           STANDING ORDER COMMENT
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)="Standing Order Comments:"
 ...N NUM S NUM=0
 ...F  S NUM=$O(VAMIARR(9000010.6213,NODE,NUM)) Q:NUM=""  D
 ....Q:NUM'?1N.N
 ....N PNUM S PNUM=0
 ....F  S PNUM=$O(VAMIARR(9000010.6213,NODE,NUM,PNUM)) Q:PNUM=""  D
 .....Q:PNUM'?1N.N
 .....S PROCOM=$G(VAMIARR(9000010.6213,NODE,NUM,PNUM)) Q:$G(PROCOM)=""  D
 ......S CNT=CNT+1
 ......S @TARGET@(CNT,0)=PROCOM
 ;FIBRINOLYTIC THERAPY INITIATED  FIELD .11
 NEW FIBSTDT,FIBNOT,FIBREA,FIBCOM,FIBTXT
 S FIBSTDT=$G(VAMIARR(FNUM,AMIEN_",",".11","E")) ;                   .11 FIBRINOLYTIC THERAPY INITIATED (D), [0;11]
 S FIBBY=$G(VAMIARR(FNUM,AMIEN_",",".13","E"))
 I FIBSTDT="" D
 .S FIBNOT=$G(VAMIARR(FNUM,AMIEN_",",".14","E")) ;                   .14 DID NOT DO
 .I FIBNOT'="" D
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)=SPACE
 ..S CNT=CNT+1
 ..S @TARGET@(CNT,0)="Fibrinolytic therapy Not chosen at "_FIBNOT
 ..S FIBREA=$G(VAMIARR(FNUM,AMIEN_",",".17","I")) ;                  .17 NO FIB REASON (REF REASON FILE IEN STORED 12.6.13)
 ..I $L(FIBREA)<4 S FIBTXT=FIBREA
 ..E  S FIBTXT=$P($$CONC^BSTSAPI(FIBREA),U,4)
 ..I FIBTXT]"" D
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)="Reason: "_FIBTXT
 E  D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="Fibrinolytic therapy started at "_FIBSTDT
 I FIBBY'="" D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="Fibrinolytic documented by "_FIBBY
 S FIBCOM=$G(VAMIARR(FNUM,AMIEN_",","4","E"))
 I $G(FIBCOM)]"" D
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 I $D(VAMIARR(FNUM,AMIEN_",","4")) I $G(VAMIARR(FNUM,AMIEN_",","4",1))]"" D  ; 4   FIBRINOLYTIC THERAPY COMMENT
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)="Fibrinolytic Therapy Comments:"
 .N NUM S NUM=""
 .F  S NUM=$O(VAMIARR(FNUM,AMIEN_",","4",NUM)) Q:NUM=""  D
 ..Q:NUM'?1N.N
 ..S FIBCOM=$G(VAMIARR(FNUM,AMIEN_",","4",NUM))
 ..I $G(FIBCOM)]"" D
 ...S CNT=CNT+1
 ...S @TARGET@(CNT,0)=FIBCOM
 .S CNT=CNT+1
 .S @TARGET@(CNT,0)=SPACE
 Q
 ;
 ; -- V AMI file number --
FNUM() ; returns 0/invalid file ref number, 9000010.62/valid file ref number
 NEW FILEN,ATTRIB,TAROOT,MSGROOT,FILEINFO
 S FILEN=9000010.62,ATTRIB="NAME;GLOBAL NAME",TAROOT="FILEINFO",MSGROOT="FILERR"
 K FILERR D FILE^DID(FILEN,,ATTRIB,TAROOT,MSGROOT)
 I $D(FILERR) Q 0
 Q 9000010.62