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

BJPNVFIL.m

Go to the documentation of this file.
BJPNVFIL ;GDIT/HS/BEE-Prenatal Care Module V OB Handling ; 08 May 2012  12:00 PM
 ;;2.0;PRENATAL CARE MODULE;;Feb 24, 2015;Build 63
 ;
 Q
 ;
VFILE(PLIEN,VFILE) ;EP - Log V OB Entry
 ;
 ;Input Parameters:
 ; PLIEN - Pointer to #90680.01
 ; VFILE("DFN") - Pointer to #9000001
 ; VFILE("VIEN") - Pointer to #9000010
 ; VFILE("POV") - Used as POV (Y)
 ; VFILE("PRIORITY") - Priority (L/M/H)
 ; VFILE("PTEXT") - Pointer to #9999999.27
 ; VFILE("SCOPE") - Scope (A/C)
 ; VFILE("STATUS") - Status (A/I)
 ; VFILE("DEDD") - Definitive EDD
 ; VFILE("NOTE") - Single Note
 ; VFILE("TNOTE") - Technical Note Header
 ; VFILE("TNOTE",fien) - Technical Notes - fields changed
 ; VFILE("OEDT") - Original Entry Date
 ; VFILE("OEBY") - Original Entry By
 ; VFILE("LMDT") - Last Modified Date
 ; VFILE("LMBY") - Last Modified By
 ; VFILE("DEBY") - Deleted By
 ; VFILE("DEDT") - Deleted Dt
 ; VFILE("DECD") - Deleted Code
 ; VFILE("DERN") - Deleted Reason
 ;
 NEW DFN,DIC,DLAYGO,X,Y,PPROV,BJPNLM,BJPNUPD,ERROR,EVDT,OEDATA,PNARR
 NEW DIK,DA,VPIEN,VNIEN,VIEN,SNPTR
 ;
 S DIC="^AUPNVOB("
 S DLAYGO=9000010.43,DIC("P")=DLAYGO,DIC(0)="LOX"
 S X=PLIEN
 K DO,DD D FILE^DICN
 S VPIEN=+Y
 S VIEN=$G(VFILE("VIEN"))
 ;
 ;Pull DFN
 S DFN=$G(VFILE("DFN"))
 ;
 ;Pull OE Into
 S OEDATA=$$OEDATA(DFN,PLIEN)
 I $G(VFILE("OEDT"))="" D
 . S VFILE("OEDT")=$P(OEDATA,U)
 . S VFILE("OEBY")=$P(OEDATA,U,2)
 ;
 ;.02 PATIENT NAME
 S BJPNUPD(9000010.43,VPIEN_",",".02")=VFILE("DFN")
 ;
 ;.03 VISIT
 S BJPNUPD(9000010.43,VPIEN_",",".03")=VFILE("VIEN")
 ;
 ;.05 USED AS POV
 I $G(VFILE("POV"))]"" S BJPNUPD(9000010.43,VPIEN_",",".05")=VFILE("POV")
 ;
 ;.06 PRIORITY
 I $G(VFILE("PRIORITY"))]"" S BJPNUPD(9000010.43,VPIEN_",",".06")=VFILE("PRIORITY")
 ;
 ;.07 PROVIDER TEXT
 I $G(VFILE("PTEXT"))]"" S BJPNUPD(9000010.43,VPIEN_",",".07")=VFILE("PTEXT")
 ;
 ;.08 SCOPE
 I $G(VFILE("SCOPE"))]"" S BJPNUPD(9000010.43,VPIEN_",",".08")=VFILE("SCOPE")
 ;
 ;.09 STATUS
 I $G(VFILE("STATUS"))]"" S BJPNUPD(9000010.43,VPIEN_",",".09")=VFILE("STATUS")
 ;
 ;.1 DEFINITIVE EDD
 I $G(VFILE("DEDD"))]"" S BJPNUPD(9000010.43,VPIEN_",",".1")=VFILE("DEDD")
 ;
 ;.11 PROVIDER NARRATIVE
 S PNARR="" D
 . NEW PTEXT,DIC,DLAYGO,X,Y
 . S PTEXT="" I $G(VFILE("PTEXT"))]"" S PTEXT=$$GET1^DIQ(9999999.27,VFILE("PTEXT")_",",.01,"E")
 . S PNARR=$$GET1^DIQ(90680.01,PLIEN_",",.03,"I")
 . S PNARR=$$GET1^DIQ(90680.02,PNARR_",",.02,"E")
 . S PNARR=PNARR_"| "_PTEXT
 . S DIC(0)="LX",DIC="^AUTNPOV(",DLAYGO=9999999.27,X=PNARR
 . D ^DIC
 . S PNARR=+Y
 ;S DIC("DR")=DIC("DR")_";.11////"_PNARR
 S BJPNUPD(9000010.43,VPIEN_",",".11")=PNARR
 ;
 ;.12 SNOMED TERM
 S SNPTR=$$GET1^DIQ(90680.01,PLIEN_",",.03,"I")
 S BJPNUPD(9000010.43,VPIEN_",",".12")=SNPTR
 ;
 ;1201 EVENT DATE AND TIME
 S EVDT=$$GET1^DIQ(9000010,VFILE("VIEN")_",",.01,"I")
 I EVDT]"" S BJPNUPD(9000010.43,VPIEN_",","1201")=EVDT
 ;
 ;Ordering Provider
 ;S PPROV=$$PPRV^BJPNPKL(VIEN)
 ;I PPROV]"" S BJPNUPD(9000010.43,VPIEN_",","1202")=PPROV
 ;
 ;1204 ENCOUNTER PROVIDER
 S BJPNUPD(9000010.43,VPIEN_",","1204")=DUZ ;Set to current user
 ;
 ;1216 DATE/TIME ENTERED
 I $G(VFILE("OEDT"))]"" S BJPNUPD(9000010.43,VPIEN_",","1216")=VFILE("OEDT")
 ;
 ;1217 ENTERED BY
 I $G(VFILE("OEBY"))]"" S BJPNUPD(9000010.43,VPIEN_",","1217")=VFILE("OEBY")
 ;
 ;2.01 PROBLEM DELETED  BY
 I $G(VFILE("DEBY"))]"" S BJPNUPD(9000010.43,VPIEN_",",2.01)=VFILE("DEBY")
 ;
 ;2.02 DATE/TIME PROBLEM DELETED
 I $G(VFILE("DEDT"))]"" S BJPNUPD(9000010.43,VPIEN_",",2.02)=VFILE("DEDT")
 ;
 ;2.03 REASON PROBLEM DELETED
 I $G(VFILE("DECD"))]"" S BJPNUPD(9000010.43,VPIEN_",",2.03)=VFILE("DECD")
 ;
 ;2.04 DELETE REASON IF OTHER
 I $G(VFILE("DERN"))]"" S BJPNUPD(9000010.43,VPIEN_",",2.04)=VFILE("DERN")
 ;
 I $D(BJPNUPD) D FILE^DIE("","BJPNUPD","ERROR")
 I $D(ERROR) Q "-1^^V OB FILE SAVE FAILED"
 ;
 ;File last modified dt/by separately - Avoid duplicate index issue
 ;
 ;1218 DATE/TIME LAST MODIFIED
 I $G(VFILE("LMDT"))]"" S BJPNLM(9000010.43,VPIEN_",","1218")=VFILE("LMDT")
 ;
 ;1219 LAST MODIFIED BY
 I $G(VFILE("LMDY"))]"" S BJPNLM(9000010.43,VPIEN_",","1219")=VFILE("LMBY")
 ;
 I $D(BJPNLM) D FILE^DIE("","BJPNLM","ERROR")
 I $D(ERROR) Q "-1^^V OB FILE SAVE FAILED"
 ;
 ;File Note
 I $G(VFILE("NOTE"))]"" S VNIEN=$$ANOTE^BJPNPRUT(VPIEN,VFILE("NOTE")) D  I VNIEN=-1 Q "-1^^V OB NOTE SAVE FAILED"
 . Q:VNIEN=-1
 . I $G(VNIEN)]"" S VFILE("TNOTE",2100)=VNIEN
 ;
 ;2200 TECHNICAL COMMENT
 I $D(VFILE("TNOTE")) D TNOTE(VPIEN,.VFILE)
 ;
 ;Reindex this entry
 S DIK="^AUPNVOB(",DA=VPIEN D IX^DIK
 ;
 Q VPIEN
 ;
TNOTE(VPIEN,VFL) ;EP - File TNOTES
 ;
 I $G(VPIEN)="" Q
 ;
 NEW HDR,FLD
 ;
 ;Look for header first
 S HDR=$G(VFL("TNOTE")) I HDR]"" D
 . NEW DA,DIC,DLAYGO,X,Y
 . S DIC="^AUPNVOB("_VPIEN_",22,",DA(1)=VPIEN
 . S DLAYGO=9000010.4311,DIC("P")=DLAYGO,DIC(0)="LOX"
 . S X="C"
 . S DIC("DR")=".02////"_HDR
 . K DO,DD D FILE^DICN
 ;
 ;Save other modified entries
 S FLD="" F  S FLD=$O(VFL("TNOTE",FLD)) Q:FLD=""  D
 . I (FLD="1.01")!(FLD="1.02")!(FLD="1.03")!(FLD="1.4") Q
 . NEW DA,DIC,DLAYGO,X,Y
 . S DIC="^AUPNVOB("_VPIEN_",22,",DA(1)=VPIEN
 . S DLAYGO=9000010.4311,DIC("P")=DLAYGO,DIC(0)="LOX"
 . S X="F"
 . S DIC("DR")=".02////"_FLD_$S(FLD=2100:":"_VFL("TNOTE",FLD),1:"")
 . K DO,DD D FILE^DICN
 ;
 ;Save last modified fields
 F FLD=1.01,1.02,1.03,1.04 I $D(VFL("TNOTE",FLD)) D
 . NEW DA,DIC,DLAYGO,X,Y
 . S DIC="^AUPNVOB("_VPIEN_",22,",DA(1)=VPIEN
 . S DLAYGO=9000010.4311,DIC("P")=DLAYGO,DIC(0)="LOX"
 . S X="F"
 . S DIC("DR")=".02////"_FLD
 . K DO,DD D FILE^DICN
 ;
 Q
 ;
OEDATA(DFN,PLIEN) ;EP - Retrieve Original Entry information for problem
 ;
 I $G(DFN)="" Q ""
 I $G(PLIEN)="" Q ""
 ;
 NEW VN,VFIEN,OEDT,OEBY
 S (OEDT,OEBY,VN)="" F  S VN=$O(^AUPNVOB("AA",DFN,PLIEN,VN)) Q:VN=""  D
 . S VFIEN="" F  S VFIEN=$O(^AUPNVOB("AA",DFN,PLIEN,VN,VFIEN)) Q:VFIEN=""  D
 .. NEW CRDT
 .. S CRDT=$$GET1^DIQ(9000010.43,VFIEN_",",1216,"I") Q:CRDT=""
 .. I OEDT]"",CRDT>OEDT Q
 .. S OEDT=CRDT
 .. S OEBY=$$GET1^DIQ(9000010.43,VFIEN_",",1217,"I")
 ;
 Q OEDT_U_OEBY
 ;
VFADD(APCDPIP,APCDVSIT) ;EP - Add placeholder entry to V OB file
 ;
 ;This function adds a basic entry into the V OB file which is then updated
 ;by the [APCDALVR 9000010.43 (ADD)] Template
 ;
 NEW DFN,DIC,DLAYGO,X,Y
 ;
 I $G(APCDPIP)="" Q ""
 I $G(APCDVSIT)="" Q ""
 ;
 S DIC="^AUPNVOB(",DLAYGO=9000010.43,DIC("P")=DLAYGO,DIC(0)="LOX"
 S X=$G(APCDPIP)
 S DFN=$$GET1^DIQ(9000010,APCDVSIT_",",".05","I")
 S DIC("DR")=".02////"_DFN_";.03////"_APCDVSIT
 K DO,DD D FILE^DICN
 S Y=$S(+Y>0:+Y,1:"")
 Q Y
 ;
PNARR(NARR) ;EP - Save new PROVIDER NARRATIVE (#9999999.27) entry
 ;
 I $G(NARR)="" Q ""
 ;
 NEW DIC,DLAYGO,X,Y
 ;
 S DIC(0)="LX",DIC="^AUTNPOV(",DLAYGO=9999999.27,X=NARR
 D ^DIC
 Q $S(+Y<0:"",1:+Y)