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

WVRPCPT2.m

Go to the documentation of this file.
WVRPCPT2 ;ISP/RFR - WV PATIENT FILE (790) APIS AND RPCS ;07/23/2020
 ;;1.0;WOMEN'S HEALTH;**24,26**;Sep 30, 1998;Build 624
 Q
CLRSRND(WVDFN,WVTYPE) ;DELETE EVENT(S) THAT TRIGGERED STATUS REVIEW NOTIFICATION
 ; INPUT: WVDFN - INTERNAL ENTRY NUMBER IN WV PATIENT FILE (#790)
 ;        WVTYPE - TYPE OF SMART DATA
 ;                 "P": PREGNANCY
 ;                 "L": LACTATION
 N WVIEN,WVFDA,WVERROR,WVRETURN
 S WVRETURN=1
 S WVIEN=0 F  S WVIEN=$O(^WV(790.9,"AC",WVDFN,WVTYPE,WVIEN)) Q:'+WVIEN  S WVFDA(790.9,WVIEN_",",.01)="@"
 Q:'$D(WVFDA) WVRETURN
 D FILE^DIE("","WVFDA","WVERROR")
 I $D(WVERROR) S WVRETURN=-1_U_"Unable to delete status review event(s): "_$$FMERROR^WVUTL11(.WVERROR)
 Q WVRETURN
FINDPROC(WVTMP,WVCNT,WVDFN,WVVISIT,WVDOC,WVNEWDFN,EIE,DOACT) ;
 N ACCESS,DA,DATE,END,FIRST,NODE,NOTIF,OCNT,PROC,PUR,SORT,TYPE,WVIEN,WVIIEN,WVNIEN,XREF
 ;find WV Procedure by documentation IEN
 S XREF=""
 I WVDOC>0,$D(^WV(790.1,"NOTE",WVDOC)) S XREF="NOTE"
 I XREF="",$D(^WV(790.1,"V",WVVISIT)) S XREF="V"
 I XREF="" Q
 S SORT=$S(XREF="NOTE":WVDOC,1:WVVISIT)
 I '$D(^WV(790.1,XREF,SORT)) Q
 S OCNT=WVCNT
 ;
 S END=0
 S WVIEN=0 F  S WVIEN=$O(^WV(790.1,XREF,SORT,WVIEN)) Q:WVIEN'>0!(END=1)  D
 .S NODE=$G(^WV(790.1,WVIEN,0))
 .I $P(NODE,U,36)=1,XREF="NOTE",DOACT=1 D OUTCLEAN(WVIEN,WVDFN,WVDOC,.WVTMP) Q
 .I DOACT=0 S WVCNT=WVCNT+1,WVTMP(WVCNT)="The patient next breast treatment data needs to be review in the Women's Package.",END=1 Q
 .I '$D(ACCESS) S WVCNT=WVCNT+1,WVTMP(WVCNT)="The following Women's Health accession# need to be reviewed:"
 .S WVCNT=WVCNT+1,WVTMP(WVCNT)="   "_$P(NODE,U)
 .S WVCNT=WVCNT+1,WVTMP(WVCNT)="   Patient: "_$$GET1^DIQ(2,WVDFN_",",.01)
 .S ACCESS($P(NODE,U))=""
 .S WVIIEN=0 F  S WVIIEN=$O(^WV(790.1,XREF,SORT,WVIEN,WVIIEN)) Q:WVIIEN'>0  D
 ..S DA(1)=WVIEN,DA=WVIIEN
 ..I EIE=1 D SETEIE(.DA,WVDOC)
 .I EIE=1 D CHKSTAT(WVIEN)
 .D FINDNOT(.NOTIF,$P(NODE,U))
 I DOACT=0,END=1 Q
 ;
 ;write out notification information
 S FIRST=0
 S WVNIEN=0 F  S WVNIEN=$O(NOTIF(WVNIEN)) Q:WVNIEN'>0  D
 .S NODE=NOTIF(WVNIEN)
 .I FIRST=0 D
 ..S WVCNT=WVCNT+1,WVTMP(WVCNT)=""
 ..S WVCNT=WVCNT+1,WVTMP(WVCNT)="The following Women's Health notification need to be reviewed:"
 ..S FIRST=1
 .S NODE=NOTIF(WVNIEN)
 .S TYPE=$P($G(^WV(790.403,$P(NODE,U,2),0)),U)
 .S PUR=$P($G(^WV(790.404,$P(NODE,U,3),0)),U)
 .S DATE=$$FMTE^XLFDT($P(NODE,U))
 .S WVCNT=WVCNT+1,WVTMP(WVCNT)="  "_PUR_" notification method "_TYPE_" on "_TYPE
 ;
 I OCNT=WVCNT Q
 S WVCNT=WVCNT+1,WVTMP(WVCNT)=""
 S WVCNT=WVCNT+1,WVTMP(WVCNT)="Review the patient next treatment due from the Women's Health patient profile."
 I +$G(WVNEWDFN)>0 D
 .S WVCNT=WVCNT+1,WVTMP(WVCNT)=""
 .S WVCNT=WVCNT+1,WVTMP(WVCNT)="Patient note reassign to new patient: "_$$GET1^DIQ(2,WVNEWDFN_",",.01)
 .S WVCNT=WVCNT+1,WVTMP(WVCNT)="Review the new patient record for any corrections."
 Q
OUTCLEAN(WVIEN,WVDFN,WVDOC,WVTMP) ;
 N ACCESS,DA,DIE,IEN,NODE,NOTIF,PAT,WVCNT
 S NODE=$G(^WV(790.1,WVIEN,0))
 S PAT=$P(NODE,U,2)
 S ACCESS=$P(NODE,U) I ACCESS="" Q
 D FINDNOT(.NOTIF,ACCESS)
 S IEN=0
 S DIE="^WV(790.4,"
 F  S IEN=$O(NOTIF(IEN)) Q:IEN'>0  D
 .S DA=IEN,DR=".08///"_DT_";.14///ENTER IN ERROR"
 .D ^DIE
 S DIE="^WV(790.1,"
 S DA=WVIEN,DR=".14///ENTER IN ERROR"
 D ^DIE
 S DA(1)=DA
 S DA=0 F  S DA=$O(^WV(790.1,DA(1),10,DA)) Q:DA'>0  D
 .D SETEIE(.DA,WVDOC)
 S WVCNT=0
 S WVCNT=WVCNT+1,WVTMP(WVCNT)="Outside breast care results and notification have been marked Enter in Error Women's Health package"
 S WVCNT=WVCNT+1,WVTMP(WVCNT)="for the following patient"
 S WVCNT=WVCNT+1,WVTMP(WVCNT)=""
 S WVCNT=WVCNT+1,WVTMP(WVCNT)="  "_$$GET1^DIQ(2,PAT_",",.01)
 S WVCNT=WVCNT+1,WVTMP(WVCNT)=""
 S WVCNT=WVCNT+1,WVTMP(WVCNT)="Review the patient next breast treatment and next treatment due in the Women's Health patient profile."
 Q
FINDNOT(NOTIF,ACCESS) ;
 N NODE,IEN
 S IEN=0 F  S IEN=$O(^WV(790.4,"C",ACCESS,IEN)) Q:IEN'>0  D
 .S NODE=$G(^WV(790.4,IEN,0))
 .S NOTIF(IEN)=$P(NODE,U,2,4)
 Q
SETEIE(DA,WVDOC) ;
 N DIE,DR
 S DIE="^WV(790.1,"_DA(1)_",10,",DR="4///YES"
 I +$G(WVDOC)>0,'$D(^TIU(8925,WVDOC)) S DR=DR_";3///@"
 D ^DIE
 Q
VERDATA(WVRETURN,WVDATA) ;VERIFY DATA FROM CLINICAL REMINDERS
 ; INPUT: WVRETURN - REFERENCE TO ARRAY IN WHICH TO RETURN STATUS
 ;                   [REQUIRED]
 ;        WVDATA - REFERENCE TO ARRAY OF DATA TO SAVE
 ;                 [REQUIRED]
 ;  OUTPUT: (0)=1 OR -1
 ;  OUTPUT: (n)=error message
 N CNT,WVFILE,WVVALDAT,WVERROR,WVIENS,WVFIELD,WVATTRS
 I '$D(WVDATA) S WVRETURN(0)=-1_U_"There is no data to validate." Q
 S WVFILE="",CNT=0 F  S WVFILE=$O(WVDATA("DATA",WVFILE)) Q:WVFILE=""  D
 .I "^790^790.05^790.17^790.16^790.9^790.1^790.4^790.23^"'[(U_WVFILE_U) S WVRETURN(1)=-1_U_"Invalid file number: "_WVFILE Q
 .I WVFILE=790 D 790(.WVDATA,.CNT,.WVRETURN)
 .I WVFILE=790.1 D 7901(.WVDATA,.CNT,.WVRETURN)
 .I WVFILE=790.4 D 7904(.WVDATA,.CNT,.WVRETURN)
 S WVFILE=1
 D CHKIENS^WVRPCPT(.WVDATA),VALS^DIE("","WVDATA(""DATA"")","WVVALDAT","WVERROR")
 K WVERROR
 S WVFILE=0 F  S WVFILE=$O(WVVALDAT(WVFILE)) Q:'+WVFILE  D
 .I "^790.9^"[(U_WVFILE_U) Q
 .S WVIENS="" F  S WVIENS=$O(WVVALDAT(WVFILE,WVIENS)) Q:WVIENS=""  S WVFIELD=0 F  S WVFIELD=$O(WVVALDAT(WVFILE,WVIENS,WVFIELD)) Q:'+WVFIELD  D
 ..Q:$G(WVVALDAT(WVFILE,WVIENS,WVFIELD))'=U
 ..D FIELD^DID(WVFILE,WVFIELD,"","LABEL;HELP-PROMPT","WVATTRS","WVERROR")
 ..I $D(WVERROR) S CNT=CNT+1,WVRETURN(CNT)="Field #"_WVFIELD_" in file #"_WVFILE_" has an error: "_$$FMERROR^WVUTL11(.WVERROR) Q
 ..S CNT=CNT+1,WVRETURN(CNT)="The "_$G(WVATTRS("LABEL"))_" field has an invalid value. "_$G(WVATTRS("HELP-PROMPT"))
 S WVRETURN(0)=$S(CNT>0:-1,1:1)
 Q
 ;
790(DATA,CNT,RETURN) ;
 K DATA("DATA",790)
 Q
 ;
7901(DATA,CNT,RETURN) ;
 N ARRAY,IEN,IENS,SUB,TEMP,X
 M ARRAY=DATA("DATA",790.1)
 S IENS="" F  S IENS=$O(ARRAY(IENS)) Q:IENS=""  D
 .I IENS[":" D
 ..K DATA("DATA",790.1,IENS)
 ..F X=1:1:$L(IENS,":") D
 ...S IEN=$P(IENS,":",X)
 ...M DATA("DATA",790.1,IEN)=ARRAY(IENS)
 S IENS="" F  S IENS=$O(ARRAY(IENS)) Q:IENS=""  D
 .S SUB="" F  S SUB=$O(DATA("DATA",790.1,IENS,SUB)) Q:SUB=""  D
 ..I SUB'>0 K DATA("DATA",790.1,IENS,SUB)
 Q
 ;
7904(DATA,CNT,RETURN) ;
 N ARRAY,DELARR,PAT,SUB,TEMP,VALUE
 S PAT=DATA("DFN")
 S SUB="" F  S SUB=$O(DATA("DATA",790.4,SUB)) Q:SUB=""  D
 .K DATA("DATA",790.4,SUB,.06),DATA("DATA",790.4,SUB,.01)
 .I SUB'>0 S TEMP(SUB)="" K DATA("DATA",790.4,SUB)
 I +$G(TEMP("F/U DATE"))>0,+$G(TEMP("F/U DATE"))<$$NOW^XLFDT S CNT=CNT+1,RETURN(CNT)="The Follow up date must be greater than now"
 Q
 ;
CHKSTAT(DA) ;
 N ALLEIE,DIE,DR,IDX,NODE
 S ALLEIE=1
 S IDX=0
 F  S IDX=$O(^WV(790.1,DA,10,IDX)) Q:IDX'>0!(ALLEIE=0)  D
 .S NODE=$G(^WV(790.1,DA,10,IDX,0))
 .I $P(NODE,U,5)'="Y" S ALLEIE=0
 I ALLEIE=1 S DIE="^WV(790.1,",DR=".14///OPEN" D ^DIE
 Q