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

WVRPCOR2.m

Go to the documentation of this file.
WVRPCOR2 ;ISP/RFR - CPRS RPCS CONTINUED ;Oct 19, 2020@14:42
 ;;1.0;WOMEN'S HEALTH;**24,26**;Sep 30, 1998;Build 624
 Q
SAVEDATA(WVRETURN,WVDATA) ;SAVE DATA FROM COVER SHEET
 ;RPC: WVRPCOR SAVEDATA
 N WVLNCNT,WVDEF,WVIEN,WVNODE,WVFILE,WVPKG,WVTYPES,WVEXTERNAL,WVERROR,WVNPFLAG
 N WVVPR
 ;Convert WVDATA(1..n)="name=value" to WVDATA("name")=value
 D CLEAN(.WVDATA)
 I $G(WVDATA("PATIENT"))'?1.N D ERROR(.WVRETURN,"ROOT") Q
 S WVNPFLAG=$$ISREG^WVUTL11(WVDATA("PATIENT"))
 I '+WVNPFLAG S WVRETURN=-1_U_$P(WVNPFLAG,U,2) Q
 S WVPKG=+$$FIND1^DIC(9.4,,,"ORDER ENTRY/RESULTS REPORTING",,,"WVERROR")
 I $D(WVERROR) S WVRETURN=-1_U_$$FMERROR^WVUTL11(.WVERROR)
 I WVPKG<1 S WVRETURN=-1_U_"Cannot find the ORDER ENTRY/RESULTS REPORTING software package in the PACKAGE file." Q
 S WVVPR("BEFORE")=+$$GETLREC^WVUTL11(WVDATA("PATIENT"),4)_","_WVDATA("PATIENT")_","
 D SETUP^WVRPCOR
 S WVRETURN=1_U
 S WVNODE=0 F  S WVNODE=$O(WVTYPES(WVNODE)) Q:'+WVNODE!(+WVRETURN=-1)  D
 .N WVFDA,WVNOSAVE,WVAPPL
 .S WVIEN="+1,"_WVDATA("PATIENT")_",",WVFILE=$P(WVTYPES(WVNODE),U,2),WVNOSAVE=0
 .F WVLNCNT=2:1 S WVDEF=$P($T(SUBS+WVLNCNT),";;",2) Q:WVDEF="EOF"!(+WVRETURN=-1)!(WVNOSAVE)  D
 ..I '(($P(WVDEF,U,2)=WVNODE)!($P(WVDEF,U,2)="*")) Q
 ..I $P(WVDEF,U,4)'="" X $P(WVDEF,U,4,$L(WVDEF,U)) Q:+WVRETURN=-1!(WVNOSAVE)
 ..I $G(WVDATA($P(WVDEF,U)))'="" S WVFDA(WVFILE,WVIEN,$P(WVDEF,U,3))=WVDATA($P(WVDEF,U))
 .I WVNOSAVE S WVRETURN=-1_U_"Your data was not saved. Please contact the help desk for assistance."
 .Q:+WVRETURN=-1!('$D(WVFDA))
 .S WVFDA(WVFILE,WVIEN,.01)=$$NOW^XLFDT,WVFDA($P(WVTYPES(WVNODE),U,2),WVIEN,3)="`"_WVPKG
 .K WVIEN
 .D UPDATE^DIE("E","WVFDA","WVIEN","WVERROR")
 .I $D(WVERROR) S WVRETURN=-1_U_$$FMERROR^WVUTL11(.WVERROR)
 .I '$D(WVERROR),WVNODE=4 S WVVPR("AFTER")=+$G(WVIEN(1))_","_WVDATA("PATIENT")_","
 D NOTIFY^WVRPCVPR(.WVVPR)
 Q
SUBS ;NAMES OF SUBSCRIPTS THAT SHOULD BE IN THE DATA ARRAY
 ;FORMAT: SUBSCRIPT NAME ^ SUB-SCRIPT NUMBER IN ^WV(790,D0, ^ FIELD NUMBER ^ SAVE CONVERSION/VALIDATION CODE
 ;;ABLE TO CONCEIVE^4^22^D VMAC
 ;;PREGNANCY STATUS^4^21^D VPREG
 ;;MEDICAL REASON^4^23^I $G(WVDATA("MEDICAL REASON"))'="",$G(WVDATA("PREGNANCY STATUS"))'="" D ERROR(.WVRETURN,13) Q
 ;;LAST MENSTRUAL PERIOD DATE^4^41^D VLMP
 ;;EXPECTED DUE DATE^4^42^D VEDD
 ;;LACTATION STATUS^5^21^D VLAC
 ;;EOF
 Q
ERROR(WVRETURN,WVERRNUM) ;POPULATE THE RETURN ARRAY WITH AN ERROR MESSAGE
 N WVTYPE
 S WVRETURN=-1
 I $G(WVNODE)'="" S WVTYPE=$P(WVTYPES(WVNODE),U,3)
 I WVERRNUM="ROOT" D
 .S $P(WVRETURN,U,2)="Invalid patient specified."
 I WVERRNUM=6 D
 .S $P(WVRETURN,U,2)="Medical reason is required when the medically able to conceive value is No."
 I WVERRNUM=7 D
 .S $P(WVRETURN,U,2)="Invalid medically able to conceive value specified: "_$G(WVDATA("ABLE TO CONCEIVE"))_"."
 I WVERRNUM=8 D
 .S $P(WVRETURN,U,2)="Medically able to conceive is required."
 I WVERRNUM=9 D
 .S $P(WVRETURN,U,2)="Invalid "_$$LOW^XLFSTR($G(WVTYPE))_" status specified: "_$G(WVDATA($G(WVTYPE)_" STATUS"))_"."
 I WVERRNUM=10 D
 .S $P(WVRETURN,U,2)="Pregnancy status is required when the patient is medically able to conceive."
 I WVERRNUM=13 D
 .S $P(WVRETURN,U,2)="Do not enter a currently pregnant value when the patient is medically unable to conceive."
 I WVERRNUM=14 D
 .S $P(WVRETURN,U,2)="Only enter the last menstrual period value when the currently pregnant value is Yes."
 I WVERRNUM=16 D
 .S $P(WVRETURN,U,2)="Only enter the expected due date value when the currently pregnant value is Yes."
 Q
VMAC ;VALIDATE/CONVERT MEDICALLY ABLE TO CONCEIVE
 S WVAPPL=$$APPL^WVRPCOR(WVDATA("PATIENT"),WVNODE)
 Q:'$D(WVDATA("ABLE TO CONCEIVE"))
 N WVSTATUS
 S WVSTATUS=$$UP^XLFSTR($G(WVDATA("ABLE TO CONCEIVE"))),WVSTATUS=$S($E(WVSTATUS,1)="Y":"NO",$E(WVSTATUS,1)="N":"YES",1:"")
 I WVSTATUS="" D ERROR(.WVRETURN,7) Q
 I WVSTATUS="YES",$G(WVDATA("MEDICAL REASON"))="" D ERROR(.WVRETURN,6) Q
 S WVDATA("ABLE TO CONCEIVE")=WVSTATUS
 Q
VPREG ;VALIDATE/CONVERT PREGNANCY STATUS
 Q:'$D(WVDATA("PREGNANCY STATUS"))
 I $G(WVDATA("ABLE TO CONCEIVE"))="" D ERROR(.WVRETURN,8) Q
 N WVSTATUS,WVEXIT
 S WVSTATUS=$$UP^XLFSTR($G(WVDATA("PREGNANCY STATUS")))
 I WVSTATUS="" D  Q:+WVRETURN=-1!($G(WVEXIT))
 .I $G(WVDATA("ABLE TO CONCEIVE"))="NO" D ERROR(.WVRETURN,10) Q
 .I $G(WVDATA("ABLE TO CONCEIVE"))="YES" D  Q
 ..S WVEXIT=1
 ..I $D(WVDATA("PREGNANCY STATUS")) K WVDATA("PREGNANCY STATUS")
 S WVSTATUS=$S($E(WVSTATUS,1)="Y":"PREGNANT",$E(WVSTATUS,1)="N":"NOT PREGNANT",$E(WVSTATUS,1)="U":"DO NOT KNOW",1:"")
 I WVSTATUS="" D ERROR(.WVRETURN,9) Q
 I WVSTATUS="PREGNANT" S WVFDA(WVFILE,WVIEN,22)="NO"
 S WVDATA("PREGNANCY STATUS")=WVSTATUS
 Q
VLMP ;VALIDATE LAST MENSTRUAL PERIOD DATE
 Q:'$D(WVDATA("LAST MENSTRUAL PERIOD DATE"))
 I $G(WVDATA("LAST MENSTRUAL PERIOD DATE"))>0,$$UP^XLFSTR($G(WVDATA("PREGNANCY STATUS")))'="PREGNANT" D ERROR(.WVRETURN,14) Q
 I $$UP^XLFSTR($G(WVDATA("PREGNANCY STATUS")))="PREGNANT" D
 .N WVFDA,WVSTAT
 .S WVFDA("DATA",790.05,"+1,"_WVDATA("PATIENT")_",",$P(WVDEF,U,3))=WVDATA("LAST MENSTRUAL PERIOD DATE")
 .D VERDATA^WVRPCPT2(.WVSTAT,.WVFDA)
 .I WVSTAT(0)=-1 S WVRETURN=-1_U_WVSTAT(1)
 Q
VEDD ;VALIDATE EXPECTED DUE DATE
 I $G(WVDATA("EXPECTED DUE DATE"))>0,$$UP^XLFSTR($G(WVDATA("PREGNANCY STATUS")))'="PREGNANT" D ERROR(.WVRETURN,16) Q
 I $$UP^XLFSTR($G(WVDATA("PREGNANCY STATUS")))="PREGNANT" D
 .N WVFDA,WVSTAT
 .S WVFDA("DATA",790.05,"+1,"_WVDATA("PATIENT")_",",$P(WVDEF,U,3))=WVDATA("EXPECTED DUE DATE")
 .D VERDATA^WVRPCPT2(.WVSTAT,.WVFDA)
 .I WVSTAT(0)=-1 S WVRETURN=-1_U_WVSTAT(1)
 Q
VLAC ;VALIDATE LACTATION STATUS
 Q:'$D(WVDATA("LACTATION STATUS"))
 N WVSTATUS
 S WVSTATUS=$$UP^XLFSTR($G(WVDATA("LACTATION STATUS")))
 S WVSTATUS=$S($E(WVSTATUS,1)="Y":"LACTATING",$E(WVSTATUS,1)="N":"NOT LACTATING",1:"")
 I WVSTATUS="" D ERROR(.WVRETURN,9) Q
 S WVDATA("LACTATION STATUS")=WVSTATUS
 Q
CLEAN(WVARRAY) ;UNMANGLE NAME=VALUE PAIRS ARRAY
 N X
 S X=0 F  S X=$O(WVARRAY(X)) Q:'X  S WVARRAY($P(WVARRAY(X),"="))=$P(WVARRAY(X),"=",2,250) K WVARRAY(X)
 Q