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 ;Jun 15, 2021@12:11
 ;;1.0;WOMEN'S HEALTH;**24,26**;Sep 30, 1998;Build 624
 Q
GETFINDS(RESULT,WVDFN,WVVISIT,WVNIEN) ;RETURN DATA NEEDED TO IDENTIFY GENERAL FINDINGS
 ; INPUT: RESULT - SUBSCRIPT UNDER WHICH TO RETURN DATA OR ERROR MESSAGES
 ;                 [OPTIONAL; DEFAULT IS "WVDATA"]
 ;        WVDFN - IEN OF PATIENT IN WV PATIENT FILE [REQUIRED]
 ;        WVVISIT - IEN IN VISIT FILE OR TIU VISIT STRING [OPTIONAL]
 ;        WVNIEN - IEN IN TIU DOCUMENT FILE [OPTIONAL]
 ;        NOTE: ONE OF WVVISIT OR WVNIEN IS REQUIRED; BOTH CANNOT BE NULL
 ; 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,WVLOOP
 S VISIT=$G(WVVISIT)
 I VISIT'="" D  Q:$D(^TMP(RESULT,$J))
 .I VISIT[";" S VISIT=$$VISITIEN^WVUTL11(WVDFN,VISIT)
 .I VISIT<1 D  Q
 ..S ^TMP(RESULT,$J)="-1"_U_"Invalid parameter: WVVISIT="_$G(WVVISIT)
 .S WVLOOP=$NA(^WV(790,WVDFN,0,"C",VISIT))
 N NOTE
 S NOTE=$G(WVNIEN)
 I NOTE'="" S WVLOOP=$NA(^WV(790,WVDFN,0,"D",NOTE))
 I VISIT="",NOTE="" D  Q
 .S ^TMP(RESULT,$J)="-1"_U_"Missing parameter: One of WVVISIT or WVNIEN is required"
 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  D
 .S $P(WVLOOP,",",3)=WVSUB1,WVIEN1=0
 .F  S WVIEN1=$O(@WVLOOP@(WVIEN1)) Q:'+WVIEN1  D
 ..S WVNODE=$G(^WV(790,WVDFN,WVSUB1,WVIEN1,0))
 ..S ^TMP(RESULT,$J,WVPKG,WVFILES(WVSUB1),3)=$$EXTERNAL^DILFD(WVFILES(WVSUB1),3,"",$P(WVNODE,U,3))
 ..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,INDEX,ITEM,LOOKUP,NODE,WVIEN,WVNODE
 S INDEX="V",LOOKUP=$G(VISIT)
 I $G(NOTE)>0 S INDEX="NOTE",LOOKUP=NOTE
 S WVIEN=0 F  S WVIEN=$O(^WV(790.1,INDEX,LOOKUP,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,INDEX,LOOKUP,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^WVRPCPT2(.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 $G(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
 ;
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^WVUTL12(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,WVSTOP
 .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 WVSTOP=$P($G(@WVRETURN@(WVORN)),U,5)
 .I WVSTOP'="" D
 ..I WVSTART="" S @WVRESULT@(WVLINE,0)=@WVRESULT@(WVLINE,0)_$$REPEAT^XLFSTR(" ",10)
 ..S @WVRESULT@(WVLINE,0)=@WVRESULT@(WVLINE,0)_"  "_$$FMTE^XLFDT(WVSTOP,"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
 .S @WVRESULT@(WVLINE,0)="  Status                Start       Stop",WVLINE=WVLINE+1
 .S WVLEN=$G(WVLEN)+1,@WVRESULT@(WVLINE,0)=$$REPEAT^XLFSTR("=",$S(WVLEN>78:78,WVLEN<46:46,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,WVADATE,WVSTART,WVSTOP,WVNODE
 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:$G(WVEXIT) 0
 .S WVDATE=$P(WVDATA("CODE"),"|",3)
 .I WVDATE'="" D  Q:$G(WVEXIT)
 ..S WVADATE=$P(WVDATE,".",1)
 ..I $P(WVDATA("ID"),U,2)="P" S WVINDEX="APREG",WVNODE=4
 ..E  S WVINDEX="ALACT",WVNODE=5
 ..S WVSTART=0 F  S WVSTART=$O(^WV(790,WVDFN,WVNODE,WVINDEX,WVSTART)) Q:('+WVSTART)!($G(WVEXIT))  D
 ...S WVSTOP=$O(^WV(790,WVDFN,WVNODE,WVINDEX,WVSTART,0))
 ...I WVADATE>=WVSTART,WVADATE<=WVSTOP,$O(^WV(790,WVDFN,WVNODE,WVINDEX,WVSTART))>0 S WVEXIT=1
 .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)) S WVEXIT=1 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"),WVDATE)
 .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)
 .I +WVSTAT>-1 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:$$NAME^XUAF4(DIV)_" DEFAULT 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:"ASSIGNED CASE MANAGER",1:"")
 I WHO["M",$P(NODE,U,29)>0 S RESULTS(+$P(NODE,U,29))=$S(IDEN:"MATERNITY CARE COORDINATOR",1:"")
 Q
GETRECIPS(RESULTS,PAT,SOURCE,TYPE,IDEN,DIV) ;RETURN STATUS CONFLICT NOTIFICATION RECIPIENTS
 ; INPUT: RESULTS - REFERENCE TO ARRAY IN WHICH TO RETURN RECIPIENT LIST
 ;                  [REQUIRED]
 ;        PAT - IEN OF PATIENT IN WV PATIENT FILE [REQUIRED]
 ;        SOURCE - TYPE OF CONFLICT SOURCE [REQUIRED]; VALUES INCLUDE:
 ;                 "CODE" FOR ICD AND SNOMED CODES
 ;                 "LAB" FOR LABORATORY TEST
 ;        TYPE - TYPE OF STATUS CONFLICT [REQUIRED]; VALUES INCLUDE:
 ;               "P" FOR PREGNANCY
 ;               "L" FOR LACTATION
 ;        IDEN - WHETHER TO IDENTIFY THE PROVIDER'S ROLE IN THE RETURN ARRAY [OPTIONAL]
 ;               1 TO RETURN THE ROLE, 0 TO NOT RETURN THE ROLE [DEFAULT]
 ;        DIV - IEN OF THE INSTITUTION FOR THE PATIENT [REQUIRED]
 N RECIPS,PCP
 S RECIPS="CM",PCP=0,IDEN=+$G(IDEN)
 I TYPE="P",$$REM^WVUTL11(PAT,"VA-WH MEDICALLY UNABLE TO CONCEIVE")="DUE NOW" D
 .I SOURCE="CODE" S RECIPS="M"
 .E  S RECIPS=""
 .S PCP=+$P($$OUTPTPR^SDUTL3(PAT,$$DT^XLFDT),U)
 I RECIPS'="" D PATMGR(.RESULTS,PAT,RECIPS,IDEN,DIV)
 I ('IDEN),($P($G(RESULTS(0)),U,2)["Patient record not found") K RESULTS
 I PCP>0 S RESULTS(PCP)=$S(IDEN:"PRIMARY CARE PROVIDER",1:"")
 Q