VBECDCM ;hoifo/gjc-data mapping utilities.;Nov 21, 2002
;;2.0;VBEC;;Jun 05, 2015;Build 4
;
;Medical Device #:
;Note: The food and Drug Administration classifies this software as a
;medical device. As such, it may not be changed in any way.
;Modifications to this software may result in an adulterated medical
;device under 21CFR820, the use of which is considered to be a
;violation of US Federal Statutes. Acquiring and implementing this
;software through the Freedom of Information Act requires the
;implementer to assume total responsibility for the software, and
;become a registered manufacturer of a medical device, subject to FDA
;regulations.
;
;Call to $$NEWERR^%ZTER supported by IA: 1621
;Call to ^DIC supported by IA: 10006
;Call to MIX^DIC1 supported by IA: 10007
;Call to FILE^DIE supported by IA: 2053
;Execution of ^%ZOSF("TEST") supported by IA: 10096
;
EN613 ; entry point for mapping utilities on antibodies & antigens
D EN613^VBECDCM0 ;check for adds, edits, or deletes on the VistA side
S VBECFN=61.3 D GO Q
;
EN654 ; entry point for mapping utilities on transfusion reactions
D EN654^VBECDCM2 ;check for adds, edits, or deletes on the VistA side
S VBECFN=65.4 D GO Q
;
GO ; main entry point for mapping...
; VBECXIT is used to denote when the application is to be exited
; VBECFNM is the attribute name within the VistA file (blood product,
; antigen/antibody, transfusion reaction, & blood supplier)
;
; initialize error trap
I $$NEWERR^%ZTER N $ETRAP,$ESTACK S $ETRAP="D ERR^VBECDCU1"
E S X="D ERR^VBECDCU1",@^%ZOSF("TRAP")
;
S VBECXIT=0
S VBECFNM=$S(VBECFN=61.3:"Antigen/Antibody",VBECFN=65.4:"Transfusion Reaction",VBECFN=66:"Blood Product",66.01:"Blood Supplier",1:"")
;
; Lock the file that is being mapped to disallow another user the
; ability to add/edit/delete records in the file. If we cannot lock,
; we need to try again at a later date.
L +^VBEC(6005):5
I '$T D D XIT Q
.W !!,"The "_VBECFNM_" file is being edited by another user.",!,"Try again later."
.Q
;
; select the VistA element to map & the standardized value to map to
F D Q:VBECXIT
.S VBECVSTA=$$VSTLOOK(VBECFNM,VBECFN)
.I +VBECVSTA=-1 S VBECXIT=1 Q
.S VBECSQL=$$SQLLOOK(VBECFNM,VBECFN,VBECVSTA)
.I +VBECSQL=-1 S VBECXIT=1 Q
.; file pointer to standardized data (fld: .05)
.K VBECFDA
.S VBECFDA(8,6005,+VBECVSTA_",",.05)=+VBECSQL
.D FILE^DIE("","VBECFDA(8)","")
.; end of data filing
.Q
;*********************************************************************
;
XIT ; kill and quit
L -^VBEC(6005) K VBECFDA,VBECFN,VBECFNM,VBECSQL,VBECVSTA,VBECXIT,X,Y
Q
;
SQLLOOK(VBECFNM,VBECFN,VBECVSTA) ; Lookup on standardized blood products,
; transfusion reactions, blood suppliers, and antigens/antibodies.
;
; Input: VBECFNM=attribute to be mapped, i.e., transfusion reactions
; & antigens/antibodies.
; VBECFN=VistA file #; VistA file where the attribute resides
; VBECVSTA=ien^file#-ien^name attribute^identifier^
; antibody/antigen flag
;
; return: ien^attribute name^attribute key, -1 if lookup fails
;
N VBECSQL,VBECID,VBECVK,VBECVN
; VBECVK=antibody/antigen flag or null
; VBECVN=VistA name (.01)
; VBECID=for antibodies only, SNOMED code
S VBECVN=$P(VBECVSTA,U,3),VBECID=$P(VBECVSTA,U,4)
S VBECVK=$P(VBECVSTA,U,5)
;
F D Q:+VBECSQL
.S DIC="^VBEC(6007,",DIC("A")="Select a standardized "_VBECFNM_": "
.S DIC(0)="QEAMZ"
.S DIC("S")="I $D(^VBEC(6007,""FNUM"",VBECFN,+Y))#2" ; common to all
.;
.;additional logic for antibody/antigen screen
.S:VBECFN=61.3 DIC("S")=DIC("S")_" N VBECQ S VBECQ=$G(^VBEC(6007,+Y,0)) I $P(VBECQ,U,4)=VBECVK"
.;
.;display identifier when looking up antibody/antigen
.S:VBECFN=61.3 DIC("W")="N VBEC67 S VBEC67=$G(^VBEC(6007,+Y,0)) W $P(VBEC67,U,2)_$S($P(VBEC67,U,4)=""AB"":"" (Antibody)"",$P(VBEC67,U,2)=""AN"":"" (Antigen)"",1:"""")"
.;
.D ^DIC K DIC,VBECSCR
.I $D(DUOUT)!($D(DTOUT))!(+Y=-1) S VBECSQL=-1 Q
.; VBECSQL format: internal entry # ^ attribute name ^ attribute key
.S VBECSQL=+Y_U_$P(Y(0),U,1,2)
.Q
Q VBECSQL
;
VSTLOOK(VBECFNM,VBECFN) ; Lookup on standardized VistA blood products,
; transfusion reactions, blood suppliers, and antigens/antibodies.
;
; Input: VBECFNM=attribute to be mapped, i.e., blood products,
; transfusion reactions, blood suppliers, and
; antigens/antibodies.
; VBECFN=VistA file #; VistA file where the attribute resides
;
; return if antibody/antigen: ien ^ file#-ien ^ name attribute ^
; ^ identifier ^ antibody/antigen flag
; transfusion reaction: ien ^ file#-ien ^ name attribute ^
; null (no identifier) ^ (no flag)
;
; -1 if lookup fails
;
N VBECVSTA
F D Q:+VBECVSTA
.K D,DIC,DO S DIC(0)="QEFASZ" S:VBECFN=61.3 DIC(0)=DIC(0)_"X"
.S D="N^VA",DIC="^VBEC(6005,",DIC("A")="Select VistA "_VBECFNM_": "
.S:VBECFN=61.3 DIC("W")="N VBEC24 S VBEC24=$P($G(^VBEC(6005,+Y,0)),U,2,4) W $P(VBEC24,U,2)_$S($P(VBEC24,U,3)=""AB"":"" (Antibody)"",$P(VBEC24,U,3)=""AN"":"" (Antigen)"",1:"""")"
.;S:VBECFN=61.3 DIC("W")="N VBEC04 S VBEC04=$P($G(^VBEC(6005,+Y,0)),U,4) W $S(VBEC04=""AB"":""(Antibody)"",VBEC04=""AN"":""(Antigen)"",1:"""")"
.S DIC("S")="N VBEC05 S VBEC05=$G(^VBEC(6005,+Y,0)) I +VBEC05=VBECFN,$P(VBEC05,U,5)="""""
.D MIX^DIC1 K D,DIC,DO
.I $D(DUOUT)!($D(DTOUT))!(+Y=-1) S VBECVSTA=-1 Q
.S VBECVSTA=+Y_U_$P(Y(0),U,1,4)
.Q
Q VBECVSTA
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVBECDCM 5595 printed Nov 22, 2024@17:53:55 Page 2
VBECDCM ;hoifo/gjc-data mapping utilities.;Nov 21, 2002
+1 ;;2.0;VBEC;;Jun 05, 2015;Build 4
+2 ;
+3 ;Medical Device #:
+4 ;Note: The food and Drug Administration classifies this software as a
+5 ;medical device. As such, it may not be changed in any way.
+6 ;Modifications to this software may result in an adulterated medical
+7 ;device under 21CFR820, the use of which is considered to be a
+8 ;violation of US Federal Statutes. Acquiring and implementing this
+9 ;software through the Freedom of Information Act requires the
+10 ;implementer to assume total responsibility for the software, and
+11 ;become a registered manufacturer of a medical device, subject to FDA
+12 ;regulations.
+13 ;
+14 ;Call to $$NEWERR^%ZTER supported by IA: 1621
+15 ;Call to ^DIC supported by IA: 10006
+16 ;Call to MIX^DIC1 supported by IA: 10007
+17 ;Call to FILE^DIE supported by IA: 2053
+18 ;Execution of ^%ZOSF("TEST") supported by IA: 10096
+19 ;
EN613 ; entry point for mapping utilities on antibodies & antigens
+1 ;check for adds, edits, or deletes on the VistA side
DO EN613^VBECDCM0
+2 SET VBECFN=61.3
DO GO
QUIT
+3 ;
EN654 ; entry point for mapping utilities on transfusion reactions
+1 ;check for adds, edits, or deletes on the VistA side
DO EN654^VBECDCM2
+2 SET VBECFN=65.4
DO GO
QUIT
+3 ;
GO ; main entry point for mapping...
+1 ; VBECXIT is used to denote when the application is to be exited
+2 ; VBECFNM is the attribute name within the VistA file (blood product,
+3 ; antigen/antibody, transfusion reaction, & blood supplier)
+4 ;
+5 ; initialize error trap
+6 IF $$NEWERR^%ZTER
NEW $ETRAP,$ESTACK
SET $ETRAP="D ERR^VBECDCU1"
+7 IF '$TEST
SET X="D ERR^VBECDCU1"
SET @^%ZOSF("TRAP")
+8 ;
+9 SET VBECXIT=0
+10 SET VBECFNM=$SELECT(VBECFN=61.3:"Antigen/Antibody",VBECFN=65.4:"Transfusion Reaction",VBECFN=66:"Blood Product",66.01:"Blood Supplier",1:"")
+11 ;
+12 ; Lock the file that is being mapped to disallow another user the
+13 ; ability to add/edit/delete records in the file. If we cannot lock,
+14 ; we need to try again at a later date.
+15 LOCK +^VBEC(6005):5
+16 IF '$TEST
Begin DoDot:1
+17 WRITE !!,"The "_VBECFNM_" file is being edited by another user.",!,"Try again later."
+18 QUIT
End DoDot:1
DO XIT
QUIT
+19 ;
+20 ; select the VistA element to map & the standardized value to map to
+21 FOR
Begin DoDot:1
+22 SET VBECVSTA=$$VSTLOOK(VBECFNM,VBECFN)
+23 IF +VBECVSTA=-1
SET VBECXIT=1
QUIT
+24 SET VBECSQL=$$SQLLOOK(VBECFNM,VBECFN,VBECVSTA)
+25 IF +VBECSQL=-1
SET VBECXIT=1
QUIT
+26 ; file pointer to standardized data (fld: .05)
+27 KILL VBECFDA
+28 SET VBECFDA(8,6005,+VBECVSTA_",",.05)=+VBECSQL
+29 DO FILE^DIE("","VBECFDA(8)","")
+30 ; end of data filing
+31 QUIT
End DoDot:1
if VBECXIT
QUIT
+32 ;*********************************************************************
+33 ;
XIT ; kill and quit
+1 LOCK -^VBEC(6005)
KILL VBECFDA,VBECFN,VBECFNM,VBECSQL,VBECVSTA,VBECXIT,X,Y
+2 QUIT
+3 ;
SQLLOOK(VBECFNM,VBECFN,VBECVSTA) ; Lookup on standardized blood products,
+1 ; transfusion reactions, blood suppliers, and antigens/antibodies.
+2 ;
+3 ; Input: VBECFNM=attribute to be mapped, i.e., transfusion reactions
+4 ; & antigens/antibodies.
+5 ; VBECFN=VistA file #; VistA file where the attribute resides
+6 ; VBECVSTA=ien^file#-ien^name attribute^identifier^
+7 ; antibody/antigen flag
+8 ;
+9 ; return: ien^attribute name^attribute key, -1 if lookup fails
+10 ;
+11 NEW VBECSQL,VBECID,VBECVK,VBECVN
+12 ; VBECVK=antibody/antigen flag or null
+13 ; VBECVN=VistA name (.01)
+14 ; VBECID=for antibodies only, SNOMED code
+15 SET VBECVN=$PIECE(VBECVSTA,U,3)
SET VBECID=$PIECE(VBECVSTA,U,4)
+16 SET VBECVK=$PIECE(VBECVSTA,U,5)
+17 ;
+18 FOR
Begin DoDot:1
+19 SET DIC="^VBEC(6007,"
SET DIC("A")="Select a standardized "_VBECFNM_": "
+20 SET DIC(0)="QEAMZ"
+21 ; common to all
SET DIC("S")="I $D(^VBEC(6007,""FNUM"",VBECFN,+Y))#2"
+22 ;
+23 ;additional logic for antibody/antigen screen
+24 if VBECFN=61.3
SET DIC("S")=DIC("S")_" N VBECQ S VBECQ=$G(^VBEC(6007,+Y,0)) I $P(VBECQ,U,4)=VBECVK"
+25 ;
+26 ;display identifier when looking up antibody/antigen
+27 if VBECFN=61.3
SET DIC("W")="N VBEC67 S VBEC67=$G(^VBEC(6007,+Y,0)) W $P(VBEC67,U,2)_$S($P(VBEC67,U,4)=""AB"":"" (Antibody)"",$P(VBEC67,U,2)=""AN"":"" (Antigen)"",1:"""")"
+28 ;
+29 DO ^DIC
KILL DIC,VBECSCR
+30 IF $DATA(DUOUT)!($DATA(DTOUT))!(+Y=-1)
SET VBECSQL=-1
QUIT
+31 ; VBECSQL format: internal entry # ^ attribute name ^ attribute key
+32 SET VBECSQL=+Y_U_$PIECE(Y(0),U,1,2)
+33 QUIT
End DoDot:1
if +VBECSQL
QUIT
+34 QUIT VBECSQL
+35 ;
VSTLOOK(VBECFNM,VBECFN) ; Lookup on standardized VistA blood products,
+1 ; transfusion reactions, blood suppliers, and antigens/antibodies.
+2 ;
+3 ; Input: VBECFNM=attribute to be mapped, i.e., blood products,
+4 ; transfusion reactions, blood suppliers, and
+5 ; antigens/antibodies.
+6 ; VBECFN=VistA file #; VistA file where the attribute resides
+7 ;
+8 ; return if antibody/antigen: ien ^ file#-ien ^ name attribute ^
+9 ; ^ identifier ^ antibody/antigen flag
+10 ; transfusion reaction: ien ^ file#-ien ^ name attribute ^
+11 ; null (no identifier) ^ (no flag)
+12 ;
+13 ; -1 if lookup fails
+14 ;
+15 NEW VBECVSTA
+16 FOR
Begin DoDot:1
+17 KILL D,DIC,DO
SET DIC(0)="QEFASZ"
if VBECFN=61.3
SET DIC(0)=DIC(0)_"X"
+18 SET D="N^VA"
SET DIC="^VBEC(6005,"
SET DIC("A")="Select VistA "_VBECFNM_": "
+19 if VBECFN=61.3
SET DIC("W")="N VBEC24 S VBEC24=$P($G(^VBEC(6005,+Y,0)),U,2,4) W $P(VBEC24,U,2)_$S($P(VBEC24,U,3)=""AB"":"" (Antibody)"",$P(VBEC24,U,3)=""AN"":"" (Antigen)"",1:"""")"
+20 ;S:VBECFN=61.3 DIC("W")="N VBEC04 S VBEC04=$P($G(^VBEC(6005,+Y,0)),U,4) W $S(VBEC04=""AB"":""(Antibody)"",VBEC04=""AN"":""(Antigen)"",1:"""")"
+21 SET DIC("S")="N VBEC05 S VBEC05=$G(^VBEC(6005,+Y,0)) I +VBEC05=VBECFN,$P(VBEC05,U,5)="""""
+22 DO MIX^DIC1
KILL D,DIC,DO
+23 IF $DATA(DUOUT)!($DATA(DTOUT))!(+Y=-1)
SET VBECVSTA=-1
QUIT
+24 SET VBECVSTA=+Y_U_$PIECE(Y(0),U,1,4)
+25 QUIT
End DoDot:1
if +VBECVSTA
QUIT
+26 QUIT VBECVSTA
+27 ;