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

VENPCCKT.m

Go to the documentation of this file.
VENPCCKT ; IHS/OIT/GIS - GUI TRANSACTION MANAGER - PT ED, NUTR AND EXAMS ; 
 ;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
 ;
 ;
 ;
EXPOP(IN) ; EP - POPULATE THE EXAM TOPICS
 N DFN,LINE,CNT,VIEN,DIK,DA,KEY,TYPE,STOP,SS
 K LINE D VAR I '$D(LINE) Q
 S (LINE,CNT)=0
EX1 I LINE="" G EX2
 S STOP=0
 F  S LINE=$O(LINE(LINE)) Q:'LINE  D  I STOP Q  ; GET STARTING LINE FOR EXAM SUBCATEGORY
 . S SS=""
 . I LINE(LINE)="AGE-SPECIFIC EXAMS" S STOP=1,SS=6 Q
 . I LINE(LINE)="GENERAL HEALTH SCREEN" S STOP=1,SS=8 Q
 . I LINE(LINE)="SPECIAL RISK SCREEN" S STOP=1,SS=4 Q
 . I LINE(LINE)="BEHAVIORAL HEALTH SCREEN" S STOP=1,SS=7 Q
 . Q
EX2 I 'LINE!('$G(SS)) D  Q  ; QUIT IF NO MORE EXAM ITEMS EXIST
 . I CNT S OUT="BMX ADO SS^VEN WCM TX^^AC~"_KEY_"~"_KEY_"~9999"
 . D ^XBFMK
 . Q
 D CAT(.LINE,.CNT,3,SS) ; PROCESS EXAM SUBCATEGORY
 G EX1 ; GET NEXT EXAM SUBCATEGORY
 ; 
PEPOP(IN) ; EP - POPULATE NUTR TOPICS OR PT ED TOPICS
 N DFN,LINE,CNT,VIEN,DIK,DA,KEY,TYPE
 D VAR
 S LINE=0,CNT=0
PE1 I LINE="" G PE2
 F  S LINE=$O(LINE(LINE)) Q:'LINE  I $E(LINE(LINE),1,8)="PT ED - " Q  ; GET STARTING LINE FOR A PT ED SUBCATEGORY
PE2 I 'LINE D  Q  ; QUIT IF NO MORE PT ED ITEMS EXIST
 . I CNT S OUT="BMX ADO SS^VEN WCM TX^^AC~"_KEY_"~"_KEY_"~9999"
 . D ^XBFMK
 . Q
 D CAT(.LINE,.CNT,TYPE) ; PROCESS SUBCATEGORY
 G PE1 ; GET NEXT SUB-CATEGORY OF PT ED TOPICS
 ; 
VAR ; EP - SET UP MAIN VARIABLES, CLEANUP TRANSACTION FILE AND CREATE THE RAW DATA ARRAY
 D STALE ; FIRST, CLEAN UP TX FILE BY REMOVING STALE ENTRIES
 S OUT=""
 S VIEN=+$G(IN) I '$D(^AUPNVSIT(VIEN,0)) Q
 S TYPE=$P(IN,"|",2) I '$L(TYPE) Q
 S DFN=+$P($G(^AUPNVSIT(VIEN,0)),U,5) I '$D(^DPT(DFN,0)) Q
 S KEY=VIEN_"_"_TYPE,DIK="^VEN(7.16,",DA=0
 F  S DA=$O(^VEN(7.16,"AC",KEY,DA)) Q:'DA  D ^DIK ; CLEANUP ALL TXS RELATED TO THIS VISIT
 D ARR(DFN,.LINE) ; GET THE RAW ARRAY IN LINE()
 Q
 ; 
CAT(LINE,CNT,TYPE,SS) ; EP - PROCESS A PT ED SUB-CATEGORY AND POPULATE THE TX FILE
 N %,CAT,CIEN,ITEM,DIC,DA,DR,X,Y,Z,%,EDATE,VAL,STG,STOP,CODE,DIK,GBL,IIEN,LAST,KIEN,SEL,RES,IX
VARS I 16[TYPE D
 . S %=$E(LINE(LINE),9,99)
 . S %=$E(%,1,$L(%)-1) I '$L(%) Q
 . S %="WCAG "_%
 . Q
 I TYPE=3 S %="WCEX "_LINE(LINE),%=$E(%,1,$L(%)-1) I '$L(%) Q
 S CAT=$O(^VEN(7.11,"B",%)) I CAT'[% Q
 S CIEN=$O(^VEN(7.11,"B",CAT,0)) I 'CIEN Q
 S STOP=0
 S DIC="^VEN(7.16,",DLAYGO=19707.16,DIC(0)="L"
 S SS=$S(16[TYPE:1,$G(SS):SS,1:"") I 'SS Q  ; SUBSCRIPT FOR FILING RESULTS
LINE F  S LINE=$O(LINE(LINE)) Q:LINE=""  D  I STOP Q  ; PROCESS EACH LINE IN THE ARRAY
IVARS . S STG=LINE(LINE)
 . I $E(STG,1,3)'="__ " S LINE=LINE-1,STOP=1 Q
 . S (IX,ITEM)=$P(STG,". ",2,99) I '$L(ITEM) Q
 . S IIEN=$P(ITEM,"|",2),ITEM=$P(ITEM,"|")
 . S KIEN=+$G(^VEN(7.12,IIEN,0)) I 'KIEN Q
 . I TYPE'=3,$P($G(^VEN(7.11,KIEN,0)),U,11)'=TYPE Q  ; PT ED CATEGORY TYPE MUST MATCH
INIT . S (CODE,SEL,RES,LAST)="" ; INITIALIZE OPTIONAL VARS
CODE . I 16[TYPE S CODE=$P($G(^VEN(7.12,IIEN,2)),U,3) ; PT ED CODE
PAST . S %=$RE(ITEM) ; PARSE LAST DATE/RESULT
 . I TYPE=3,$E(%,1,7)=")LAMRON" D  ; FOR EXAMS, PEEL OFF THE RESULT VALUE
 .. S RES=$P(ITEM," ",$L(ITEM," ")) ; GET DATE OF LAST INSTANCE
 .. S RES=$E(RES)
 .. S %=")"_$P(%," ",2,99)
 .. Q
 . I $E(%,1,4)?1")"2N1"/" D  ; FOR PT ED AND EXAMS, STRIP OFF DATE
 .. S X=$P(%,"( ",2,99),ITEM=$RE(X),IX=$E(ITEM,1,30) ; IX IS THE LOOKUP NAME, ITEM IS THE FULL TEXT
 .. S Y=$P(%,"( "),Y=$E(Y,2,999),LAST=$RE(Y) ; DATE OF LAST ENTRY
 .. Q
 . I $L(LAST) S X=LAST D ^%DT I Y=DT S (LAST,RES)="" ; TODAY'S RESULTS SHOULD ARE "CURRENT", NOT "LAST"
CURRENT . S SEL=$$SEL(DFN,IX,TYPE,$G(SS)) ; GET TODAY'S SELECTION, IF IT EXISTS
DIC . S X=""""_CIEN_""""
 . D ^DIC I Y=-1 Q
 . S DA=+Y,GBL=$NA(^VEN(7.16))
 . S @GBL@(DA,0)=CIEN_U_CAT_U_IIEN_U_ITEM_U_CODE_U_LAST_U_SEL_U_VIEN_U_TYPE_U_KEY_U_RES_U_DT_U_SS ; TX RECORD
 . S @GBL@("AC",KEY,DA)="",@GBL@("AD",DT,DA)="" ; INDEXES
 . S CNT=CNT+1
 . Q
 D ^XBFMK
 Q
 ; 
SEL(DFN,ITEM,TYPE,SS) ; EP - SEE IF THIS ITEM IS ALREADY IN TODAY'S V WELL CHILD RECORD
 N SEL,DA,X,%,IDT
 S SEL="",IDT=9999999-DT
 I $G(ITEM)="" Q ""
 S DA=$O(^AUPNVWC("AA",DFN,IDT,0)) I 'DA Q ""
 I 16[$G(TYPE),$D(^AUPNVWC(DA,1,"B",ITEM)) S SEL=1 Q SEL ; TODAY'S PT ED
 I TYPE=3,$G(SS) D  ; TODAY'S EXAM RESULT
 . S %=$O(^AUPNVWC(DA,SS,"B",ITEM,0)) I '% Q
 . S SEL=$P($G(^AUPNVWC(DA,SS,%,0)),U,2)
 . Q
 Q SEL
 ; 
ARR(DFN,LINE) ; EP - RETURN THE LINE ARRAY USED IN GENERATING THE HEALTH SUMMARY SEGMENT ; 
 N DOB,DAYS,SEX,GUIFLAG
 S LINE=0
 S GUIFLAG=1 ; TELLS THE ARRAY GENERATOR TO PREVENT TODAY'S RESULTS FROM BEING RETURNED AS A "LAST" RESULT
 S DOB=$P($G(^DPT(+DFN,0)),U,3) I 'DOB Q
 S SEX=$P($G(^DPT(+DFN,0)),U,2) I '$L(SEX) Q
 S DAYS=$$FMDIFF^XLFDT(DT,DOB,1) I 'DAYS Q
 D REM^APCHS6B(DFN,-1,SEX,DAYS) ; GET REMINDER LIST FOR EA KB CATEGORY
 Q
 ;
EXFLUSH(IN) ; EP - FLUSH EXAM TXS TO V WELL CHILD
 ; IN = VIEN
 I '$D(^AUPNVSIT(+$G(IN),0)) Q  ; A VALID VISIT MUST EXIST
 N APCDVSIT,AUPNPAT,KEY,TXIEN,STG,X,Y,Z,%,TOT,SS,RES,ARR
 S OUT=""
 S APCDVSIT=+IN ; VISIT IEN
 S KEY=APCDVSIT_"_3" ; LOOKUP KEY
 S AUPNPAT=+$P($G(^AUPNVSIT(APCDVSIT,0)),U,5) I '$D(^DPT(AUPNPAT,0)) Q  ; PATIENT DFN
 S TXIEN=0,TOT=0
 F  S TXIEN=$O(^VEN(7.16,"AC",KEY,TXIEN)) Q:'TXIEN  D  ; BUILD THE RESULTS ARRAY
 . S STG=$G(^VEN(7.16,TXIEN,0))
 . S RES=$P(STG,U,7) I RES="" Q  ; ITEM MUST HAVE A RESULT
 . S SS=$P(STG,U,13) I 'SS Q  ; ITEM MUST HAVE A FILING SUBSCRIPT
 . S TITLE=$P(STG,U,4) I '$L(TITLE) Q  ; MUST HAVE A VALID TITLE
 . S TOT=TOT+1 ; KEEP TRACK OF THE TOT NUMBER OF VALID TITLES ENTERED
 . S ARR(TOT)=TITLE,ARR(TOT,1)=RES
 . Q
 I 'TOT D TXCLEAN Q  ; NOTHING SELECTED, SO CLEAN UP AND QUIT
EXVF D EVWCFILE^VENPCCQC(SS,1) ; FILE EXAMS IN V WC
 D TXCLEAN
 S OUT="OK"
 Q
 ; 
PEFLUSH(IN) ; EP - FLUSH DATA FOR PT ED AND NUTR TRANSACTIONS TO V FILES
 ; IN = TYPE|VISIT IEN|LOU|TIME|EDUCATOR IEN|INFANT FEEDING CHOICE
 I '$L($G(IN)) Q
 N APCDVSIT,AUPNPAT,DA,TXIEN,STG,X,Y,Z,%,TOT,TITLE,CODE,LOU,TIME,EDU,ARR,FTIME,CNT,OK,CIEN,KEY,TYPE,IFC
FVAR ; GET FLUSH VARIABLES
 S OUT=""
 S TYPE=$P(IN,"|") I 'TYPE Q  ; TYPE
 S APCDVSIT=+$P(IN,"|",2) I '$D(^AUPNVSIT(APCDVSIT,0)) Q  ; VISIT IEN
 S KEY=APCDVSIT_"_"_TYPE ; LOOKUP KEY
 S AUPNPAT=+$P($G(^AUPNVSIT(APCDVSIT,0)),U,5) I '$D(^DPT(AUPNPAT,0)) Q  ; PATIENT DFN
 S LOU=$P(IN,"|",3) ; LEVEL OF UNDERSTANDING
 I $L(LOU)>1,"POORFAIRGOODNAREFUSED"[LOU
 E  S LOU=""
 S EDU=$P(IN,"|",5) I '$D(^VA(200,EDU,0)) S EDU="" ; EDUCATOR
FARR ; BUILD THE FLUSH ARRAY
 S TXIEN=0,TOT=0
 F  S TXIEN=$O(^VEN(7.16,"AC",KEY,TXIEN)) Q:'TXIEN  D
 . S STG=$G(^VEN(7.16,TXIEN,0))
 . I '$P(STG,U,7) Q  ; ITEM MUST BE SELECTED
 . S TITLE=$P(STG,U,4) I '$L(TITLE) Q  ; MUST HAVE A VALID TITLE
 . S CODE=$P(STG,U,5) I '$L(CODE) Q
 . S CIEN=$$CODE^VENPCCQC(CODE) I 'CIEN Q  ; CAN'TY FIND A VALID INSTANCE OF THE PT ED CODE, SO QUIT
 . S TOT=TOT+1 ; KEEP TRACK OF THE TOT NUMBER OF VALID TITLES ENTERED
 . S ARR(TOT)=TITLE,ARR(TOT,1)="",ARR("CODE",CODE,TOT)=TITLE,ARR("CAT",CIEN)=""
 . Q
 I 'TOT G TXCLEAN ; NOTHING SELECTED
TIME ; GET EDU TIME AND FRACTIONAL TIME
 S TIME=$P(IN,"|",4) ; TOTAL PATIENT ED TIME
 I TIME=+TIME,TIME=TIME\1,TIME>0,TIME<999 D  I 1 ; VALIDATE TIME
 . I TYPE=6 S FTIME=TIME Q
 . S CIEN=0 F CNT=0:1 S CIEN=$O(ARR("CAT",CIEN)) Q:'CIEN  ; COUNT THE NUMBER OF KB CATEGORIES
 . I CNT S FTIME=TIME\CNT ; FRACTONAL TIME (AVERAGED ACROSS ALL PT ED CATEGORIES)
 . Q
 E  S (FTIME,TIME)=""
VPED ; UPDATE V PAT ED
 D VPEFILE^VENPCCQC(LOU,FTIME,EDU)
VWC ; UPDATE V WELL CHILD
 I TYPE=1 D PEWCFILE^VENPCCQC(LOU,TIME,EDU) S OUT="OK" G TXCLEAN
 I TYPE=6 D NVWCFILE^VENPCCQC(LOU,TIME,EDU)
VIFC S IFC=$P(IN,"|",6) I $L(IFC) D  ; UPDATE V INFANT FEEDING CHOICE
 . S IFC=$$UP^XLFSTR(IFC)
 . S IFC=$S(IFC["EXCLU":1,IFC["LY BR":2,IFC["1/2":3,IFC["LY FO":4,IFC["LA ON":5,1:"")
 . I 'IFC Q
 . S DIC="^AUPNVIF(",DIC(0)="L",DLAYGO=9000010.44,X="""`"_IFC_""""
 . D ^DIC I Y=-1 Q
 . S DIE=DIC,DA=+Y,DR=".02////^S X=AUPNPAT;.03////^S X=APCDVSIT"
 . L +^AUPNVIF(DA):1 I  D ^DIE  L -^AUPNVIF(DA)
 . Q
 S OUT="OK"
TXCLEAN S DA=0,DIK="^VEN(7.16," F  S DA=$O(^VEN(7.16,"AC",KEY,DA)) Q:'DA  D ^DIK ; EP - CLEAN UP THE TX FILE
 D ^XBFMK
 Q
 ;
TODAY(DFN,TYPE) ; EP - RETURNS TODAY'S PT ED/NURT RESULTS - IF THERE ARE ANY
 S TYPE=$G(TYPE) I TYPE'="P",TYPE'="N" Q
 I '$D(^DPT(+$G(DFN,0))) Q
 N VIEN,PRV,PRVIEN,LOU,TIME,IFC,X,Y,%,VWCIEN,STOP,VDATE,B,IFCIEN
 S (OUT,PRV,PRVIEN,LOU,TIME,IFC)="",B="|"
 S VWCIEN=99999999,STOP=0
 F  S VWCIEN=$O(^AUPNVWC("AC",DFN,VWCIEN),-1) Q:'VWCIEN  D  I STOP Q
 . S X=$G(^AUPNVWC(VWCIEN,0)) I '$L(X) Q
 . S VIEN=$P(X,U,3) I 'VIEN Q
 . S VDATE=+$G(^AUPNVSIT(VIEN,0)) I 'VDATE Q
 . I VDATE<DT S STOP=1 Q
 . S STOP=1,OUT=VIEN
 . I TYPE="P",'$D(^AUPNVWC(VWCIEN,1)) Q
 . I TYPE="N",'$D(^AUPNVWC(VWCIEN,5)) Q
 . I TYPE="P" S PRVIEN=$P(X,U,4),TIME=$P(X,U,5),LOU=$P(X,U,6)
 . I TYPE="N" D
 .. S PRVIEN=$P(X,U,9),TIME=$P(X,U,7),LOU=$P(X,U,8)
 .. S IFCIEN=$O(^AUPNVIF("AD",VIEN,0))
 .. I IFCIEN S IFC=+$G(^AUPNVIF(IFCIEN,0))
 .. Q
 . I PRVIEN S PRV=$P($G(^VA(200,PRVIEN,0)),U)
 . I LOU S LOU=$P("GOOD^FAIR^POOR^NA^REFUSED",U,LOU)
 . I $G(IFC) S IFC=$P("EXCLUSIVE BREASTFEEDING^MOSTLY BREASTFEEDING^1/2 & 1/2 BREAST AND FORMULA^MOSTLY FORMULA^FORMULA ONLY",U,IFC)
 . S OUT=VIEN_B_PRV_B_PRVIEN_B_LOU_B_TIME
 . I TYPE="N" S OUT=OUT_B_IFC
 . Q
 Q
 ;
STALE ; EP - REMOVE STALE ENTRIES FROM TX FILE ; TRANSACTION FROM EARLIER DATES ARE, BY DEFINITION, ORPHANS
 N DATE,DIK,DA
 S DATE=DT,DIK="^VEN(7.16,"
 F  S DATE=$O(^VEN(7.16,"AD",DATE),-1) Q:'DATE  D
 . S DA=0
 . F  S DA=$O(^VEN(7.16,"AD",DATE,DA)) Q:'DA  D ^DIK
 . Q
 D ^XBFMK
 Q
 ;