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