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

WVRPCPT1.m

Go to the documentation of this file.
WVRPCPT1 ;ISP/RFR - WV PATIENT FILE (790) APIS AND RPCS ;Dec 20, 2019@15:07
 ;;1.0;WOMEN'S HEALTH;**24**;Sep 30, 1998;Build 582
 Q
GETFINDS(RESULT,WVDFN,WVVISIT) ;RETURN DATA NEEDED TO IDENTIFY GENERAL FINDINGS
 ; INPUT: RESULT - SUBSCRIPT UNDER WHICH TO RETURN DATA OR ERROR MESSAGES
 ;                 [REQUIRED]
 ;        WVDFN - IEN OF PATIENT IN WV PATIENT FILE [REQUIRED]
 ;        WVVISIT - IEN IN VISIT FILE OR TIU VISIT STRING [REQUIRED]
 ; OUTPUT: ^TMP(RESULT,$J)=NUMBER OF ENTRIES RETURNED
 ;                         -1^Error message
 ;         FOR NON-MULTIPLES:
 ;         ^TMP(RESULT,$J,"PACKAGE","FILE NUMBER","FIELD NUMBER")=EXTERNAL FORMAT
 ;         FOR MULTIPLES:
 ;         ^TMP(RESULT,$J,"PACKAGE","FILE NUMBER","FIELD NUMBER",IEN)=EXTERNAL FORMAT
 I $G(RESULT)="" S RESULT="WVDATA"
 K ^TMP(RESULT,$J)
 I $G(WVDFN)'?1.N D  Q
 .S ^TMP(RESULT,$J)="-1"_U_"Invalid parameter: WVDFN="_$G(WVDFN)
 I '$D(^WV(790,WVDFN)) D  Q
 .S ^TMP(RESULT,$J)="-1"_U_"The specified patient is not in the WV PATIENT file"
 N VISIT
 S VISIT=$G(WVVISIT)
 I VISIT[";" S VISIT=$$VISITIEN^WVUTL11(WVDFN,VISIT)
 I VISIT<1 D  Q
 .S ^TMP(RESULT,$J)="-1"_U_"Invalid parameter: WVVISIT="_$G(WVVISIT)
 N WVPKG,WVERROR
 S WVPKG=+$$FIND1^DIC(9.4,,,"WOMEN'S HEALTH",,"I $P($G(^(0)),U,2)=""WV""","WVERROR")
 I WVPKG<1 D  Q
 .S ^TMP(RESULT,$J)="-1"_U_"Could not find the WOMEN'S HEALTH entry in the PACKAGE FILE"
 .I $D(WVERROR) S ^TMP(RESULT,$J)=^TMP(RESULT,$J)_" "_$$FMERROR^WVUTL11(.WVERROR)
 .S ^TMP(RESULT,$J)=^TMP(RESULT,$J)_"."
 N WVSUB1,WVIEN1,WVSUB2,WVIEN2,WVPIECE,WVCOUNT,WVFILES,WVFIELD,WVNODE
 S WVFILES(4)=790.05,WVFILES(4,3)=790.17,WVFILES(5)=790.16
 F WVSUB1=4,5  S WVIEN1=0 F  S WVIEN1=$O(^WV(790,WVDFN,WVSUB1,"C",VISIT,WVIEN1)) Q:'+WVIEN1  S WVCOUNT=1+$G(WVCOUNT) F WVSUB2=2:1:4  I $D(^WV(790,WVDFN,WVSUB1,WVIEN1,WVSUB2))  D
 .I $D(^WV(790,WVDFN,WVSUB1,WVIEN1,WVSUB2))=1 S WVNODE=$G(^(WVSUB2)) F WVPIECE=1:1:$L(WVNODE,U)  I $P(WVNODE,U,WVPIECE)'="" D
 ..S WVFIELD=WVSUB2_WVPIECE,^TMP(RESULT,$J,WVPKG,WVFILES(WVSUB1),WVFIELD)=$$EXTERNAL^DILFD(WVFILES(WVSUB1),WVFIELD,"",$P(WVNODE,U,WVPIECE))
 .I $D(^WV(790,WVDFN,WVSUB1,WVIEN1,WVSUB2))>9 S WVIEN2=0 F  S WVIEN2=$O(^WV(790,WVDFN,WVSUB1,WVIEN1,WVSUB2,WVIEN2)) Q:'+WVIEN2  D
 ..S ^TMP(RESULT,$J,WVPKG,WVFILES(WVSUB1,WVSUB2),.01,WVIEN2)=$$EXTERNAL^DILFD(WVFILES(WVSUB1,WVSUB2),.01,"",$P($G(^WV(790,WVDFN,WVSUB1,WVIEN1,WVSUB2,WVIEN2,0)),U))
 ;check smart
 N DX,ITEM,NODE,WVIEN,WVNODE
 S WVIEN=0 F  S WVIEN=$O(^WV(790.1,"V",VISIT,WVIEN)) Q:WVIEN'>0  D
 .S WVNODE=$G(^WV(790.1,WVIEN,0))
 .S WVCOUNT=1+$G(WVCOUNT)
 .I $P(WVNODE,U,5)>0 D
 ..S DX=$P($G(^WV(790.31,+$P(WVNODE,U,5),0)),U)
 ..S ^TMP(RESULT,$J,WVPKG,790.1,.05)=DX
 .I $P($G(^WV(790.1,WVIEN,3)),U)'="" S ^TMP(RESULT,$J,WVPKG,790.1,3.01)=$P($G(^WV(790.1,WVIEN,3)),U)
 .S ITEM=0 F  S ITEM=$O(^WV(790.1,"V",VISIT,WVIEN,ITEM)) Q:ITEM'>0  D
 ..S NODE=$G(^WV(790.1,WVIEN,10,ITEM,0)) I $P(NODE,U)="" Q
 ..S ^TMP(RESULT,$J,WVPKG,790.23,.01,ITEM)=$P(NODE,U)
 S ^TMP(RESULT,$J)=+$G(WVCOUNT)
 Q
SHOVISIT ;RETURN MESSAGE FOR TIU USER ABOUT PRESENCE OF PREGNANCY/LACTATION STATUS DATA
 N WVCNT,WVDFN,WVVISIT,WVSUB1,WVDATA,WVTEXT,WVTMP,WVDOC,WVACT
 S WVDFN=$G(^TMP("TIUDOCDIS",$J,"PATIENT")),WVVISIT=+$G(^("VISIT")),WVDOC=+$G(^("DOCUMENT")),WVACT=$G(^("ACTION"))
 S WVCNT=0
 F WVSUB1=4,5  D
 .I +$O(^WV(790,WVDFN,WVSUB1,"D",WVDOC,0))>0 S WVDATA("DOCUMENT")=WVSUB1+$G(WVDATA("DOCUMENT")) Q
 .I +$O(^WV(790,WVDFN,WVSUB1,"C",WVVISIT,0))>0 S WVDATA("VISIT")=WVSUB1+$G(WVDATA("VISIT"))
 S WVDATA=$S($G(WVDATA("DOCUMENT"))>0:WVDATA("DOCUMENT")_U_$P($G(^TMP("TIUDOCDIS",$J,"DOCUMENT")),U,2)_" (#"_WVDOC_") document",1:+$G(WVDATA("VISIT"))_U_$P($G(^TMP("TIUDOCDIS",$J,"DOCUMENT")),U,2)_" (#"_WVDOC_") document's visit")
 S WVDATA=WVDATA_" that will remain in the database after deletion of this document."
 I $P(WVDATA,U)>0,WVACT="RETRACT" D
 .D WRAP^ORUTL("There is "_$S(+WVDATA=4:"pregnancy",+WVDATA=5:"lactation",+WVDATA=9:"pregnancy and lactation",1:"")_" status data associated with the "_$P(WVDATA,U,2),"WVTMP",0,,,.WVCNT)
 D FINDPROC(.WVTMP,.WVCNT,WVDFN,WVVISIT,WVDOC,0,0,0)
 I WVCNT=0 Q
 I $G(DUZ(2))?1.N S WVTEXT=$P($G(^WV(790.02,DUZ(2),44)),U)
 I WVTEXT'="" S WVCNT=WVCNT+1,WVTMP(WVCNT)=" ",WVCNT=WVCNT+1,WVTMP(WVCNT)=WVTEXT
 S ^TMP("TIUDOCDIS",$J,"MESSAGES","WOMEN'S HEALTH")=WVCNT
 M ^TMP("TIUDOCDIS",$J,"MESSAGES","WOMEN'S HEALTH")=WVTMP
 Q
 ;
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 DOACT=0 S WVCNT=WVCNT+1,WVTMP(WVCNT)="The patient has breast treatment data that needs to be reviewed.",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)
 .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 file"
 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
 ;
FINDNOT(NOTIF,ACCESS) ;
 N NODE,IEN
 S IEN=0 F  S IEN=$O(^WV(790.4,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 '$D(^TIU(8925,WVDOC)) S DR=DR_";3///@"
 D ^DIE
 Q
 ;
GETORDRS(WVDFN,WVTYPE,WVCCACHE) ;GET HARMFUL ORDERS FOR A GIVEN CONTEXT
 ; INPUT: WVDFN - INTERNAL ENTRY NUMBER (IEN) OF PATIENT IN WV PATIENT FILE (#790)
 ;        WVTYPE - CONTEXT OF ORDERS [REQUIRED]:
 ;                 "P": PREGNANT
 ;                 "L": LACTATING
 ;        WVCCACHE - STORE RETURNED TEXT IN CACHE [OPTIONAL]:
 ;                  1: STORE TEXT IN CACHE
 ;                  0 OR UNDEFINED: DO NOT STORE TEXT IN CACHE
 S WVCCACHE=+$G(WVCCACHE)
 N WVRESULT,WVCACHE,WVLINE
 S WVRESULT=$NA(^TMP("WVPTO",$J)),WVCACHE=$NA(^TMP("WVPTOCACHE",$J,WVTYPE))
 K @WVRESULT
 I '$$VERDFN(.WVDFN,0,WVRESULT) D  Q "~@"_WVRESULT
 .S WVLINE=2 D WRAP^ORUTL(@WVRESULT@(1,0),WVRESULT,0,,,.WVLINE,80,1)
 .S @WVRESULT@(1,0)="An automated review of this patient's chart for potentially harmful orders"
 .S @WVRESULT@(2,0)="failed. A manual review is required."
 I $D(@WVCACHE) D  Q "~@"_WVRESULT
 .M @WVRESULT=@WVCACHE
 .K @WVCACHE
 N WVFKST,WVRETURN,WVLEN,WVCNT,WVORN,WVOCRNM
 S WVTYPE=$G(WVTYPE),WVFKST=1,WVLINE=7,WVCNT=0
 S WVRETURN=$$GETORDRS^WVUTL11(WVDFN,$S(WVTYPE="L":1,1:0))
 I $P(@WVRETURN@(0),U)=-1 D
 .S @WVRESULT@(1,0)="An automated review of this patient's chart for potentially harmful orders"
 .S @WVRESULT@(2,0)="failed. A manual review is required.",@WVRESULT@(3,0)=""
 .S WVLINE=3 D WRAP^ORUTL("Error: "_$P(@WVRETURN@(0),U,2),WVRESULT,1,,,.WVLINE,80,1)
 S WVORN=0 F  S WVORN=$O(@WVRETURN@(WVORN)) Q:'+WVORN  D
 .N WVCONT
 .S WVOCRNM="" F  S WVOCRNM=$O(@WVRETURN@(WVORN,"RULES",WVOCRNM)) Q:WVOCRNM=""!($G(WVCONT))  I ((WVTYPE="P")&(WVOCRNM["PREG"))!((WVTYPE="L")&(WVOCRNM["LACT")) S WVCONT=1
 .Q:'$G(WVCONT)
 .N WVOI,WVSTART
 .S WVOI=$G(@WVRETURN@(WVORN,"TX",1)),@WVRESULT@(WVLINE,0)=WVOI,WVLINE=WVLINE+1,WVCNT=1+WVCNT
 .I $L(WVOI)>$G(WVLEN) S WVLEN=$L(WVOI)
 .S @WVRESULT@(WVLINE,0)="  "_$$LJ^XLFSTR($P($G(@WVRETURN@(WVORN)),U,6),20)_"  "
 .S WVSTART=$P($G(@WVRETURN@(WVORN)),U,4) I WVSTART'="" S @WVRESULT@(WVLINE,0)=@WVRESULT@(WVLINE,0)_$$FMTE^XLFDT(WVSTART,"5DZ")
 .S WVLINE=WVLINE+1
 I '$P(@WVRETURN@(0),U)!(WVCNT=0) D
 .S @WVRESULT@(1,0)="An automated review of this patient's chart indicates there are no"
 .S @WVRESULT@(2,0)="potentially harmful orders to review."
 K @WVRETURN
 I WVCNT>0 D
 .S @WVRESULT@(WVLINE,0)=" ",WVLINE=1
 .S @WVRESULT@(WVLINE,0)="An automated review of this patient's chart indicates the following",WVLINE=WVLINE+1
 .S @WVRESULT@(WVLINE,0)="order"_$S(WVCNT=1:" is",1:"s are")_" potentially harmful:",WVLINE=WVLINE+1
 .S @WVRESULT@(WVLINE,0)="",WVLINE=WVLINE+1
 .S @WVRESULT@(WVLINE,0)="Orderable Item",WVLINE=WVLINE+1,@WVRESULT@(WVLINE,0)="  Status                Start",WVLINE=WVLINE+1
 .S WVLEN=$G(WVLEN)+1,@WVRESULT@(WVLINE,0)=$$REPEAT^XLFSTR("=",$S(WVLEN>78:78,WVLEN<34:34,1:WVLEN))
 I WVCCACHE D
 .M @WVCACHE=@WVRESULT
 .S ^TMP("WVGETORDERS",$J,WVTYPE)=WVCNT
 Q "~@"_WVRESULT
GETMRST(WVDFN,WVTYPE) ;GET MOST RECENT STATUS
 ; INPUT: WVDFN - INTERNAL ENTRY NUMBER (IEN) OF PATIENT IN WV PATIENT FILE (#790)
 ;        WVTYPE - TYPE OF STATUS TO RETURN; P FOR PREGNANCY, L FOR LACTATION
 N WVRESULT,WVPATNM,WVNUM,WVLINE,WVVALUE,WVSUB
 S WVRESULT=$NA(^TMP("WVPTO",$J)),WVLINE=1
 K @WVRESULT
 I '$$VERDFN(.WVDFN,1,WVRESULT) Q "~@"_WVRESULT
 I "^L^P^"'[(U_WVTYPE_U) D  Q "~@"_WVRESULT
 .S @WVRESULT@(1,0)="Invalid type specified: """_$G(WVTYPE)_""""
 D GETDATA^WVRPCPT("WVSTATS",WVDFN,WVTYPE)
 S WVSUB=$S(WVTYPE="P":"PREGNANCY",1:"LACTATION")
 F WVNUM=1:1:$G(^TMP("WVSTATS",$J)) Q:WVLINE>1  D
 .Q:'$D(^TMP("WVSTATS",$J,WVNUM))
 .Q:+$G(^TMP("WVSTATS",$J,WVNUM,WVSUB_" STATE"))'=1
 .S @WVRESULT@(WVLINE,0)=$$LJ^XLFSTR("DATE",23)_WVSUB_" STATE",WVLINE=WVLINE+1
 .S @WVRESULT@(WVLINE,0)="  DETAILS",WVLINE=WVLINE+1
 .S @WVRESULT@(WVLINE,0)=$$REPEAT^XLFSTR("=",50),WVLINE=WVLINE+1
 .S @WVRESULT@(WVLINE,0)=$$LJ^XLFSTR($P($G(^TMP("WVSTATS",$J,WVNUM,WVSUB_" STATUS D/T ENTERED")),U,2),23)
 .S @WVRESULT@(WVLINE,0)=@WVRESULT@(WVLINE,0)_$P($G(^TMP("WVSTATS",$J,WVNUM,WVSUB_" STATE")),U,2)
 .S WVLINE=WVLINE+1
 .I WVTYPE="P" D
 ..S WVVALUE=$P($G(^TMP("WVSTATS",$J,WVNUM,"LAST MENSTRUAL PERIOD DATE")),U,2)
 ..I WVVALUE'="" S @WVRESULT@(WVLINE,0)="  LAST MENSTRUAL PERIOD DATE: "_WVVALUE,WVLINE=WVLINE+1
 ..S WVVALUE=$P($G(^TMP("WVSTATS",$J,WVNUM,"EDD")),U,2)
 ..I WVVALUE'="" S @WVRESULT@(WVLINE,0)="  EXPECTED DUE DATE: "_WVVALUE,WVLINE=WVLINE+1
 ..S WVVALUE=$P($G(^TMP("WVSTATS",$J,WVNUM,"OVERRIDE CALCULATED EDD REASON")),U,2)
 ..I WVVALUE'="" D WRAP^ORUTL("  REASON WHY CALCULATED EDD WAS OVERRIDDEN: "_WVVALUE,WVRESULT,1,,,.WVLINE,80,1) S WVLINE=WVLINE+1
 K ^TMP("WVSTATS",$J)
 I '$D(@WVRESULT) S @WVRESULT@(1,0)="There is no status of "_$S(WVTYPE="P":"pregnant",1:"lactating")_" on file."
 Q "~@"_WVRESULT
GETMUCRT(WVDFN) ;GET MOST RECENT MEDICALLY UNABLE TO CONCEIVE REASON
 N WVRESULT,WVSTATS,WVNUM
 S WVRESULT=$NA(^TMP("WVMUCRT",$J))
 K @WVRESULT
 D GETDATA^WVRPCPT("WVSTATS",WVDFN,"P",,,1)
 I +$G(^TMP("WVSTATS",$J,1,"MEDICALLY UNABLE TO CONCEIVE")) D
 .S @WVRESULT@(1,0)=$P($G(^TMP("WVSTATS",$J,1,"MEDICAL REASON")),U,2)
 I '+$G(^TMP("WVSTATS",$J,1,"MEDICALLY UNABLE TO CONCEIVE")) D
 .S @WVRESULT@(1,0)="The patient is not currently documented as medically unable to conceive."
 K ^TMP("WVSTATS",$J)
 Q "~@"_WVRESULT
VERDFN(WVDFN,WVCHKREG,WVRESULT) ;VERIFY DFN IS IN WV PATIENT FILE (#790)
 I +$G(WVDFN)<1 S @WVRESULT@(1,0)="Invalid patient selected: """_$G(WVDFN)_"""" Q 0
 I +$G(WVCHKREG),'$D(^WV(790,WVDFN)) D  Q 0
 .S WVPATNM=$P($G(^DPT(WVDFN,0)),U)
 .S @WVRESULT@(1,0)=$S(WVPATNM'="":WVPATNM,1:"Patient #"_WVDFN)_" is not registered in the Women's Health package."
 Q 1
SAVESRND(WVDATA) ;SAVE EVENT THAT TRIGGERED STATUS REVIEW NOTIFICATION
 ;INPUT: WVDATA - ARRAY OF DATA FOR THE EVENT
 ;                WVDATA("LAB")="Observation D/T|Observation ID|Observation Sub-ID|Observation Value|Units|Reference Range"
 ;                WVDATA("CODE")="Coding System|Code|Date of Interest|Date Recorded"
 ;                WVDATA("ID")="IEN in file #790^Status Type"
 ;                             Status Type: P for Pregnancy or L for Lactation
 ;OUTPUT: $$SAVESRND - 1=Successfully saved the event
 ;                     0=Did not save the event
 ;                    -1^Message=Error^Error message
 N WVFDA,WVIEN,WVSTAT,WVDESC,WVLINES,WVDFN,WVEXIT,WVINDEX,WVMAP,WVVER,WVLAB
 N WVCODE,WVDATE
 S WVLINES=0
 I $L($G(WVDATA("ID")),U)=2 D
 .S WVDFN=$P(WVDATA("ID"),U),WVFDA(790.9,"+1,",2)=WVDFN
 .S WVFDA(790.9,"+1,",3)=$P(WVDATA("ID"),U,2)
 I $L($G(WVDATA("LAB")),"|")=6 D
 .D WRAP^ORUTL("Laboratory Test: "_$P($P(WVDATA("LAB"),"|",2),U,5),"WVDESC",,,,.WVLINES,,1)
 .D WRAP^ORUTL("Collected On: "_$$FMTE^XLFDT($P(WVDATA("LAB"),"|"),1),"WVDESC",,,,.WVLINES,,1)
 .D WRAP^ORUTL("Result: "_$P(WVDATA("LAB"),"|",4)_" "_$P(WVDATA("LAB"),"|",5),"WVDESC",,,,.WVLINES,,1)
 .D WRAP^ORUTL("Reference Range: "_$P(WVDATA("LAB"),"|",6),"WVDESC",,,,.WVLINES,,1)
 .S WVDATE=$$NOW^XLFDT
 I $L($G(WVDATA("CODE")),"|")>=2 D  Q:'$D(WVFDA) 0
 .S WVDATE=$P(WVDATA("CODE"),"|",3) I WVDATE="" S WVDATE=$$DT^XLFDT
 .S WVCODE("C")=$P(WVDATA("CODE"),"|",2),WVCODE("S")=$P(WVDATA("CODE"),"|")
 .S WVIEN=+$O(^WV(790.9,"C",WVDFN,$P(WVDATE,"."),WVCODE("S"),WVCODE("C"),0))
 .I WVIEN>0,$D(^WV(790.9,WVIEN,0)) K WVFDA Q
 .K WVIEN
 .S WVFDA(790.9,"+1,",4)=WVCODE("S"),WVFDA(790.9,"+1,",5)=WVCODE("C")
 .S WVSTAT=$$EXP^LEXCODE(WVCODE("C"),WVCODE("S"))
 .I +WVSTAT=-1 D WRAP^ORUTL("Description for code "_WVCODE("C")_"in coding system "_WVCODE("S")_" not found: "_$P(WVSTAT,U,2),"WVDESC",,,,.WVLINES,,1)
 .E  D WRAP^ORUTL("Code: "_$P(WVSTAT,U,2)_" ("_WVCODE("C")_")","WVDESC",,,,.WVLINES,,1)
 .D WRAP^ORUTL("Visit/Admit Date/Time: "_$$FMTE^XLFDT(WVDATE,1),"WVDESC",,,,.WVLINES,,1)
 .S WVFDA(790.9,"+1,",6)=WVDATE
 .S WVDATE=$P(WVDATA("CODE"),"|",4)
 .I WVDATE'?7N.1".".6N S WVDATE=$$NOW^XLFDT
 I '$D(WVFDA(790.9,"+1,",2))!('$D(WVDESC)) Q -1_U_"Incomplete input."
 S WVFDA(790.9,"+1,",.01)=WVDATE
 D UPDATE^DIE("","WVFDA","WVIEN","WVERROR")
 I $D(WVERROR) Q -1_U_$$FMERROR^WVUTL11(.WVERROR)
 I $G(WVIEN(1))<1 Q -1_U_"A record number was not returned."
 D WP^DIE(790.9,WVIEN(1)_",",10,"","WVDESC","WVERROR")
 I $D(WVERROR) Q -1_U_$$FMERROR^WVUTL11(.WVERROR)
 Q 1
GETSRND(WVDFN,WVTYPE) ;GET EVENT THAT TRIGGERED STATUS REVIEW NOTIFICATION
 ;INPUT: WVDFN - IEN IN FILE #790
 ;       WVTYPE - STATUS TYPE FIELD (#3) IN WV PREGNANCY/LACTATION STATUS CONFLICT EVENTS FILE (#790.9)
 N WVIEN,WVRETURN,WVLINE,WVCNT
 S WVRETURN=$NA(^TMP("WVPTO",$J)),WVCNT=0
 K @WVRETURN
 I '$$VERDFN(.WVDFN,0,WVRETURN) Q "~@"_WVRETURN
 S WVIEN=0 F  S WVIEN=$O(^WV(790.9,"AC",WVDFN,WVTYPE,WVIEN)) Q:'+WVIEN  D
 .I WVCNT=0 M @WVRETURN=^WV(790.9,WVIEN,1) K @WVRETURN@(0) S WVCNT=+$P($G(^WV(790.9,WVIEN,1,0)),U,4) Q
 .I WVCNT>0 S WVLINE=0 F  S WVLINE=$O(^WV(790.9,WVIEN,1,WVLINE)) Q:'+WVLINE  S WVCNT=1+WVCNT M @WVRETURN@(WVCNT)=^WV(790.9,WVIEN,1,WVLINE)
 I WVCNT=0 D WRAP^ORUTL("There is no "_$S(WVTYPE="P":"pregnancy",WVTYPE="L":"lactation",1:"")_" status review event for "_$P($G(^DPT(WVDFN,0)),U)_".",WVRETURN,1,,,.WVCNT,80,1)
 Q "~@"_WVRETURN
PATMGR(RESULTS,PAT,WHO,IDEN,DIV) ;RETURN HEALTHCARE MANAGERS FOR PATIENT
 ; INPUT: RESULTS - REFERENCE TO ARRAY IN WHICH TO RETURN DATA [REQUIRED]
 ;        PAT - IEN OF PATIENT IN WV PATIENT FILE [REQUIRED]
 ;        WHO - TYPE OF MANAGER TO RETURN; VALUES INCLUDE:
 ;              "C" FOR CASE MANAGER
 ;              "M" FOR MATERNITY CARE COORDINATOR
 ;              "CM" FOR CASE MANAGER AND MATERNITY CARE COORDINATOR
 ;        IDEN - WHETHER TO IDENTIFY THE PROVIDER'S ROLE IN THE RETURN ARRAY [OPTIONAL]
 ;               1 TO RETURN THE ROLE [DEFAULT], 0 TO NOT RETURN THE ROLE
 ;        DIV - IEN OF THE INSTITUTION FOR THE PATIENT [REQUIRED]
 N IEN,NODE
 S IDEN=$G(IDEN,1),WHO=$G(WHO)
 I "^C^M^CM^"'[(U_WHO_U) S RESULTS(0)="-1^Invalid healthcare manager specified" Q
 S IEN=+$O(^WV(790,"B",PAT,""))
 I IEN=0 D  Q
 .I WHO="M" S RESULTS(0)="-1^Patient record not found" Q
 .I +$G(DIV)=0 S RESULTS(0)="-1^Patient record not found and invalid institution parameter" Q
 .I '$D(^WV(790.02,DIV,0)) S RESULTS(0)="-1^Patient record not found and institution is not configured in site parameters" Q
 .S NODE=$G(^WV(790.02,DIV,0))
 .I WHO["C" D
 ..I $P(NODE,U,2)>0 S RESULTS($P(NODE,U,2))=$S(IDEN:"CASE MANAGER",1:"")
 ..I +$P(NODE,U,2)=0 S RESULTS(0)="-1^Patient record not found and default case manager not set"
 S NODE=$G(^WV(790,IEN,0))
 I WHO["C",$P(NODE,U,10)>0 S RESULTS(+$P(NODE,U,10))=$S(IDEN:"CASE MANAGER",1:"")
 I WHO["M",$P(NODE,U,29)>0 S RESULTS(+$P(NODE,U,29))=$S(IDEN:"MATERNITY CARE COORDINATOR",1:"")
 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