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

VENPCCKB.m

Go to the documentation of this file.
VENPCCKB ; IHS/OIT/GIS - KNOWLEDGEBASE UTILITIES ;
 ;;2.6;PCC+;**1,4**;APR 03, 2012;Build 24
 ;
 ;
 ;
PARSE(PATH,FILE) ; EP - PARSE A KB DEFINITION DOCUMENT AND STORE KB GROUPS AND ITEMS
 N TMP,POP,MN
 I '$L($G(FILE)) Q
 S FILE=$$UP^XLFSTR(FILE)
 S MN=$E($P(FILE,".TXT"),1,4) I '$L(MN) Q
 S TMP=$NA(^TMP("VEN AG",$J)) K @TMP
 S POP=$$OPN^VENPCCP(PATH,FILE,"R","D GET^VENPCCKB") ; CAPTURE TXT FILE AS A GLOBAL ARRAY
 I POP Q
 D PASS1 ; GET KB GROUPS
 D PASS2 ; GET KB ITEMS
 K @TMP,^TMP("VEN AG GROUP",$J)
 Q
 ;
GET ; EP - CAPTURE CONTENT
 N LINE,X,STOP
 S X="",STOP=0
 F LINE=1:1 D  I STOP Q
 . R X:1 E  Q
 . I X["***END***" S STOP=1 Q
 . I X="" Q
 . S @TMP@(LINE)=X
 . Q
 Q
 ;
PASS1 ; EP - GET KB GROUPS
 N LINE,NAME,Y,%,X,DIC,DIE,DR,DA,HDR,CAT
 S X="",LINE=0 K ^TMP("VEN AG GROUP",$J)
 F  S LINE=$O(@TMP@(LINE)) Q:'LINE  D  I X="***END***" Q
 . S X=$G(@TMP@(LINE))
 . I $E(X)=$C(9),$E(X,2)?1A S ^TMP("VEN AG GROUP",$J,$E(X,2,99))=""
 . Q
 S NAME="",%=" and "
 S DIC="^VEN(7.11,",DIC(0)="L",DLAYGO=19707.11,DIE=DIC
 S DR=".03////1;.05////1;.09///^S X=HDR;.1////M"
 F  S NAME=$O(^TMP("VEN AG GROUP",$J,NAME)) Q:NAME=""  D
 . S X=NAME
 . I X[% S X=$P(X,%)_"/"_$P(X,%,2,99)
 . S X=$$UP^XLFSTR(X),HDR="PT ED - "_X,HDR=$E(HDR,1,30),CAT=X
 . S X=MN_" "_X
 . D ^DIC I Y=-1 Q
 . S DA=+Y
 . L +^VEN(7.11,DA):1 I  D ^DIE L -^VEN(7.11,DA)
 . S ^VEN(7.11,DA,2,0)="^^1^1^"_DT_U
 . S ^VEN(7.11,DA,2,1,0)="NATL. ANTICIPETORY GUIDANCE STANDARDS FOR "_CAT
 . S ^TMP("VEN AG GROUP",$J,NAME)=DA
 . Q
 D ^XBFMK
 Q
 ;
PASS2 ; EP - GET KB ITEMS
 N LINE,X,M1,M2,DAY1,DAY2,GROUP,M,W,Y,Z,DIC,DIE,DR,DA,ITEM,TXT,GIEN
 S LINE=0,(DAY1,DAY2)="",GROUP="",GIEN=""
 S (DIC,DIE)="^VEN(7.12,",DIC(0)="L",DLAYGO=19707.12
 S DR=".02///^S X=ITEM;.05///^S X=DAY1;.06///^S X=DAY2;.13///^S X=M1;.14///^S X=M2"
 F  S LINE=$O(@TMP@(LINE)) Q:'LINE  S TXT=@TMP@(LINE) I $L(TXT) D
BRACKET . I TXT["{" D  Q  ; GET THE CURRENT SET OF AGE BRACKETS (IN DAYS AND MONTHS)
 .. S (DAY1,DAY2)="" ; RESET THE AGE RANGE
 .. S Y=$P(TXT,"{",2) S Y=$P(Y,"}")
 .. S M1=+Y,M2=$P(Y,"-",2)
 .. I M1!(M1=0),M2
 .. E  Q
 .. I M1=0 S DAY1=0
 .. E  S DAY1=(30.4375*M1\1)+1
 .. S DAY2=30.4375*M2\1
 .. Q
GRP . I $E(TXT)=$C(9),$E(TXT,2)?1A S GROUP=$E(TXT,2,99),GIEN=$G(^TMP("VEN AG GROUP",$J,GROUP)) Q
ITEM . I (DAY1!(DAY1=0)),DAY2,M2,$L(GROUP),GIEN
 . E  Q  ; AT THIS STAGE DAYS, MONTHS AND GROUP MUST BE DEFINED
 . I $E(TXT,1,2)'=$C(9,9) Q  ; SCREEN OUT ANYTHING THAT IS NOT AN ITEM
 . S ITEM=$E(TXT,3,82) I '$L(ITEM) Q
 . S ITEM=$TR(ITEM,$C(9),"") ; CLEAN OUT ANY TRAILING TABS
 . S X="""`"_GIEN_""""
 . D ^DIC I Y=-1 Q
 . S DA=+Y
 . L +^VEN(7.12,DA):1 I  D ^DIE L -^VEN(7.12,DA)
 . Q
 D ^XBFMK
 Q
 ; 
PEC ; EP - AUTOMATICALLY ASSIGN PATIENT ED CODES TO ITEMS
 N IIEN,ITEM,X,Y,Z,CIEN,PRE,CODE,GRP
 S IIEN=0
 F  S IIEN=$O(^VEN(7.12,IIEN)) Q:'IIEN  D  ; CHECK EACH ITEM
 . S X=$G(^VEN(7.12,IIEN,0)) I '$L(X) Q
 . S CIEN=+X S Y=$G(^VEN(7.11,CIEN,0)) I '$L(Y) Q
 . S PRE=$P(Y,U,12) I '$L(PRE) Q
 . S CODE=$P(Y,U,13) I '$L(CODE) Q
 . S Z=$P(X,U,6),GRP=$S(Z<62:"N",Z<366:"I",Z<1096:"T",Z<1827:"P",Z<4384:"S",Z<7686:"A",1:"")
 . S $P(X,U,4)=PRE_GRP_"-"_CODE,^VEN(7.12,IIEN,0)=X
 . Q
 Q
 ; 
TOPIC ; EP - IF ENTRIES ARE MISSING FROM THE EDUCATION TOPIC FILE, ADD THEM NOW
 N TIEN,STOPIC,MN,X,Y,Z,%,TMP,CNT,FULL,STG,NAME,MAJ,EIEN,TNAME,KGBL
 S TMP=$NA(^TMP("VEN EDU",$J)) K @TMP
 I '$G(KIEN) S KIEN=0
TARR ; MAKE TEMP ARRAY OF ALL MNEMONICS AND THEIR SUB-TOPICS IN THE KB ITEM FILE
 S KGBL=$NA(^VEN(7.12))
 F  S KIEN=$O(@KGBL@(KIEN)) Q:'KIEN  D
 . S MN=$P($G(@KGBL@(KIEN,2)),U,3) I MN="" Q  ; TOPIC MNEMONIC
 . S MAJ=$P(MN,"-") I MAJ="" Q  ; MAJOR TOPIC.  BY DEFAULT, ALL WCM MAJOR TOPICS WILL BE THE 1ST PIECE OF THE MN
 . S TNAME=$P(@KGBL@(KIEN,2),U,6) I TNAME="" S TNAME=MN,$P(@KGBL@(KIEN,2),U,6)=MN ; FULL TOPIC NAME
 . S EIEN=$O(^AUTTEDT("C",MN,99999999),-1) ; GIVEN A MN FROM THE KB ITEM FILE, FIND THE IEN OF THE NEWEST TOPIC TOPIC IN EDU TOPIC FILE WITH THAT EXACT MN
 . I EIEN D  Q  ; THE MNEMONIC IS ALREADY IN THERE.  CLEAN IT UP AND QUIT 
 .. S %=$NA(^AUTTEDT(EIEN))
 .. S $P(@%@(0),U,3)="",$P(@%@(0),U,5)="" ; MAKE SURE IT'S ACTIIVE
 .. S $P(@%@(0),U,6)=MAJ ; MAKE SUR MAJOR TOPIC IS SYNC'D
 .. Q
 . S Y=$P(MN,"-",2,99) ; FIRST VALIDATE THE MNEMONIC STORED IN THE KB ITEM FILE
 . I '$L(Y) Q
 . I $L(Y)>3 Q
 . I Y?.E1.N.E Q
 . S @TMP@(MN)=TNAME ; FULL TOPIC NAME
 . S STOPIC=$P(^VEN(7.12,KIEN,0),U,2) I '$L(STOPIC) Q  ; SUB-TOPIC NAME
 . S %=$O(@TMP@(MN,999999),-1)+1
 . S @TMP@(MN,%)=STOPIC ; SUB TOPIC ARRAY
 . Q
TENT ; FOR EACH ITEM IN THE ARRAY, MAKE NEW ENTRY IN THE EDUCATION TOPIC FILE - IF NECESSARY
 S MN=""
 F  S MN=$O(@TMP@(MN)) Q:'$L(MN)  D  ; LOOP THROUGH THE MENOMIC ARRAY OF UN-ENTERED TOPICS
 . S TNAME=@TMP@(MN)
 . S MAJ=$P(MN,"-")
 . S STG="",CNT=0
 . F  S CNT=$O(@TMP@(MN,CNT)) Q:'CNT  D  ; FOR EA TOPIC, BUILD A LONG TEXT STRING WITH ALL SUBTOPICS IN IT
 .. S X=@TMP@(MN,CNT) I '$L(X) Q
 .. S X=CNT_". "_X
 .. I $L(STG) S STG=STG_".  "
 .. S STG=STG_X
 .. Q
WPARR .; CONVERT THE SUBTOPIC STG TO AN ARRAY THAT CAN BE GRAFTED INTO THE WP (SUBTOPIC) FIELD OT EDU TOPIC FILE
 . K ARR S CNT=0
 . F  D  I '$L(STG) Q
 ..  S CNT=CNT+1
 ..  I $L(STG)<61 S ARR(CNT)=STG,STG="" Q
 ..  S X=$E(STG,1,60),Y=$E(STG,61,9999),Z=$P(Y," ")
 ..  S ARR(CNT)=X_Z_" ",%=$L(ARR(CNT))+1
 ..  S STG=$E(STG,%,9999)
 ..  Q
 . D TDIC(MN,MAJ,TNAME,.ARR) ; FILL OUT THE NEW TOPIC ENTRY
 . Q
 K @TMP
 Q
 ; 
TDIC(MN,MAJ,TNAME,ARR) ; EP - MAKE NEW EDUCATION TOPIC ENTRY
 N DIC,DIE,DA,DR,X,Y,%,CNT,GBL
 S DIC="^AUTTEDT(",DIC(0)="L",DLAYGO=9999999.09
 S X=TNAME
 D ^DIC I Y=-1 Q
 S DIE=DIC,DA=+Y,DR=".06///^S X=MAJ;1///^S X=MN"
 S GBL=$NA(^AUTTEDT(DA))
 L +@GBL:1 I  D ^DIE L -@GBL
 S CNT=$O(ARR(9999),-1)
 S @GBL@(2,0)="^^"_CNT_U_CNT_U_DT ; STUFF STANDARDS FIELD WITH WP ARRAY - BASED ON SUBTOPICS IN KB ITEM FILE
 F X=1:1:CNT S @GBL@(2,X,0)=ARR(X)
 D ^XBFMK K ARR
 W !?10,TNAME," (",MN,")  <-Added"
 Q
 ; 
CONVERT ; EP - CONVERT ENTRIES TO NEW NATL STDS
 N X,DIC,Y,%,CAT,IIEN,STG,Z
 S IIEN=0,DIC="^VEN(7.12,",DLAYGO=19707.12,DIC(0)="L"
 F  S IIEN=$O(^VEN(7.12,IIEN)) Q:'IIEN  D  I IIEN>1964 Q
 . S STG=$G(^VEN(7.12,IIEN,0)),%=+STG
 . S X=$S(%=1:34,%=3:35,%=4:36,%=5:37,1:0) I 'X Q
 . S $P(STG,U,1)=X
 . S X="""`"_X_""""
 . D ^DIC I Y=-1 Q
 . S ^VEN(7.12,+Y,0)=STG
 . Q
 D ^XBFMK
 Q
 ; 
PTED ; EP - PATIENT ED CODES
 N DA
 S DA=0
 F  S DA=$O(^VEN(7.12,DA)) Q:'DA  D
 . S X=$P($G(^VEN(7.12,DA,0)),U,4)
 . I $E(X,1,2)'="CH" Q
 . I X?.E1.N.E Q  ; MUST BE A NATL CODE
 . S $P(^VEN(7.12,DA,2),U,3)=X
 . Q
 Q
 ; 
CHA ; EP - CONVERT CH TO CHA
 N KIEN,X,Y,%
 S KIEN=0
 F  S KIEN=$O(^VEN(7.12,KIEN)) Q:'KIEN  S X=$P($G(^VEN(7.12,KIEN,0)),U,4) I $E(X,1,3)="CH-" D
 . S X="CHA-"_$P(X,"-",2)
 . S $P(^VEN(7.12,KIEN,0),U,4)=X
 . Q
 Q
 ; 
NAME(MN) ; EP - TRIGGER: GIVEN A ED TOPIC MNEMONIC, RETURN THE NAME FROM THE PT ED FILE
 I '$L($G(MN)) Q
 N EIEN,NAME,X,Y,Z
 S EIEN=0,NAME=""
 F  S EIEN=$O(^AUTTEDT("C",MN,EIEN)) Q:'EIEN  D  I NAME Q
 . I $P($G(^AUTTEDT(EIEN,0)),U,3) Q  ; INACTIVE
 . S NAME=$P($G(^AUTTEDT(EIEN,0)),U)
 . Q
 ; I NAME="" W !,MN
 Q NAME
 ;