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

WVMGRP2.m

Go to the documentation of this file.
WVMGRP2 ;ISP/RFR - MANAGER'S PATIENT EDITS;06/13/2017  15:49
 ;;1.0;WOMEN'S HEALTH;**24**;Sep 30, 1998;Build 582
 Q
PACT(WVNODE,WVACTION,WVRIENS,WVNPAT,WVNVISIT,WVADESC,WVSRC,WVNPATNM) ;PERFORM AN ACTION ON THE DATA
 ; INPUT: WVNODE: GLOBAL NODE NUMBER IN ^WV(790,D0, WHERE THE DATA RESIDES [REQUIRED]
 ;        WVACTION: THE ACTION TO TAKE [REQUIRED]
 ;                  1 TO REASSIGN, 2 TO MARK AS ENTERED IN ERROR
 ;        WVRIENS: IENS OF CURRENT ENTRY IN ACTIVITIES MULTIPLE IN WV DATA NEEDING REVIEW FILE [OPTIONAL]
 ;        WVNPAT: IEN IN WV PATIENT FILE OF PATIENT TO REASSIGN DATA TO [OPTIONAL]
 ;        WVNVISIT: IEN IN VISIT FILE TO ASSOCIATE WITH REASSIGNED DATA [OPTIONAL]
 ;        WVADESC: EXTERNAL FORM OF THE ACTION TO TAKE [OPTIONAL]
 ;        WVSRC: THE OBJECT THE ACTION WAS TAKEN ON [OPTIONAL]
 ;        WVNPATNM: THE NEW PATIENT'S NAME [OPTIONAL]
 ; OUTPUT: $$PACT: WHETHER THE ACTION WAS SUCCESSFULLY TAKEN, -1 FOR AN ERROR
 N WVDIENS,WVDATA,WVERROR,WVFDA,WVFILE,WVFIELD,WVIENS,WVRESULT,WVENTRIS,WVIEN
 I '$G(WVPROMPT) D  Q:$G(WVRESULT)=-1 -1
 .S WVIEN=0 F  S WVIEN=$O(^WV(790,WVPAT,WVNODE,$P(WVTYPE,U,2),WVITEM,WVIEN)) Q:'+WVIEN  S WVENTRIS(WVIEN_","_WVPAT_",")=""
 .I $D(WVENTRIS)<10 S WVRESULT=$$ERROR^WVMGRP("determining the data record ID(s)",,"There is a problem with the "_$P(WVTYPE,U,2)_" cross-reference on the^"_$S(WVNODE=4:"PREGNANCY",1:"LACTATION")_" STATUSES multiple in the WV PATIENT file.")
 I $G(WVPROMPT) S WVENTRIS(WVPROMPT)=""
 S WVFILE=$S(WVNODE=4:790.05,1:790.16)
 I WVACTION=1 D  Q:$G(WVRESULT)=-1 -1
 .D GETS^DIQ(WVFILE,WVDIENS,"**","IN","WVDATA","WVERROR")
 .I $D(WVERROR) S WVRESULT=$$ERROR^WVMGRP("retrieving existing data",.WVERROR) Q
 .S WVFIELD="" F  S WVFIELD=$O(WVDATA(WVFILE,WVDIENS,WVFIELD)) Q:WVFIELD=""  S WVFDA(WVFILE,"+1,"_WVNPAT_",",WVFIELD)=WVDATA(WVFILE,WVDIENS,WVFIELD,"I")
 .S WVFDA(WVFILE,"+1,"_WVNPAT_",",4)=$G(WVNVISIT),WVFDA(WVFILE,"+1,"_WVNPAT_",",.01)=$$NOW^XLFDT
 .D UPDATE^DIE("","WVFDA","WVIEN","WVERROR")
 .I $D(WVERROR) S WVRESULT=$$ERROR^WVMGRP("copying existing data",.WVERROR) Q
 .I WVNODE=4 D  Q:$G(WVRESULT)=-1
 ..N WVCNT
 ..S WVIENS="" F  S WVIENS=$O(WVDATA(790.17,WVIENS)) Q:WVIENS=""  S WVFIELD="" F  S WVFIELD=$O(WVDATA(790.17,WVIENS,WVFIELD)) Q:WVFIELD=""  D
 ...S WVCNT=1+$G(WVCNT),WVFDA(790.17,"+"_WVCNT_","_WVIEN(1)_","_WVNPAT_",",WVFIELD)="`"_WVDATA(790.17,WVIENS,WVFIELD,"I")
 ..Q:'$D(WVFDA)
 ..S WVRESULT=$$METHOD^WVTDALRT(WVNPAT,,.WVFDA)
 ..I $P(WVRESULT,U)=-1 S WVRESULT=$$ERROR^WVMGRP("copying existing contraceptive methods",,$P(WVRESULT,U,2))
 .K WVDATA
 S WVDIENS=0 F  S WVDIENS=$O(WVENTRIS(WVDIENS)) Q:WVDIENS=""!($G(WVRESULT)=-1)  D
 .S WVFILE=$S(WVNODE=4:790.05,1:790.16)
 .S WVFDA(WVFILE,WVDIENS,6)=1
 .D FILE^DIE("K","WVFDA","WVERROR")
 .I $D(WVERROR) S WVRESULT=$$ERROR^WVMGRP("marking the "_$S(WVACTION=1:"incorrect ",1:"")_"entry as entered in error",.WVERROR) Q
 .S WVFILE=$S(WVNODE=4:790.15,1:790.18)
 .I '$G(WVPROMPT) D  Q:$G(WVRESULT)=-1
 ..I +WVRIENS>0 D  Q:$G(WVRESULT)=-1
 ...D GETS^DIQ(790.801,WVRIENS,"2;3;11","","WVDATA","WVERROR")
 ...I $D(WVERROR) S WVRESULT=$$ERROR^WVMGRP("retrieving WV DATA NEEDING REVIEW data",.WVERROR) Q
 ...S WVADESC=WVDATA(790.801,WVRIENS,3),WVSRC=WVDATA(790.801,WVRIENS,2),WVNPATNM=WVDATA(790.801,WVRIENS,11)
 ..I +WVRIENS=0 S WVSRC=$P(WVSRC," (")
 ..S WVFDA(WVFILE,"+1,"_WVDIENS,.01)="A "_WVADESC_" action taken on the "_WVSRC_" document prompted a chart review."
 .I $G(WVPROMPT) D  Q:$G(WVRESULT)=-1
 ..K DIR,DIRUT,DIROUT,Y
 ..S DIR(0)=WVFILE_",.01"
 ..D ^DIR
 ..I $D(DIRUT)!($D(DIROUT)) S WVRESULT=-1 Q
 ..S WVFDA(WVFILE,"+1,"_WVDIENS,.01)=$P($G(Y),U)
 .I WVACTION=1 S WVFDA(WVFILE,"+1,"_WVDIENS,.01)=WVFDA(WVFILE,"+1,"_WVDIENS,.01)_" The data was moved to "_WVNPATNM_"'s chart."
 .D UPDATE^DIE("","WVFDA",,"WVERROR")
 .I $D(WVERROR) S WVRESULT=$$ERROR^WVMGRP("storing the reason why the "_$S(WVACTION=1:"incorrect",1:"")_" entry was marked as entered in error",.WVERROR)
 I $G(WVRESULT)=-1 Q -1
 W !!,"ACTION TAKEN.",!
 H 4
 I $G(WVRIENS)'="" D  Q:$G(WVRESULT)=-1 -1
 .S WVRIENS=$P(WVRIENS,",",2)_","
 .I +WVRIENS=0 S WVRESULT=$$ERROR^WVMGRP("deleting the review record",,"Unable to determine the proper IENS value.") Q
 .S WVFDA(790.8,WVRIENS,.01)="@"
 .D FILE^DIE(,"WVFDA","WVERROR")
 .I $D(WVERROR) S WVRESULT=$$ERROR^WVMGRP("deleting the review record",.WVERROR) Q
 .K WVRTACTS
 Q 1
 ;