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

PXAPIDEL.m

Go to the documentation of this file.
  1. PXAPIDEL ;ISL/dee - PCE's code for the DELVFILE api ;11/4/96
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**1,9,22**;Aug 12, 1996
  1. Q
  1. ;
  1. DELVFILE(PXAWHICH,PXAVISIT,PXAPKG,PXASOURC,PXAASK,PXAECHO,PXAUSER) ;Deletes the requesed data related to the visit.
  1. ; PXAWHICH is a ^ delimited string with the last two or three letters
  1. ; of the v-files to delete entries from and VISIT for the
  1. ; administative data on the visit and STOP for the stop codes.
  1. ; (e.g. for immunization the v-file is AUPNVIMM so IMM is
  1. ; passed.) Or "ALL" to delete all of the data form the
  1. ; V-Files, the Stop Code and Visit.
  1. ; PXAVISIT is pointer to a visit for which the related data is be
  1. ; deleted.
  1. ; PACKAGE (optional) if passed will only delete items created by
  1. ; this package
  1. ; SOURCE (optional) if passed will only delete items created by
  1. ; this source
  1. ; PXAASK (optional) if passed and not 0 or "" then will ask the user
  1. ; if they are sure that they want to delete
  1. ; (suggest 1 if want to ask).
  1. ; PXAECHO (optional) if passed and not 0 or "" then will display to
  1. ; the user what is being deleted (suggest 1 if want to echo).
  1. ; PXAUSER (optional) this is the duz of a user if you only want to
  1. ; delete entries that this user created. If it is not passed
  1. ; or is 0 or "" then it will not matter who created the
  1. ; entries being deleted.
  1. ;
  1. ; Returns:
  1. ; 1 if no errors and process completely
  1. ; 0 if errors occurred
  1. ; or try to delete something that was now allowed to delete
  1. ; but deletion processed completely as possible
  1. ; -1 if user said not to delete or user up arrows out
  1. ; or errors out. In any case nothing was delete.
  1. ; -2 if could not get a visit
  1. ; -3 if called incorrectly
  1. ; -4 if dependent entry count is still greater than zer0
  1. ;
  1. ;Good visit?
  1. Q:'$G(PXAVISIT) -2
  1. Q:'($D(^AUPNVSIT(PXAVISIT,0))#2) -2
  1. ;
  1. ;Get package pointer
  1. S PACKAGE=$G(PACKAGE)
  1. I PACKAGE="" S PXAPKG=0
  1. E I PACKAGE=+PACKAGE S PXAPKG=PACKAGE
  1. E S PXAPKG=$$PKG2IEN^VSIT(PACKAGE) I PXAPKG=-1 W:'$D(ZTQUEUED) !,"Procedure ""DELVFILE^PXAPI"" was called incorrectly without a valid ""PACKAGE"", contact IRM." Q -3
  1. I PXAPKG>0,'($D(^DIC(9.4,PXAPKG,0))#2) W:'$D(ZTQUEUED) !,"Procedure ""DELVFILE^PXAPI"" was called incorrectly without a valid ""PACKAGE"", contact IRM." Q -3
  1. ;
  1. ;Lookup source in PCE DATA SOURCE file (#839.7) with LAYGO
  1. S SOURCE=$G(SOURCE)
  1. I SOURCE="" S PXASOURC=0
  1. E I SOURCE=+SOURCE S PXASOURC=SOURCE
  1. E S PXASOURC=$$SOURCE^PXAPIUTL(SOURCE)
  1. I +PXASOURC=-1 W:'$D(ZTQUEUED) !,"Procedure ""DELVFILE^PXAPI"" was called incorrectly without a valid ""SOURCE"", contact IRM." Q -3
  1. ;
  1. K ^TMP("PXK",$J)
  1. N PXACOUNT,PXAINDX,PXAVFILE,PXAFILE,PXARET,PXAWFLAG
  1. N PXALEN,PXAIEN,PXAPIECE,PXAMYSOR
  1. S PXARET=1
  1. I PXAWHICH="ALL" S PXAWHICH="VISIT^STOP^CPT^IMM^PED^POV^PRV^SK^TRT^HF^XAM"
  1. S PXALEN=$L(PXAWHICH,"^")
  1. Q:PXALEN<1 -3
  1. E F PXACOUNT=1:1:PXALEN S PXAVFILE=$P(PXAWHICH,"^",PXACOUNT) D Q:PXARET<0
  1. . I "~VISIT~STOP~CPT~IMM~PED~POV~PRV~SK~TRT~HF~XAM~"'[("~"_PXAVFILE_"~") S PXARET=-3
  1. Q:PXARET<0 PXARET
  1. I PXAASK D Q:PXARET<0 PXARET
  1. . N DIR,X,Y
  1. . ;ask the user if they want to delete
  1. . S DIR(0)="Y"
  1. . S DIR("A")="Are you sure you want to delete the encounter information"
  1. . S DIR("B")="NO"
  1. . D ^DIR
  1. . I Y'=1 S PXARET=-1 Q
  1. S PXAMYSOR=$$SOURCE^PXAPIUTL("PCE DELETE V-FILES API")
  1. ;Do Stop Codes first
  1. S PXAWFLAG=PXAECHO&'$D(ZTQUEUED)
  1. I "^"_PXAWHICH_"^"["^STOP^" D
  1. . S PXAIEN=0
  1. . F PXACOUNT=0:1 S PXAIEN=$O(^AUPNVSIT("AD",PXAVISIT,PXAIEN)) Q:'PXAIEN D
  1. .. I PXAUSER>0,PXAUSER'=$P(^AUPNVSIT(PXAIEN,0),"^",23) Q
  1. .. I PXAWFLAG S PXAWFLAG=0 W !," ...deleting Stop Codes"
  1. .. I $$STOPCODE^PXUTLSTP(PXAMYSOR,"@",PXAVISIT,PXAIEN)
  1. ;Set up the visit
  1. S ^TMP("PXK",$J,"PKG")=PXAPKG
  1. S ^TMP("PXK",$J,"SOR")=PXAMYSOR
  1. S ^TMP("PXK",$J,"VST",1,"IEN")=PXAVISIT
  1. F PXAPIECE=0,21,150,800,811 D
  1. . S (^TMP("PXK",$J,"VST",1,PXAPIECE,"BEFORE"),^TMP("PXK",$J,"VST",1,PXAPIECE,"AFTER"))=$G(^AUPNVSIT(PXAVISIT,PXAPIECE))
  1. ;
  1. F PXACOUNT=1:1:PXALEN S PXAVFILE=$P(PXAWHICH,"^",PXACOUNT) D
  1. . I PXAVFILE="VISIT" D
  1. .. ;set fields to @
  1. .. S $P(^TMP("PXK",$J,"VST",1,0,"AFTER"),"^",18)="@"
  1. .. F INDEX=1:1:4 S:$P(^TMP("PXK",$J,"VST",1,800,"AFTER"),"^",INDEX)]"" $P(^TMP("PXK",$J,"VST",1,800,"AFTER"),"^",INDEX)="@"
  1. . E I PXAVFILE="STOP" ;skip already done
  1. . E D ;the v-files
  1. .. S PXAWFLAG=PXAECHO&'$D(ZTQUEUED)
  1. .. S PXAFILE=$P($T(FORMAT^@("PXCE"_$S(PXAVFILE="IMM":"VIMM",1:PXAVFILE))),"~",5)
  1. .. S PXAIEN=0
  1. .. F PXAINDX=1:1 S PXAIEN=$O(@(PXAFILE_"(""AD"",PXAVISIT,PXAIEN)")) Q:'PXAIEN D
  1. ... I $P($G(@(PXAFILE_"(PXAIEN,812)")),"^",1) S PXARET=0 Q
  1. ... I PXAUSER>0,PXAUSER'=$P($P($P($G(@(PXAFILE_"(PXAIEN,801)")),"^",2),";",1)," ",2) Q
  1. ... I PXAPKG>0,PXAPKG'=$P($G(@(PXAFILE_"(PXAIEN,812)")),"^",2) Q
  1. ... I PXASOURC>0,PXASOURC'=$P($G(@(PXAFILE_"(PXAIEN,812)")),"^",3) Q
  1. ... S ^TMP("PXK",$J,PXAVFILE,PXAINDX,0,"BEFORE")=@(PXAFILE_"(PXAIEN,0)")
  1. ... S ^TMP("PXK",$J,PXAVFILE,PXAINDX,0,"AFTER")="@"
  1. ... S ^TMP("PXK",$J,PXAVFILE,PXAINDX,"IEN")=PXAIEN
  1. ... I PXAWFLAG D
  1. .... S PXAWFLAG=0
  1. .... W !," ...deleting "
  1. .... W $S("CPT"=PXAVFILE:"Procedure","IMM"=PXAVFILE:"Immunizations","PED"=PXAVFILE:"Patient Education",1:"")
  1. .... W $S("POV"=PXAVFILE:"Diagnoses","PRV"=PXAVFILE:"Providers","SK"=PXAVFILE:"Skin Test","TRT"=PXAVFILE:"Treatments","HF"=PXAVFILE:"Health Factors","XAM"=PXAVFILE:"Exams",1:"")
  1. ;now process all the data except the stop codes which have already been done
  1. N PXKERROR
  1. I $D(^TMP("PXK",$J)) D
  1. . I PXAECHO,'$D(ZTQUEUED) D WAIT^DICD
  1. . D EN1^PXKMAIN
  1. . D EVENT^PXKMAIN
  1. . K ^TMP("PXK",$J)
  1. N PXAKILL
  1. I "^"_PXAWHICH_"^"["^VISIT^" D
  1. . S PXAKILL=$$KILL^VSITKIL(PXAVISIT)
  1. Q $S(PXARET=0!$D(PXKERROR):0,$G(PXAKILL):-4,1:1)
  1. ;