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

APCDTWC.m

Go to the documentation of this file.
APCDTWC ; IHS/CMI/LAB - GENERATED FROM 'APCD WCE (ADD)' INPUT TEMPLATE(#XXX), FILE 9000010 ; 
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ; WELL CHILD EXAM INPUT TEMPLATE FOR PCC AND PCC+
 ; 
 ;
DATA I '$D(^DPT(+$G(AUPNPAT),0)) Q  ; DFN MUST BE DEFINED
 I '$G(^AUPNVSIT(+$G(APCDVSIT),0)) Q  ; VISIT MUST BE DEFINED
 I $O(^VEN(7.12)),$O(^VEN(7.13))
 E  D  Q
 . W !,"Sorry, if you want to use this Mnemonic,"
 . W !,"the PCC+ Knowledgebase must be installed."
 . W !,"Request cancelled..."
 . H 1
 . Q
 W !!!,?15,"***  DATA ENTRY - WELL CHILD EXAM  ***"
 K Y ; PREVENT THE "An error has occurred, I think" message.
NEW N DIR,DIC,DIE,DA,X,Y,%,%T,%,%Y,%DT,VDATE
 S VDATE=^AUPNVSIT(APCDVSIT,0)\1 I 'VDATE Q  ; VISIT DATE MUST EXIST
 S DIR("B")="A" ; ONLY SET DEFAULT TO "A" ON THE FIRST PASS
 S DIR(0)="S^1:Clinic;2:Provider;3:POV;4:Development/Autism Screen comments;5:Patient education;6:Nutrition;7:Screening exams;8:ASQ score;A:ALL items;Q:QUIT THIS MNEMONIC"
 S DIR("A")="Your choice" D ^DIR K DIR
 I Y="A" D ALL G MENU  ; EDIT THE V OB RECORD
 I '$G(Y) G FIN  ; BAIL OUT
 D @$P("CLN^PRV^POV^DEV^PTED^NUT^EXAM^ASQ",U,Y) W !! G MENU
FIN D ^XBFMK
 Q
 ;
TEST N AUPNPAT,APCDVSIT S AUPNPAT=1,AUPNVSIT=71262 D APCDTWC Q
 ; 
ALL ; EDIT ALL SECTIONS
 D CLN,PRV,POV,DEV,PTED,NUT,EXAM,ASQ
 Q
 ;
CLN ; EDIT CLINIC
 N CIEN,CLN,DA,DIE,DR,%,DIC,X,Y
 S CIEN=$O(^DIC(40.7,"C",24,0)),CLN=""
 I 'CIEN S CLN="GENERAL"
 I CIEN S CLN=$P($G(^DIC(40.7,CIEN,0)),U)
 S %=$P($G(^AUPNVSIT(APCDVSIT,0)),U,8) I % S CLN=$P($G(^DIC(40.7,%,0)),U)
 S DIE="^AUPNVSIT(",DA=APCDVSIT,DR=".08//"_CLN
 L +^AUPNVSIT(APCDVSIT):1 I  D ^DIE L -^AUPNVSIT(APCDVSIT)
 Q
 ;
PRV ; ENTER THE PROVIDERS
 N DIC,DA,DR,DIE,X,Y,%,PS
 S %=0,X=0
 F  S X=$O(^AUPNVPRV("AD",APCDVSIT,X)) Q:'X  I $E($P($G(^AUPNVPRV(X,0)),U,4))="P" S %=1 Q
 I %=1 W !,"A primary provider has already been entered for this visit..." G PRV2
 S DIC("A")="Provider: "
 S PS="PRIMARY"
PRVQ S DIC=200,DIC(0)="AEQM"
 I $P($G(^DD(9000010.06,.01,0)),U,2)[6 S DIC=6
 D ^DIC I Y=-1 D ^XBFMK Q
 S %=0,X=0
 F  S X=$O(^AUPNVPRV("AD",APCDVSIT,X)) Q:'X  I +$G(^AUPNVPRV(X,0))=+Y S %=1 Q
 I %=1 W !,"This provider has already been entered for this visit..." G PRV2
PRV1 S DIC="^AUPNVPRV(",DIC(0)="L",DLAYGO=9000010.06,X="""`"_+Y_""""
 D ^DIC I Y=-1 D ^XBFMK Q
 S DA=+Y,DIE=DIC,DR=".02////^S X=AUPNPAT;.03////^S X=APCDVSIT;.04//"_PS
 L +^AUPNVPRV(DA):1 I  D ^DIE L -^AUPNVPRV(DA)
PRV2 S PS="SECONDARY"
 S DIC("A")="Another provider: "
 G PRVQ ; GET MORE
 ;
POV ; PURPOSE OF VISIT
 N DA
 S DA=APCDVSIT
 I $D(^AUPNVPOV("AD",DA)) G POV1 ; THERE IS ALREADY A POV FOR THIS VISIT
 N DIC,DIE,DR,X,Y,%,DIR,NIEN,IIEN
 S DIC="^AUTNPOV(",DIC(0)="L",DLAYGO=9999999.27,X="WELL CHILD EXAM"
 D ^DIC I Y=-1 G POVX
 S NIEN=+Y ; GET IEN FOR 'WELL CHILD EXAM' PROVIDER NARRATIVE
 S X=$O(^ICD9("AB","V20.2",0)) I 'X S X=$O(^ICD9("AB","V20.2 ",0)) I 'X G POVX ; GET THE ICD9 IEN FOR A WELL CHILD EXAM
 S DIC="^AUPNVPOV(",DIC(0)="L",DLAYGO=9000010.07,X="""`"_X_""""
 D ^DIC I Y=-1 G POVX ; CREATE NEW POV ENTRY
 S DA=+Y,DIE=DIC,DR=".02////^S X=AUPNPAT;.03////^S X=APCDVSIT;.04////^S X=NIEN;.12////P"
 L +^AUPNVPOV(DA):1 I  D ^DIE L -^AUPNVPOV(DA)
POV1 W !!,"***  WELL CHILD EXAM (V20.2) has been automatically added as a POV  ***"
 W !,"Add additional POV's using the PV mnemonic",! Q
POVX W !,"Unable to automatically add WELL CHILD EXAM as a POV!!!"
 Q
 ; 
DEV ; ENTER DEVELOPMENT ASSESSMENT
 N DEV,DA,DIR,DIE,DR,VAL1,VAL2,VAL3,VAL4,FNO,TOT,X,Y,VWCIEN,%,%Y
 S X=$O(^VEN(7.13,"B","WELL CHILD NATL DEV STDS 9999"),-1) Q:X=""  S Y=$O(^(X,0)) I 'Y Q
 I '$P($G(^VEN(7.13,Y,0)),U,7) W !,"No DEV guidelines available..." Q  ; DEV DOMAIN IS INACIVE
 S VWCIEN=$O(^AUPNVWC("AD",APCDVSIT,999999999),-1)
 W !!,"Want to enter Development or Autism screen comments" S %=2
 D YN^DICN I %'=1 Q
 S DIR(0)="FO^1:60",DIR("A")="Fine motor"
 S DIR("B")="OK"
 I VWCIEN S %=$P($G(^AUPNVWC(VWCIEN,3)),U,1) I $L(%) S DIR("B")=%
 D ^DIR K DIR I Y?1."^" G DEVX
 I $L(Y) S DEV(3.01)=Y
 S DIR(0)="FO^1:60",DIR("A")="Gross motor"
 S DIR("B")="OK"
 I VWCIEN S %=$P($G(^AUPNVWC(VWCIEN,3)),U,2) I $L(%) S DIR("B")=%
 D ^DIR K DIR I Y?1."^" G DEVX
 I $L(Y) S DEV(3.02)=Y
 S DIR(0)="FO^1:60",DIR("A")="Language"
 S DIR("B")="OK"
 I VWCIEN S %=$P($G(^AUPNVWC(VWCIEN,3)),U,3) I $L(%) S DIR("B")=%
 D ^DIR K DIR I Y?1."^" G DEVX
 I $L(Y) S DEV(3.03)=Y
 S DIR(0)="FO^1:60",DIR("A")="Social"
 S DIR("B")="OK"
 I VWCIEN S %=$P($G(^AUPNVWC(VWCIEN,3)),U,4) I $L(%) S DIR("B")=%
 D ^DIR K DIR I Y?1."^" G DEVX
 I $L(Y) S DEV(3.04)=Y
 S DIR(0)="FO^1:60",DIR("A")="Autism screen"
 S DIR("B")="OK"
 I VWCIEN S %=$P($G(^AUPNVWC(VWCIEN,9)),U,1) I $L(%) S DIR("B")=%
 D ^DIR K DIR I Y?1."^" G DEVX
 I $L(Y) S DEV(9.01)=Y
DEV1 ; FILE RESULTS
 I '$D(DEV) G DEVX
 S DA=$$VWC^APCDTWC1(AUPNPAT,APCDVSIT) I 'DA G DEVX ; CREATE A NEW V WELL CHILD RECORD IF NECESSARY
 S DIE="^AUPNVWC(",DR="",FNO=0,TOT=0
 F  S FNO=$O(DEV(FNO)) Q:'FNO  D  ; MAKE THE DR STRING
 . I $L(DR) S DR=DR_";"
 . S TOT=TOT+1,@("VAL"_TOT)=DEV(FNO)
 . S DR=DR_FNO_"///^S X=VAL"_TOT
 . Q
 L +^AUPNVWC(DA):1 I  D ^DIE L -^AUPNVWC(DA)
DEVX D ^XBFMK
 Q
 ;
ARR(DFN,TYPE,DOM,ARR) ;EP - GIVEN A PATIENT DFN AND A KB CATEGORY TYPE, BUILD AN ARRAY OF ITEMS
 ; TYPE = KB CATEGORY TYPE (e.g., PT ED, DEVEL, etc.), DOMAIN = WELL CHILD CARE
 N SEX,DAYS,X,Y,Z,%,TOT,DOB,CIEN,KIEN,CAT,ORD,CODE,MOD,START,STOP,STG,TITLE
 S TOT=0 K ARR
 S %=$G(^DPT(+$G(DFN),0)) I '$L(%) Q
 S SEX=$P(%,U,2),DOB=$P(%,U,3) I '$L(SEX)!('DOB) Q
 S DAYS=$$FMDIFF^XLFDT(DT,DOB,1)
 S CAT=0
 F  S CAT=$O(^VEN(7.13,DOM,1,CAT)) Q:'CAT  D  ; CREATE THE ORDINAL ARRAY OF KB CATEGORIES OF THIS TYPE.
 . S CIEN=+$G(^VEN(7.13,DOM,1,CAT,0)) I 'CIEN Q
 . I $P($G(^VEN(7.11,CIEN,0)),U,11)'=TYPE Q  ; TYPE MUST MATCH SELECTION
 . S ORD=$P(^VEN(7.13,DOM,1,CAT,0),U,2)
 . I 'ORD S ORD=100+CAT ; MAKE SURE EVERY CAT HAS AN ORDER - EVEN IF ONE IS NOT OFFICIALLY ASSIGNED
 . S ORD(ORD)=CIEN ; TYPICALLY THE ORD ARRAY WILL ONLY HAVE ONE NODE
 . Q
 ; NOW CHECK ALL ENTRIES IN THE KNOWLEDGE CATEGORY AND BUILD THE DATA ENTRY ARRAY (ARR)
 ; LOOP USING THE ORD ARRAY (ORD)
 S (TOT,ORD)=0
 F  S ORD=$O(ORD(ORD)) Q:'ORD  S CIEN=ORD(ORD) S KIEN=0 F  S KIEN=$O(^VEN(7.12,"B",CIEN,KIEN)) Q:'KIEN  D
 . S STG=$G(^VEN(7.12,KIEN,0)) I '$L(STG) Q
 . I $P(STG,U,11) Q  ; INACTIVE ITEM !!!
 . S START=$P(STG,U,5) I DAYS<START Q
 . S STOP=$P(STG,U,6) I DAYS>STOP Q
 . S CODE=$P(STG,U,4)
 . S %=$P(STG,U,10) I $L(%),%'=SEX Q
 . S TITLE=$P(STG,U,2) I '$L(TITLE) Q
 . S MOD=$P(STG,U,12)
 . I $L(MOD) S TITLE=TITLE_" ("_MOD_")"
 . S TOT=TOT+1
 . S ARR(TOT)=TOT_". "_TITLE
 . S ARR(TOT,0)=KIEN,ARR("X",KIEN)=TOT
 . I $L(CODE) S ARR("CODE",CODE,TOT)=TITLE
 . Q
 Q
 ; 
RANGE(ARR) ;EP - MANAGE A RANGE OF ARRAY NUMBERS
 N CNT,MAX,DIR,DEL,PCE,A,B,X,MORE,RFLG,%
PRE ; CHECK V FILE TO SEE IF ANYTHING HAS ALREADY BEEN SELECTED
 S MORE=0
R1 S CNT=0,MAX=$O(ARR(999),-1)
 F  S CNT=$O(ARR(CNT)) Q:'CNT  W !,?3,ARR(CNT) I $D(ARR(CNT,1)) W " [SELECTED]"
 I MORE W !,"Want to make any additional changes" S %=2 D YN^DICN I %'=1 G RANGEX
 S DIR(0)="FO^1:7",DIR("A")="Select ITEMS by number"
 S DIR("?")="Sample: 1,2,4-6,-9,-12-15,16"
 D ^DIR
 I $E(Y)'="-",'Y G RANGEX
 S DEL=$L(Y,",")
 F PCE=1:1:DEL D
 . S X=$P(Y,",",PCE),RFLG=0
 . I $E(X)="-" S RFLG=1,X=$E(X,2,99)
 . S A=+X I 'A W !,"The expression '",$P(Y,",",PCE),"' is invalid" Q
 . S B=$P(X,"-",2) I B="" S B=A
 . S B=+B
 . I A>B W !,"The expression '",$P(Y,",",PCE),"' is invalid" Q
 . F X=A:1:B D
 .. I '$D(ARR(X)) W !,"Item number ",X," does not exist" Q
 .. I RFLG,'$D(ARR(X,1)) W !,"Item number ",X," has not been selected - can't remove it" Q
 .. I RFLG K ARR(X,1) Q
 .. I $D(ARR(X,1)) W !,"Item "_X_" has already been selected" Q
 .. S ARR(X,1)=""
 .. Q
 . Q
 S MORE=1  W ! G R1
RANGEX K DIRUT,DIRDT,DUOUT,DIROUT,DTOUT
 S (%,X)=0 F  S X=$O(ARR(X)) Q:'X  I $D(ARR(X,1)) S %=1 Q
 I '% K ARR ; NOTHING SELECTED, SO KILL OFF THE ARRAY
 Q
 ;
NUT ; ENTER NUTRITION TOPICS
 D FEED^APCDTWC1(APCDVSIT) ; INFANT FEEDING PRACTICES
 N ARR,AGIEN,%,X,Y,TOT,LOU,TIME,FTIME,GRP,WVCIEN,TYPE,TITLE,DOM
 S X=$O(^VEN(7.13,"B","WELL CHILD NATL NUTR STDS 9999"),-1) Q:X=""  S Y=$O(^(X,0)) I 'Y Q
 I '$P($G(^VEN(7.13,Y,0)),U,7) W !,"No NUTRITION guidelines available..." Q  ; NUTRITION DOMAIN IS INACIVE
 S TITLE="nutrition counseling ",TYPE=6,DOM=6
 D ARR(AUPNPAT,TYPE,DOM,.ARR) ; BUILD THE PRE-SELECTION ARRAY
 I '$D(ARR) W !!,"No nutrition topics are required for this visit!!",!! H 1 G NUTX
 S VWCIEN=$O(^AUPNVWC("AD",APCDVSIT,999999999),-1)
 I VWCIEN D  ; CHECK FOR EXISTING SELECTIONS AND UPDATE THE ARRAY
 . S TOT=0 F  S TOT=$O(ARR(TOT)) Q:'TOT  D
 .. S X=ARR(TOT)
 .. S X=$P(X,". ",2)
 .. S X=$E(X,1,30)
 .. I $D(^AUPNVWC(VWCIEN,5,"B",X)) S ARR(TOT,1)="" ; IF ITS ALREADY IN V WC, SET THE ARR NODE TO 'SELECTED'
 .. Q
 . Q
 I '$D(ARR) G NUTX
 W !!,"Select from the list of standard ",TITLE,"topics: "
 D RANGE(.ARR) I '$D(ARR) Q  ; GET FINAL SELECTION ARRAY
NUTFILE ; MAKE ENTRIES IN V WC AND V PATIENT ED
 S (LOU,TIME,FTIME)="",GRP="I"
 D LOU^APCDTWC1(TITLE,.LOU,.TIME,.FTIME) ; GET LEVEL OF UNDERSTANDING AND NUT ED TIME
 D NVWCFILE^APCDTWC1(LOU,TIME) ; FILE RESULTS IN V WELL CHILD ; REQUIRES THE SELECTION ARRAY
 D VPEFILE^APCDTWC1(LOU,FTIME,GRP) ; FILE RESULTS IN V PATIENT ED ; REQUIRES THE SELECTION ARRAY
NUTX K ARR ; CLEANUP ARRAY
 Q
 ; 
PTED ; ENTER PATIENT EDUCATION TOPICS
 ; RESULTS ARE FILE IN BOTH V PATIENT ED AND V WELL CHILD AS FREE TEXT SUBTOPICS
 S X=$O(^VEN(7.13,"B","WELL CHILD NATL AG STDS 9999"),-1) Q:X=""  S Y=$O(^(X,0)) I 'Y Q
 I '$P($G(^VEN(7.13,Y,0)),U,7) W !,"No PATIENT EDUCATION guidelines available..." Q  ; AG DOMAIN IS INACIVE
 N ARR,AGIEN,%,X,TOT,LOU,TIME,FTIME,GRP,WVCIEN,TYPE,TITLE,DOM
 S TITLE="patient education ",TYPE=1,DOM=5
 D ARR(AUPNPAT,TYPE,DOM,.ARR) ; BUILD THE PRE-SELECTION ARRAY
 S VWCIEN=$O(^AUPNVWC("AD",APCDVSIT,999999999),-1)
 I VWCIEN D  ; CHECK FOR EXISTING SELECTIONS AND UPDATE THE ARRAY
 . S TOT=0 F  S TOT=$O(ARR(TOT)) Q:'TOT  D
 .. S X=ARR(TOT)
 .. S X=$P(X,". ",2)
 .. S X=$E(X,1,30)
 .. I $D(^AUPNVWC(VWCIEN,1,"B",X)) S ARR(TOT,1)="" ; IF ITS ALREADY IN V WC, SET THE ARR NODE TO 'SELECTED'
 .. Q
 . Q
 I '$D(ARR) Q
 W !!,"Select from the list of standard ",TITLE,"topics: "
 D RANGE(.ARR) I '$D(ARR) Q  ; GET FINAL SELECTION ARRAY
PEFILE ; AT THIS POINT WE HAVE THE FINAL SELECTION ARRAY AND ARE READY TO MAKE ENTRIES IN V WELL CHILD AND V PATIENT ED
 S (LOU,TIME,FTIME)="",GRP="I"
 D LOU^APCDTWC1(TITLE,.LOU,.TIME,.FTIME,.EDU) ; GET LEVEL OF UNDERSTANDING AND PT ED TIME
 D PEWCFILE^APCDTWC1(LOU,TIME,EDU) ; FILE RESULTS IN V WELL CHILD ; REQUIRES THE SELECTION ARRAY
 D VPEFILE^APCDTWC1(LOU,FTIME,GRP) ; FILE RESULTS IN V PATIENT ED ; REQUIRES THE SELECTION ARRAY
 K ARR ; CLEANUP ARRAY
 Q
 ; 
EXAM ; ENTER SPECIAL EXAMS AND SCREENING PROCEDURES
 S X=$O(^VEN(7.13,"B","WELL CHILD NATL EXAM STDS 9999"),-1) Q:X=""  S Y=$O(^(X,0)) I 'Y Q
 I '$P($G(^VEN(7.13,Y,0)),U,7) W !,"No EXAM guidelines available..." Q  ; EXAM DOMAIN IS INACIVE
 D EXAM^APCDTWC2
 Q
 ; 
ASQ ; ENTER ASQ SCORES
 D ASQFILE^APCDTWC1
 Q
 ;