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

BIVISIT2.m

Go to the documentation of this file.
  1. BIVISIT2 ;IHS/CMI/MWR - DELETE VISITS; MAY 10, 2010
  1. ;;8.5;IMMUNIZATION;**5**;JUL 01,2013
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; CODE TO DELETE V FILE VISITS, TRIGGER EVENT FOR DELETE IMM.
  1. ;; PATCH 5: TRIGADD EP moved from rtn BIVISIT for Rsize. TRIGADD+0
  1. ;
  1. ;
  1. ;----------
  1. DELETE(BIDA,BIVTYPE,BIERR) ;EP
  1. ;---> Delete a V IMMUNIZATION File entry.
  1. ;---> Called exclusively by ^BIRPC3.
  1. ;---> Parameters:
  1. ; 1 - BIDA (req) IEN of V File entry to be deleted.
  1. ; 2 - BIVTYPE (req) "I"=Immunization Visit, "S"=Skin Text Visit.
  1. ; 3 - BIERR (ret) Text of Error Code if any, otherwise null.
  1. ;
  1. ;---> If DA not passed, set Error Code and quit.
  1. I '$G(BIDA) D ERRCD^BIUTL2(404,.BIERR) Q
  1. ;
  1. ;---> If BIVTYPE does not="I" (Immunization Visit) and it does
  1. ;---> not="S" (Skin Test Visit), then set Error Code and quit.
  1. I ($G(BIVTYPE)'="I")&($G(BIVTYPE)'="S") D Q
  1. .D ERRCD^BIUTL2(410,.BIERR)
  1. ;
  1. ;---> DIK kills D.
  1. N BIGBL,BIGBLK
  1. S BIGBLK=$S(BIVTYPE="I":"^AUPNVIMM(",1:"^AUPNVSK(")
  1. S BIGBL=BIGBLK_BIDA_",0)"
  1. ;
  1. ;---> If V File Visit doesn't exist, set Error and quit.
  1. I '$D(@BIGBL) D ERRCD^BIUTL2(411,.BIERR) Q
  1. ;
  1. ;---> Save VISIT pointer for this V File entry.
  1. N APCDVDLT S APCDVDLT=$P(@BIGBL,U,3)
  1. ;
  1. ;---> Store Immunization Visit data for Trigger Event in BIDATA.
  1. N BIDATA
  1. D:BIVTYPE="I" SAVEDATA(BIDA,.BIDATA)
  1. ;
  1. ;
  1. ;********** PATCH 5, v8.5, JUL 01,2013, IHS/CMI/MWR
  1. ;---> Switch to logical deletion of V Immunizations.
  1. ;---> Note: Edits are also stored and can be reviewed.
  1. ;
  1. D:BIVTYPE="I"
  1. .N BINODE S BINODE=@BIGBL
  1. .;---> Create an entry in BI PATIENT CONTRAINDICATION DELETED File.
  1. .N BIERR,BIIEN,BIFLD
  1. .S BIFLD(.01)=$P(BINODE,U,1)
  1. .S BIFLD(.02)=$P(BINODE,U,2)
  1. .S BIFLD(.03)=$P(BINODE,U,3)
  1. .S BIFLD(2.01)=+$G(DUZ)
  1. .D NOW^%DTC S BIFLD(2.02)=%
  1. .D UPDATE^BIFMAN(9002084.118,.BIIEN,.BIFLD,.BIERR)
  1. .;---> Quit if new entry failed.
  1. .I BIERR]"" S BIERR=BI31_BIERR Q
  1. .;---> Quit if new entry IEN bad.
  1. .I '$D(^BIVIMMD(+BIIEN(1),0)) D Q
  1. ..D ERRCD^BIUTL2(450,.BIERR) S BIERR=BI31_BIERR
  1. .;---> Now copy the rest of the Imm data.
  1. .S ^BIVIMMD(+BIIEN(1),0)=^AUPNVIMM(BIDA,0)
  1. .S:($D(^AUPNVIMM(BIDA,1))) ^BIVIMMD(+BIIEN(1),1)=^AUPNVIMM(BIDA,1)
  1. .S:($D(^AUPNVIMM(BIDA,12))) ^BIVIMMD(+BIIEN(1),12)=^AUPNVIMM(BIDA,12)
  1. ;
  1. Q:(BIERR]"")
  1. ;**********
  1. ;
  1. ;---> Delete the V File entry (and decrement the
  1. ;---> Dependent Entry Count of the parent Visit).
  1. N D,DA,DIK S DA=BIDA,DIK=BIGBLK
  1. D ^DIK
  1. ;
  1. ;---> If deletion of the V File Visit failed, set Error and quit.
  1. I $D(@BIGBL) D ERRCD^BIUTL2(428,.BIERR) Q
  1. ;
  1. ;---> If the DEPENDENT ENTRY COUNT for parent Visit is 0, then
  1. ;---> delete the Visit, too.
  1. S DLAYGO=9000010
  1. D:'$P(^AUPNVSIT(APCDVDLT,0),U,9) ^APCDVDLT
  1. ;
  1. ;---> Trigger Event, call Protocol: BI DELETE IMMUNIZATION.
  1. D:BIVTYPE="I" TRIGDEL($G(BIDATA))
  1. ;
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. SAVEDATA(BIDA,BIDATA) ;EP
  1. ;---> Save V Immunization data for Trigger Event, return in BIDATA.
  1. ;---> Parameters:
  1. ; 1 - BIDA (req) IEN of V IMMUNIZATION entry.
  1. ; 2 - BIDATA (ret) String of data returned.
  1. ;
  1. Q:'$G(BIDA)
  1. ;
  1. ;---> Specify Data Elements to collect.
  1. ;
  1. ;---> IEN PC DATA
  1. ;---> --- -- ----
  1. ;---> 4 2 = Vaccine Name, Short.
  1. ;---> 6 3 = Dose#.
  1. ;---> 25 4 = Vaccine Code, HL7.
  1. ;---> 30 5 = Vaccine IEN.
  1. ;---> 33 6 = Vaccine Lot Number (text).
  1. ;---> 34 7 = Location IEN.
  1. ;---> 35 8 = Category of Visit (A,E, or I)
  1. ;---> 36 9 = Location Other (text).
  1. ;---> 44 10 = Vaccine Reaction (text).
  1. ;---> 56 11 = Date of Immunization (Fileman format).
  1. ;---> 58 12 = Patient DFN.
  1. ;---> 59 13 = Visit, PCC Type (I,C,6).
  1. ;
  1. N BIDE,I
  1. F I=4,6,25,30,33,34,35,36,44,56,58,59 S BIDE(I)=""
  1. D GET^BIRPC1(.BIDATA,BIDA,"I",.BIDE)
  1. ;
  1. ;---> If an error is passed back, set BIDATA="".
  1. N BI31 S BI31=$C(31)_$C(31)
  1. I $P(BIDATA,BI31,2)]"" S BIDATA="" Q
  1. S BIDATA=$P(BIDATA,BI31)
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. TRIGDEL(BIDATA) ;EP
  1. ;---> Immunization Deleted Trigger Event call to Protocol File.
  1. ;---> V Immunization data of just deleted visit is saved in BIDATA.
  1. ;---> (Note: Trigger Event for ADD Immunization is in rtn BIVISIT.)
  1. ;---> Parameters:
  1. ; 1 - BIDATA (req) String of V Imm data.
  1. ;
  1. Q:$G(BIDATA)=""
  1. ;
  1. ;---> Local variables available when Delete Event is triggered:
  1. ;
  1. ; BICAT - Category: A (Ambul), I (Inpat), E (Event/Hist)
  1. ; BIDATE - Date of Visit (Fileman format).
  1. ; BIDFN - DFN of patient.
  1. ; BIDOSE - Dose# number for this Immunization.
  1. ; BILOC - Location of encounter (IEN).
  1. ; BILOT - Lot number for this Immunization (text).
  1. ; BIOLOC - Other Location of encounter (text).
  1. ; BIPTR - Vaccine (IEN in IMMUNIZATION File).
  1. ; BIREC - Vaccine Reaction (text).
  1. ; BITYPE - Type of Visit (PCC Master Control File I,C,6).
  1. ; BIVHL7 - Vaccine HL7 Code.
  1. ; BIVISD - Release/Revision Date of VIS (YYYMMDD).
  1. ; BIVNAM - Vaccine Name, short form.
  1. ;
  1. ;---> Parse out Immunization Visit data in local variables.
  1. N V S V="|"
  1. ;
  1. S BICAT=$P(BIDATA,V,8)
  1. S BIDATE=$P(BIDATA,V,11)
  1. S BIDFN=$P(BIDATA,V,12)
  1. S BIDOSE=$P(BIDATA,V,3)
  1. S BILOC=$P(BIDATA,V,7)
  1. S BILOT=$P(BIDATA,V,6)
  1. S BIOLOC=$P(BIDATA,V,9)
  1. S BIPTR=$P(BIDATA,V,5)
  1. S BIREC=$P(BIDATA,V,10)
  1. S BITYPE=$P(BIDATA,V,13)
  1. S BIVHL7=$P(BIDATA,V,4)
  1. S BIVNAM=$P(BIDATA,V,2)
  1. ;
  1. ;---> Local variables available when Event is triggered:
  1. ;---> Exclusive New of all variables except those to be available.
  1. N BISAVE
  1. S BISAVE="BICAT;BIDATE;BIDFN;BIDOSE;BILOC;BILOT;BIOLOC;BIPTR"
  1. S BISAVE=BISAVE_";BIREC;BITYPE;BIVHL7;BIVNAM;DIC;X;XQORS"
  1. ;
  1. D
  1. .S DIC=101,X="BI IMMUNIZATION DELETED"
  1. .D EN^XBNEW("EN^XQOR",BISAVE)
  1. ;
  1. Q
  1. ;
  1. ;
  1. ;********** PATCH 5, v8.5, JUL 01,2013, IHS/CMI/MWR
  1. ;---> TRIGADD EP moved from rtn BIVISIT for Rsize.
  1. ;----------
  1. TRIGADD ;EP
  1. ;---> Exclusively called from VFILE+216^BIVISIT.
  1. ;---> Immunization Added Trigger Event call to Protocol File.
  1. ;---> Called at the end/bottom of BIVISIT, after new V IMM created.
  1. ;---> (Note: Trigger Event for DELETE Immunization is in rtn BIVISIT2.)
  1. ;---> Local variables available when Event is triggered:
  1. ;
  1. ; BIADFN - IEN of V IMMUNIZATION just created.
  1. ; BICAT - Category: A (Ambul), I (Inpat), E (Event/Hist)
  1. ; BIDATE - Date of Visit (Fileman format).
  1. ; BIDFN - DFN of patient.
  1. ; BILOC - Location of encounter (IEN).
  1. ; BILOT - Lot Number IEN for this Immunization (text).
  1. ; BIOLOC - Other Location of encounter (text).
  1. ; BIPTR - Vaccine (IEN in IMMUNIZATION File).
  1. ; BIREC - Vaccine Reaction (text).
  1. ; BITYPE - Type of Visit (PCC Master Control File I,C,6).
  1. ; BIVHL7 - Vaccine HL7 Code.
  1. ; BIVNAM - Vaccine Name, short form.
  1. ; BIVSIT - IEN of Visit.
  1. ;
  1. ;
  1. N BIVNAM,BIVHL7,BISAVE
  1. S BIVNAM=$$VNAME^BIUTL2(BIPTR)
  1. S BIVHL7=$$CODE^BIUTL2(BIPTR,1)
  1. S BIREC=$$REACTXT^BIUTL6(BIREC)
  1. S BILOT=$$LOTTX^BIUTL6(BILOT)
  1. ;
  1. S BISAVE="BIADFN;BICAT;BIDATE;BIDFN;BILOC;BILOT;BIOLOC;BIPTR"
  1. S BISAVE=BISAVE_";BIREC;BITYPE;BIVHL7;BIVNAM;BIVSIT;DIC;X;XQORS"
  1. D
  1. .S DIC=101,X="BI IMMUNIZATION ADDED"
  1. .D EN^XBNEW("EN^XQOR",BISAVE)
  1. ;
  1. Q
  1. ;**********