BJPNAPI ;GDIT/HS/BEE-Prenatal Care Module API Calls ; 08 May 2012 12:00 PM
;;2.0;PRENATAL CARE MODULE;**8**;Feb 24, 2015;Build 25
;
Q
;
PIPA(TARGET,DFN,PARM) ;PEP - Returns PIPA - Active All Notes
;
;This API returns all Active problems on the prenatal PIP for a patient. For
;each problem entry, ALL ACTIVE goals and Care Plans and ALL Visit Instructions associated
;with that problem will be returned (even if outside of the current pregnancy window).
;
;Input:
; DFN - Patient IEN
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
;Reset output
K @TARGET
;
Q $$PIP^BJPNAPI2(TARGET,$G(DFN),"A","","","","",$G(PARM),1)
;
PIPN(TARGET,DFN,PARM) ;PEP - Returns PIPN - Active/Inactive All Notes
;
;This API returns all Active and Inactive problems on the prenatal PIP for a patient. For
;each problem entry, ALL ACTIVE and INACTIVE goals and Care Plans, and ALL Visit Instructions associated
;with that problem will be returned.
;
;Input:
; DFN - Patient IEN
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
;Reset output
K @TARGET
;
Q $$PIP^BJPNAPI2(TARGET,$G(DFN),"A",1,"","","",$G(PARM))
;
PIPC(TARGET,DFN,PARM) ;PEP - Returns PIPC - Active All Current Notes
;
;This API returns all Active problems on the prenatal PIP for a patient. For
;each problem entry, ALL ACTIVE goals, Care Plans, and Visit Instructions associated
;with that problem FOR THE CURRENT PREGNANCY WINDOW will be returned.
;
;Input:
; DFN - Patient IEN
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
;Reset output
K @TARGET
;
Q $$PIP^BJPNAPI2(TARGET,$G(DFN),"C","","","","",$G(PARM))
;
VPOV(TARGET,DFN,VIEN,PARM) ;PEP - Returns VPOV - Returns POV Active Problems for visit (just VI notes)
;
;This API returns all active and inactive problems on a patients PIP that were selected as a POV
;for the specified visit. Only associated visit instructions are returned.
;
;Input:
; DFN - Patient IEN
; VIEN - Visit IEN - If not passed in, attempt to pull from CONTEXT
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed
;
;Reset output
K @TARGET
;
S VIEN=$G(VIEN)
I $G(DFN)="" S @TARGET@(1,0)="Invalid DFN" Q "~@"_$NA(@TARGET)
;
;Pull visit from context
I VIEN="" D I VIEN="" Q "~@"_$NA(@TARGET)
. NEW VST,X
. I $T(GETVAR^CIAVMEVT)="" S @TARGET@(1,0)="Invalid context variables" Q
. S VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
. I VST="" S @TARGET@(1,0)="Invalid visit" Q
. S X="BEHOENCX" X ^%ZOSF("TEST")
. I $T S VST=+$$VSTR2VIS^BEHOENCX(DFN,VST) I VST<1 S @TARGET@(1,0)="Invalid visit" Q
. S VIEN=VST
;
Q $$PIP^BJPNAPI2(TARGET,$G(DFN),"A",1,$G(VIEN),1,"",$G(PARM))
;
APOV(TARGET,DFN,VIEN,PARM) ;PEP - Returns VPOV - Returns POV Active Problems for visit (all notes)
;
;This API returns all problems on a patients PIP that were selected as a POV
;for the specified visit. Only associated visit instructions as well as all active
;care plans and goals are returned.
;
;Input:
; DFN - Patient IEN
; VIEN - Visit IEN - If not passed in, attempt to pull from CONTEXT
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
;Reset output
K @TARGET
;
I $G(DFN)="" S @TARGET@(1,0)="Invalid DFN" Q "~@"_$NA(@TARGET)
S VIEN=$G(VIEN)
;
;Pull visit from context
I VIEN="" D I VIEN="" Q "~@"_$NA(@TARGET)
. NEW VST,X
. I $T(GETVAR^CIAVMEVT)="" S @TARGET@(1,0)="Invalid context variables" Q
. S VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
. I VST="" S @TARGET@(1,0)="Invalid visit" Q
. S X="BEHOENCX" X ^%ZOSF("TEST")
. I $T S VST=+$$VSTR2VIS^BEHOENCX(DFN,VST) I VST<1 S @TARGET@(1,0)="Invalid visit" Q
. S VIEN=VST
;
Q $$PIP^BJPNAPI2(TARGET,$G(DFN),"A",1,$G(VIEN),"","",$G(PARM))
;
APIP(TARGET,DFN,TYPE,ASTS,PARM) ;PEP - Returns Prenatal PIP Entry Information
;
;Input:
; DFN - Patient IEN
; TYPE - "C" - Returns list of ALL ACTIVE problem entries on the PIP.
; For each problem entry, returns any notes for each entry
; entered within the date range for the current pregnancy.
; "A" - Returns list of ALL ACTIVE problem entries on the PIP.
; For each problem entry, returns ALL notes for each entry,
; regardless of whether they apply to the current pregnancy
; or to prior pregnancies.
; ASTS - All Statuses (Optional) - If 1, return both Active and Inactive
; Problems. Otherwise, just return
; Active problems.
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
;Reset output
K @TARGET
;
;Input validation
S ASTS=$G(ASTS)
S PARM=$G(PARM)
I $G(DFN)="" S @TARGET@(1,0)="Invalid DFN" Q "~@"_$NA(@TARGET)
I $G(TYPE)="" S @TARGET@(1,0)="Invalid TYPE" Q "~@"_$NA(@TARGET)
I (",C,A,")'[TYPE D Q "~@"_$NA(@TARGET)
. S @TARGET@(1,0)="Invalid TYPE - Must be C or A"
S VIEN=$G(VIEN) I VIEN]"",$$GET1^DIQ(9000010,VIEN_",",.01,"I")="" D Q "~@"_$NA(@TARGET)
. S @TARGET@(1,0)="Invalid VIEN"
;
NEW II,CNT,RESULT,PRBIEN,PCNT,SPACE,TMP,UID,NEDT
;
;Define task id
S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
;
;Definitive EDD date range check
D GETPAR^CIAVMRPC(.NEDT,"BJPN POST DEDD DAYS","SYS",1,"I","")
;
;If blank default to 70
I +$G(NEDT)<1 S NEDT=70
;
;Call EHR API and format results into usable data
D COMP^BJPNUTIL(DFN,UID,VIEN)
S TMP=$NA(^TMP("BJPNIPL",UID)) ;Define compiled data reference
;
;Loop through PIP - Process each entry
S PRBIEN="",II=0,PCNT=0 F S PRBIEN=$O(^BJPNPL("F",DFN,PRBIEN)) Q:PRBIEN="" D
. NEW BPIEN,LINE
. S BPIEN="" F S BPIEN=$O(^BJPNPL("F",DFN,PRBIEN,BPIEN)) Q:BPIEN="" D PROC^BJPNAPI1(PRBIEN,BPIEN,ASTS,PARM,PCNT,.II,TYPE,TMP,.RESULT)
;
;Clear out scratch global
K ^TMP("BJPNPRL",$J)
;
;Define Output
S (II,CNT)=0 F S II=$O(RESULT(II)) Q:'II D
.S CNT=CNT+1
.S @TARGET@(CNT,0)=RESULT(II)
I 'CNT S @TARGET@(1,0)="No Active Problems for Current Pregnanacy"
Q "~@"_$NA(@TARGET)
;
LPIP(TARGET,DFN,LNOTE,PARM) ;PEP - Returns Prenatal Problems for LATEST prenatal visit
;
;Returns a list of all prenatal problem entries on the PIP that were used
;as the POV for the LATEST (most recent) prenatal visit for the patient. For
;each entry, displays the visit instructions entered for that visit (or the
;latest visit instruction entered - see LNOTE)
;
;Input:
; DFN - Patient IEN
; LNOTE (optional) - If 1, for each POV problem for the visit, pull the latest
; visit instruction entered. If none were entered for the
; visit, look back to previous visit(s) to get the last one
; and return it.
; If not 1, do not look to get the latest visit instruction
; from the previous visit(s) if the current visit didn't have
; any.
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
NEW VIEN,X,PRBIEN,RLIST,PBLIST
;
;Reset output
K @TARGET
;
S LNOTE=$G(LNOTE)
I $G(DFN)="" S @TARGET@(1,0)="Invalid DFN" Q "~@"_$NA(@TARGET)
;
;Get ordered list of prenatal visits
D PVST(DFN,.ORLIST,.PBLIST)
;
;Get current visit
S VIEN=$G(ORLIST(1))
I VIEN="" S @TARGET@(1,0)="Could not find Prenatal Visit" Q "~@"_$NA(@TARGET)
;
Q $$PIP^BJPNAPI2(TARGET,$G(DFN),"A",1,$G(VIEN),1,$G(LNOTE),$G(PARM))
;
;Get list of prenatal visits
PVST(DFN,ORLIST,PBLIST) ;Return list of prenatal POV visits and problems for patient
;
;This function returns a list of patient visits that have a POV that points to a
;problem on the patient's PIP
;
;Input
; DFN - Patient IEN
;
;Output
; ORLIST(#) - Array of visits, ranked newest to oldest
;
NEW PRBIEN,INVTM,ORD,DPLIST
;
;Loop through prenatal PIP problems and assemble list of associated IPL entries
S PRBIEN="" F S PRBIEN=$O(^BJPNPL("F",DFN,PRBIEN)) Q:PRBIEN="" D
. NEW BPIEN
. S BPIEN="" F S BPIEN=$O(^BJPNPL("F",DFN,PRBIEN,BPIEN)) Q:BPIEN="" D
.. NEW DEL
.. ;
.. ;Skip deletes
.. S DEL=$$GET1^DIQ(90680.01,PRBIEN_",",2.01,"I") Q:DEL]"" ;PIP Delete
.. S DEL=$$GET1^DIQ(9000011,PRBIEN_",",2.02,"I") Q:DEL]"" ;IPL Delete
.. ;
.. ;Add entry to list
.. S PBLIST(PRBIEN)=BPIEN
;
;Now loop through the V POV and find the last V POV entry for a PIP problem
S INVTM="",ORD=0 F S INVTM=$O(^AUPNVPOV("AA",DFN,INVTM)) Q:INVTM="" D
. NEW VPVIEN
. S VPVIEN="" F S VPVIEN=$O(^AUPNVPOV("AA",DFN,INVTM,VPVIEN),-1) Q:VPVIEN="" D
.. NEW PRBIEN,VIEN
.. ;
.. ;Get the IPL entry
.. S PRBIEN=$$GET1^DIQ(9000010.07,VPVIEN_",",.16,"I") Q:PRBIEN=""
.. ;
.. ;Quit if not a prenatal problem
.. I '$D(PBLIST(PRBIEN)) Q
.. ;
.. ;Get the VIEN
.. S VIEN=$$GET1^DIQ(9000010.07,VPVIEN_",",.03,"I") Q:VIEN=""
.. Q:$D(DPLIST(VIEN)) ;Quit if visit already filed
.. ;
.. ;Set up the ordered list
.. S ORD=ORD+1,ORLIST(ORD)=VIEN
.. S DPLIST(VIEN)=""
Q
;
VPIP(TARGET,DFN,VIEN,LNOTE,PARM) ;PEP - Returns Prenatal POV Problems for a Visit
;
;Returns a list of all prenatal problem entries on the PIP that were used
;as the POV for the specified visit. For each entry, displays the visit instructions
;entered for that visit (or the latest visit instruction entered - see LNOTE).
;
;Input:
; DFN - Patient IEN
; VIEN (optional) - Visit IEN - If blank VIEN is pulled from Context
; LNOTE (optional) - If 1, for each POV problem for the visit, pull the latest
; visit instruction entered. If none were entered for the
; visit, look back to previous visit(s) to get the last one
; and return it.
; If not 1, do not look to get the latest visit instruction
; from the previous visit(s) if the current visit didn't have
; any.
; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
; - 'V' - Do NOT display the date beside visit instructions/OB Notes
; - 'P' - Do NOT display the date entered for the problem
; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
; - 'O' - Include OB Notes
; - So as an example, passing "VP" would not display either date listed, but the hyphen
; would still display
;
;Reset output
K @TARGET
;
;Input validation
S LNOTE=$G(LNOTE)
I $G(DFN)="" S @TARGET@(1,0)="Invalid DFN" Q "~@"_$NA(@TARGET)
S VIEN=$G(VIEN) I VIEN]"",$$GET1^DIQ(9000010,VIEN_",",.01,"I")="" D Q "~@"_$NA(@TARGET)
. S @TARGET@(1,0)="Invalid VIEN"
;
NEW II,CNT,RESULT,VFIEN,PCNT,SPACE,PARY,X,TMP,UID,TMP,PBLIST,ORLIST,PRBIEN
;
;Pull visit from context
I VIEN="" D I VIEN="" Q "~@"_$NA(@TARGET)
. NEW VST,X
. I $T(GETVAR^CIAVMEVT)="" S @TARGET@(1,0)="Invalid context variables" Q
. S VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
. I VST="" S @TARGET@(1,0)="Invalid visit" Q
. S X="BEHOENCX" X ^%ZOSF("TEST")
. I $T S VST=+$$VSTR2VIS^BEHOENCX(DFN,VST) I VST<1 S @TARGET@(1,0)="Invalid visit" Q
. S VIEN=VST
;
;Get the prenatal problems and visit
;
I VIEN="" S @TARGET@(1,0)="No Visit Identified" Q "~@"_$NA(@TARGET)
;
Q $$PIP^BJPNAPI2(TARGET,DFN,"A",1,VIEN,1,LNOTE,$G(PARM))
BJPNAPI ;GDIT/HS/BEE-Prenatal Care Module API Calls ; 08 May 2012 12:00 PM
+1 ;;2.0;PRENATAL CARE MODULE;**8**;Feb 24, 2015;Build 25
+2 ;
+3 QUIT
+4 ;
PIPA(TARGET,DFN,PARM) ;PEP - Returns PIPA - Active All Notes
+1 ;
+2 ;This API returns all Active problems on the prenatal PIP for a patient. For
+3 ;each problem entry, ALL ACTIVE goals and Care Plans and ALL Visit Instructions associated
+4 ;with that problem will be returned (even if outside of the current pregnancy window).
+5 ;
+6 ;Input:
+7 ; DFN - Patient IEN
+8 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+9 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+10 ; - 'P' - Do NOT display the date entered for the problem
+11 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+12 ; - 'O' - Include OB Notes
+13 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+14 ; would still display
+15 ;
+16 ;Reset output
+17 KILL @TARGET
+18 ;
+19 QUIT $$PIP^BJPNAPI2(TARGET,$GET(DFN),"A","","","","",$GET(PARM),1)
+20 ;
PIPN(TARGET,DFN,PARM) ;PEP - Returns PIPN - Active/Inactive All Notes
+1 ;
+2 ;This API returns all Active and Inactive problems on the prenatal PIP for a patient. For
+3 ;each problem entry, ALL ACTIVE and INACTIVE goals and Care Plans, and ALL Visit Instructions associated
+4 ;with that problem will be returned.
+5 ;
+6 ;Input:
+7 ; DFN - Patient IEN
+8 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+9 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+10 ; - 'P' - Do NOT display the date entered for the problem
+11 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+12 ; - 'O' - Include OB Notes
+13 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+14 ; would still display
+15 ;
+16 ;Reset output
+17 KILL @TARGET
+18 ;
+19 QUIT $$PIP^BJPNAPI2(TARGET,$GET(DFN),"A",1,"","","",$GET(PARM))
+20 ;
PIPC(TARGET,DFN,PARM) ;PEP - Returns PIPC - Active All Current Notes
+1 ;
+2 ;This API returns all Active problems on the prenatal PIP for a patient. For
+3 ;each problem entry, ALL ACTIVE goals, Care Plans, and Visit Instructions associated
+4 ;with that problem FOR THE CURRENT PREGNANCY WINDOW will be returned.
+5 ;
+6 ;Input:
+7 ; DFN - Patient IEN
+8 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+9 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+10 ; - 'P' - Do NOT display the date entered for the problem
+11 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+12 ; - 'O' - Include OB Notes
+13 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+14 ; would still display
+15 ;
+16 ;Reset output
+17 KILL @TARGET
+18 ;
+19 QUIT $$PIP^BJPNAPI2(TARGET,$GET(DFN),"C","","","","",$GET(PARM))
+20 ;
VPOV(TARGET,DFN,VIEN,PARM) ;PEP - Returns VPOV - Returns POV Active Problems for visit (just VI notes)
+1 ;
+2 ;This API returns all active and inactive problems on a patients PIP that were selected as a POV
+3 ;for the specified visit. Only associated visit instructions are returned.
+4 ;
+5 ;Input:
+6 ; DFN - Patient IEN
+7 ; VIEN - Visit IEN - If not passed in, attempt to pull from CONTEXT
+8 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+9 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+10 ; - 'P' - Do NOT display the date entered for the problem
+11 ; - 'O' - Include OB Notes
+12 ; - So as an example, passing "VP" would not display either date listed
+13 ;
+14 ;Reset output
+15 KILL @TARGET
+16 ;
+17 SET VIEN=$GET(VIEN)
+18 IF $GET(DFN)=""
SET @TARGET@(1,0)="Invalid DFN"
QUIT "~@"_$NAME(@TARGET)
+19 ;
+20 ;Pull visit from context
+21 IF VIEN=""
Begin DoDot:1
+22 NEW VST,X
+23 IF $TEXT(GETVAR^CIAVMEVT)=""
SET @TARGET@(1,0)="Invalid context variables"
QUIT
+24 SET VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
+25 IF VST=""
SET @TARGET@(1,0)="Invalid visit"
QUIT
+26 SET X="BEHOENCX"
XECUTE ^%ZOSF("TEST")
+27 IF $TEST
SET VST=+$$VSTR2VIS^BEHOENCX(DFN,VST)
IF VST<1
SET @TARGET@(1,0)="Invalid visit"
QUIT
+28 SET VIEN=VST
End DoDot:1
IF VIEN=""
QUIT "~@"_$NAME(@TARGET)
+29 ;
+30 QUIT $$PIP^BJPNAPI2(TARGET,$GET(DFN),"A",1,$GET(VIEN),1,"",$GET(PARM))
+31 ;
APOV(TARGET,DFN,VIEN,PARM) ;PEP - Returns VPOV - Returns POV Active Problems for visit (all notes)
+1 ;
+2 ;This API returns all problems on a patients PIP that were selected as a POV
+3 ;for the specified visit. Only associated visit instructions as well as all active
+4 ;care plans and goals are returned.
+5 ;
+6 ;Input:
+7 ; DFN - Patient IEN
+8 ; VIEN - Visit IEN - If not passed in, attempt to pull from CONTEXT
+9 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+10 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+11 ; - 'P' - Do NOT display the date entered for the problem
+12 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+13 ; - 'O' - Include OB Notes
+14 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+15 ; would still display
+16 ;
+17 ;Reset output
+18 KILL @TARGET
+19 ;
+20 IF $GET(DFN)=""
SET @TARGET@(1,0)="Invalid DFN"
QUIT "~@"_$NAME(@TARGET)
+21 SET VIEN=$GET(VIEN)
+22 ;
+23 ;Pull visit from context
+24 IF VIEN=""
Begin DoDot:1
+25 NEW VST,X
+26 IF $TEXT(GETVAR^CIAVMEVT)=""
SET @TARGET@(1,0)="Invalid context variables"
QUIT
+27 SET VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
+28 IF VST=""
SET @TARGET@(1,0)="Invalid visit"
QUIT
+29 SET X="BEHOENCX"
XECUTE ^%ZOSF("TEST")
+30 IF $TEST
SET VST=+$$VSTR2VIS^BEHOENCX(DFN,VST)
IF VST<1
SET @TARGET@(1,0)="Invalid visit"
QUIT
+31 SET VIEN=VST
End DoDot:1
IF VIEN=""
QUIT "~@"_$NAME(@TARGET)
+32 ;
+33 QUIT $$PIP^BJPNAPI2(TARGET,$GET(DFN),"A",1,$GET(VIEN),"","",$GET(PARM))
+34 ;
APIP(TARGET,DFN,TYPE,ASTS,PARM) ;PEP - Returns Prenatal PIP Entry Information
+1 ;
+2 ;Input:
+3 ; DFN - Patient IEN
+4 ; TYPE - "C" - Returns list of ALL ACTIVE problem entries on the PIP.
+5 ; For each problem entry, returns any notes for each entry
+6 ; entered within the date range for the current pregnancy.
+7 ; "A" - Returns list of ALL ACTIVE problem entries on the PIP.
+8 ; For each problem entry, returns ALL notes for each entry,
+9 ; regardless of whether they apply to the current pregnancy
+10 ; or to prior pregnancies.
+11 ; ASTS - All Statuses (Optional) - If 1, return both Active and Inactive
+12 ; Problems. Otherwise, just return
+13 ; Active problems.
+14 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+15 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+16 ; - 'P' - Do NOT display the date entered for the problem
+17 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+18 ; - 'O' - Include OB Notes
+19 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+20 ; would still display
+21 ;
+22 ;Reset output
+23 KILL @TARGET
+24 ;
+25 ;Input validation
+26 SET ASTS=$GET(ASTS)
+27 SET PARM=$GET(PARM)
+28 IF $GET(DFN)=""
SET @TARGET@(1,0)="Invalid DFN"
QUIT "~@"_$NAME(@TARGET)
+29 IF $GET(TYPE)=""
SET @TARGET@(1,0)="Invalid TYPE"
QUIT "~@"_$NAME(@TARGET)
+30 IF (",C,A,")'[TYPE
Begin DoDot:1
+31 SET @TARGET@(1,0)="Invalid TYPE - Must be C or A"
End DoDot:1
QUIT "~@"_$NAME(@TARGET)
+32 SET VIEN=$GET(VIEN)
IF VIEN]""
IF $$GET1^DIQ(9000010,VIEN_",",.01,"I")=""
Begin DoDot:1
+33 SET @TARGET@(1,0)="Invalid VIEN"
End DoDot:1
QUIT "~@"_$NAME(@TARGET)
+34 ;
+35 NEW II,CNT,RESULT,PRBIEN,PCNT,SPACE,TMP,UID,NEDT
+36 ;
+37 ;Define task id
+38 SET UID=$SELECT($GET(ZTSK):"Z"_ZTSK,1:$JOB)
+39 ;
+40 ;Definitive EDD date range check
+41 DO GETPAR^CIAVMRPC(.NEDT,"BJPN POST DEDD DAYS","SYS",1,"I","")
+42 ;
+43 ;If blank default to 70
+44 IF +$GET(NEDT)<1
SET NEDT=70
+45 ;
+46 ;Call EHR API and format results into usable data
+47 DO COMP^BJPNUTIL(DFN,UID,VIEN)
+48 ;Define compiled data reference
SET TMP=$NAME(^TMP("BJPNIPL",UID))
+49 ;
+50 ;Loop through PIP - Process each entry
+51 SET PRBIEN=""
SET II=0
SET PCNT=0
FOR
SET PRBIEN=$ORDER(^BJPNPL("F",DFN,PRBIEN))
IF PRBIEN=""
QUIT
Begin DoDot:1
+52 NEW BPIEN,LINE
+53 SET BPIEN=""
FOR
SET BPIEN=$ORDER(^BJPNPL("F",DFN,PRBIEN,BPIEN))
IF BPIEN=""
QUIT
DO PROC^BJPNAPI1(PRBIEN,BPIEN,ASTS,PARM,PCNT,.II,TYPE,TMP,.RESULT)
End DoDot:1
+54 ;
+55 ;Clear out scratch global
+56 KILL ^TMP("BJPNPRL",$JOB)
+57 ;
+58 ;Define Output
+59 SET (II,CNT)=0
FOR
SET II=$ORDER(RESULT(II))
IF 'II
QUIT
Begin DoDot:1
+60 SET CNT=CNT+1
+61 SET @TARGET@(CNT,0)=RESULT(II)
End DoDot:1
+62 IF 'CNT
SET @TARGET@(1,0)="No Active Problems for Current Pregnanacy"
+63 QUIT "~@"_$NAME(@TARGET)
+64 ;
LPIP(TARGET,DFN,LNOTE,PARM) ;PEP - Returns Prenatal Problems for LATEST prenatal visit
+1 ;
+2 ;Returns a list of all prenatal problem entries on the PIP that were used
+3 ;as the POV for the LATEST (most recent) prenatal visit for the patient. For
+4 ;each entry, displays the visit instructions entered for that visit (or the
+5 ;latest visit instruction entered - see LNOTE)
+6 ;
+7 ;Input:
+8 ; DFN - Patient IEN
+9 ; LNOTE (optional) - If 1, for each POV problem for the visit, pull the latest
+10 ; visit instruction entered. If none were entered for the
+11 ; visit, look back to previous visit(s) to get the last one
+12 ; and return it.
+13 ; If not 1, do not look to get the latest visit instruction
+14 ; from the previous visit(s) if the current visit didn't have
+15 ; any.
+16 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+17 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+18 ; - 'P' - Do NOT display the date entered for the problem
+19 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+20 ; - 'O' - Include OB Notes
+21 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+22 ; would still display
+23 ;
+24 NEW VIEN,X,PRBIEN,RLIST,PBLIST
+25 ;
+26 ;Reset output
+27 KILL @TARGET
+28 ;
+29 SET LNOTE=$GET(LNOTE)
+30 IF $GET(DFN)=""
SET @TARGET@(1,0)="Invalid DFN"
QUIT "~@"_$NAME(@TARGET)
+31 ;
+32 ;Get ordered list of prenatal visits
+33 DO PVST(DFN,.ORLIST,.PBLIST)
+34 ;
+35 ;Get current visit
+36 SET VIEN=$GET(ORLIST(1))
+37 IF VIEN=""
SET @TARGET@(1,0)="Could not find Prenatal Visit"
QUIT "~@"_$NAME(@TARGET)
+38 ;
+39 QUIT $$PIP^BJPNAPI2(TARGET,$GET(DFN),"A",1,$GET(VIEN),1,$GET(LNOTE),$GET(PARM))
+40 ;
+41 ;Get list of prenatal visits
PVST(DFN,ORLIST,PBLIST) ;Return list of prenatal POV visits and problems for patient
+1 ;
+2 ;This function returns a list of patient visits that have a POV that points to a
+3 ;problem on the patient's PIP
+4 ;
+5 ;Input
+6 ; DFN - Patient IEN
+7 ;
+8 ;Output
+9 ; ORLIST(#) - Array of visits, ranked newest to oldest
+10 ;
+11 NEW PRBIEN,INVTM,ORD,DPLIST
+12 ;
+13 ;Loop through prenatal PIP problems and assemble list of associated IPL entries
+14 SET PRBIEN=""
FOR
SET PRBIEN=$ORDER(^BJPNPL("F",DFN,PRBIEN))
IF PRBIEN=""
QUIT
Begin DoDot:1
+15 NEW BPIEN
+16 SET BPIEN=""
FOR
SET BPIEN=$ORDER(^BJPNPL("F",DFN,PRBIEN,BPIEN))
IF BPIEN=""
QUIT
Begin DoDot:2
+17 NEW DEL
+18 ;
+19 ;Skip deletes
+20 ;PIP Delete
SET DEL=$$GET1^DIQ(90680.01,PRBIEN_",",2.01,"I")
IF DEL]""
QUIT
+21 ;IPL Delete
SET DEL=$$GET1^DIQ(9000011,PRBIEN_",",2.02,"I")
IF DEL]""
QUIT
+22 ;
+23 ;Add entry to list
+24 SET PBLIST(PRBIEN)=BPIEN
End DoDot:2
End DoDot:1
+25 ;
+26 ;Now loop through the V POV and find the last V POV entry for a PIP problem
+27 SET INVTM=""
SET ORD=0
FOR
SET INVTM=$ORDER(^AUPNVPOV("AA",DFN,INVTM))
IF INVTM=""
QUIT
Begin DoDot:1
+28 NEW VPVIEN
+29 SET VPVIEN=""
FOR
SET VPVIEN=$ORDER(^AUPNVPOV("AA",DFN,INVTM,VPVIEN),-1)
IF VPVIEN=""
QUIT
Begin DoDot:2
+30 NEW PRBIEN,VIEN
+31 ;
+32 ;Get the IPL entry
+33 SET PRBIEN=$$GET1^DIQ(9000010.07,VPVIEN_",",.16,"I")
IF PRBIEN=""
QUIT
+34 ;
+35 ;Quit if not a prenatal problem
+36 IF '$DATA(PBLIST(PRBIEN))
QUIT
+37 ;
+38 ;Get the VIEN
+39 SET VIEN=$$GET1^DIQ(9000010.07,VPVIEN_",",.03,"I")
IF VIEN=""
QUIT
+40 ;Quit if visit already filed
IF $DATA(DPLIST(VIEN))
QUIT
+41 ;
+42 ;Set up the ordered list
+43 SET ORD=ORD+1
SET ORLIST(ORD)=VIEN
+44 SET DPLIST(VIEN)=""
End DoDot:2
End DoDot:1
+45 QUIT
+46 ;
VPIP(TARGET,DFN,VIEN,LNOTE,PARM) ;PEP - Returns Prenatal POV Problems for a Visit
+1 ;
+2 ;Returns a list of all prenatal problem entries on the PIP that were used
+3 ;as the POV for the specified visit. For each entry, displays the visit instructions
+4 ;entered for that visit (or the latest visit instruction entered - see LNOTE).
+5 ;
+6 ;Input:
+7 ; DFN - Patient IEN
+8 ; VIEN (optional) - Visit IEN - If blank VIEN is pulled from Context
+9 ; LNOTE (optional) - If 1, for each POV problem for the visit, pull the latest
+10 ; visit instruction entered. If none were entered for the
+11 ; visit, look back to previous visit(s) to get the last one
+12 ; and return it.
+13 ; If not 1, do not look to get the latest visit instruction
+14 ; from the previous visit(s) if the current visit didn't have
+15 ; any.
+16 ; PARM - (Optional) - Formatting parameter which can contain one or more of the following codes
+17 ; - 'V' - Do NOT display the date beside visit instructions/OB Notes
+18 ; - 'P' - Do NOT display the date entered for the problem
+19 ; - 'H' - Do Not display a hyphen next to each care plan, goal, and visit instruction
+20 ; - 'O' - Include OB Notes
+21 ; - So as an example, passing "VP" would not display either date listed, but the hyphen
+22 ; would still display
+23 ;
+24 ;Reset output
+25 KILL @TARGET
+26 ;
+27 ;Input validation
+28 SET LNOTE=$GET(LNOTE)
+29 IF $GET(DFN)=""
SET @TARGET@(1,0)="Invalid DFN"
QUIT "~@"_$NAME(@TARGET)
+30 SET VIEN=$GET(VIEN)
IF VIEN]""
IF $$GET1^DIQ(9000010,VIEN_",",.01,"I")=""
Begin DoDot:1
+31 SET @TARGET@(1,0)="Invalid VIEN"
End DoDot:1
QUIT "~@"_$NAME(@TARGET)
+32 ;
+33 NEW II,CNT,RESULT,VFIEN,PCNT,SPACE,PARY,X,TMP,UID,TMP,PBLIST,ORLIST,PRBIEN
+34 ;
+35 ;Pull visit from context
+36 IF VIEN=""
Begin DoDot:1
+37 NEW VST,X
+38 IF $TEXT(GETVAR^CIAVMEVT)=""
SET @TARGET@(1,0)="Invalid context variables"
QUIT
+39 SET VST=$$GETVAR^CIAVMEVT("ENCOUNTER.ID.ALTERNATEVISITID",,"CONTEXT.ENCOUNTER")
+40 IF VST=""
SET @TARGET@(1,0)="Invalid visit"
QUIT
+41 SET X="BEHOENCX"
XECUTE ^%ZOSF("TEST")
+42 IF $TEST
SET VST=+$$VSTR2VIS^BEHOENCX(DFN,VST)
IF VST<1
SET @TARGET@(1,0)="Invalid visit"
QUIT
+43 SET VIEN=VST
End DoDot:1
IF VIEN=""
QUIT "~@"_$NAME(@TARGET)
+44 ;
+45 ;Get the prenatal problems and visit
+46 ;
+47 IF VIEN=""
SET @TARGET@(1,0)="No Visit Identified"
QUIT "~@"_$NAME(@TARGET)
+48 ;
+49 QUIT $$PIP^BJPNAPI2(TARGET,DFN,"A",1,VIEN,1,LNOTE,$GET(PARM))