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

PSNCLING.m

Go to the documentation of this file.
PSNCLING ;BIR/DMA-clean up ingredients and interactions ; 19 Jan 2006  9:45 AM
 ;;4.0; NATIONAL DRUG FILE;**107**; 3O Oct 98
 ;
 ;Reference to ^GMRD(120.8 supported by DBIA# 2545
 ;Reference to ADCOM^GMRAFX supported by DBIA# 4783 
 ;
 ;delete existing cross reference
 K ^PS(50.416,"P")
 ;and the entries
 ;
 ;following code generated by DIKCBLD
 N PSNXR,PSNRES,PSNOUT
 S PSNXR("FILE")=50.416
 S PSNXR("NAME")="P1"
 S PSNXR("TYPE")="MU"
 S PSNXR("USE")="LS"
 S PSNXR("EXECUTION")="R"
 S PSNXR("ACTIVITY")="IR"
 S PSNXR("SHORT DESCR")="CROSS REFERENCE ON PRIMARY INGREDIENT"
 S PSNXR("DESCR",1)=" "
 S PSNXR("SET")="I X2(1)'="""",X2(2)="""" S ^PS(50.416,""P"",X2(1),DA)="""""
 S PSNXR("KILL")="I X2(1)=""""!(X2(2)'="""")!(X1(1)'=X2(1)) K ^PS(50.416,""P"",X1(1),DA)"
 S PSNXR("WHOLE KILL")="K ^PS(50.416,""P"")"
 S PSNXR("VAL",1)=.01
 S PSNXR("VAL",1,"COLLATION")="F"
 S PSNXR("VAL",2)=2
 S PSNXR("VAL",2,"COLLATION")="F"
 D CREIXN^DDMOD(.PSNXR,"SW",.PSNRES,"PSNOUT")
 ;end of generated code
 ;
 N DA,DIE,DIK,DR,J,LINE,NA,OLD,PSN,PSN1,PSN11,PSN2,PSN21,PSNA1,PSNA2,PSNDA,PSNFREE,PSNI,PSNI1,PSNI2,PSNPAT,PSNPSNI1,PSNK,PSNN,PSNN1,PSNQ,PSNX,X,XMDUZ,XMSUB,XMTEXT,XMY
 K ^TMP($J),^TMP("PSN",$J)
 S DA=4254
 F  S DA=$O(^PS(50.416,DA)) Q:'DA  S X=$P(^(DA,0),"^"),^TMP($J,X)="",DIK="^PS(50.416," D ^DIK
 ;
MESSAGE ;
 F LINE=1:1 S X=$P($T(TEXT+LINE),";",3,300) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X
 I '$D(^TMP($J)) S ^TMP("PSN",$J,LINE,0)="none found",LINE=LINE+1
 S NA="" F LINE=LINE:1 S NA=$O(^TMP($J,NA)) Q:NA=""  S ^TMP("PSN",$J,LINE,0)=NA
 ;
 ;
 ;now the interactions
 K ^TMP($J)
 ;
 S DA=14999 F  S DA=$O(^PS(56,DA)) Q:'DA  S X=^(DA,0),OLD=$P(X,"^") K PSN,PSNN D
 .S PSNI1=$P(X,"^",2),PSNI2=$P(X,"^",3) I '$D(^PS(50.416,PSNI1,0))!'$D(^PS(50.416,PSNI2,0)) S ^TMP($J,1,OLD)="",DIK="^PS(56," D ^DIK Q
 .S PSN($P(^PS(50.416,PSNI1,0),"^"))="",PSN($P(^PS(50.416,PSNI2,0),"^"))="",PSNN=$O(PSN(""))_"/"_$O(PSN($O(PSN("")))),PSNQ=0 I PSNN'=OLD D  Q:PSNQ
 ..S PSNN1=$P(PSNN,"/",2)_"/"_$P(PSNN,"/") I PSNN1=OLD S DIE="^PS(56,",DR=".01////"_PSNN D ^DIE Q
 ..S ^TMP($J,2,OLD)=PSNN,DIK="^PS(56," D ^DIK S PSNQ=1 Q
 .S X=$P(^PS(50.416,PSNI1,0),"^",2) I X S $P(^PS(56,DA,0),"^",2)=X,PSNI1=X
 .S X=$P(^PS(50.416,PSNI2,0),"^",2) I X S $P(^PS(56,DA,0),"^",3)=X,PSNI2=X
 .K PSN,PSNN S PSN($P(^PS(50.416,PSNI1,0),"^"))="",PSN($P(^PS(50.416,PSNI2,0),"^"))="",PSNN=$O(PSN(""))_"/"_$O(PSN($O(PSN("")))) I PSNN'=OLD S DIE="^PS(56,",DR=".01////"_PSNN_";" D
 ..I $O(^PS(56,"B",PSNN,0)),$O(^(0))'=DA S DIK="^PS(56," D ^DIK Q
 ..D ^DIE S ^TMP($J,3,OLD)=PSNN
 ;
 ;now the APD
 K ^PS(50.416,"APD") S DA=0 F  S DA=$O(^PS(50.416,DA)),K=0 Q:'DA  F  S K=$O(^PS(50.416,DA,1,K)) Q:'K  S X=^(K,0),^PS(50.416,"APD",X,DA)=""
 ;now the interactions
 K ^PS(56,"APD") S DA=0 F  S DA=$O(^PS(56,DA)) Q:'DA  K PSN1,PSN2 S PSN1=$P(^(DA,0),"^",2),PSN2=$P(^(0),"^",3) D
 .S NA="" F  S NA=$O(^PS(50.416,PSN1,1,"B",NA)) Q:NA=""  S PSN1(NA)=""
 .S PSN11=0 F  S PSN11=$O(^PS(50.416,"APS",PSN1,PSN11)),NA="" Q:'PSN11  F  S NA=$O(^PS(50.416,PSN11,1,"B",NA)) Q:NA=""  S PSN1(NA)=""
 .S NA="" F  S NA=$O(^PS(50.416,PSN2,1,"B",NA)) Q:NA=""  S PSN2(NA)=""
 .S PSN21=0 F  S PSN21=$O(^PS(50.416,"APS",PSN2,PSN21)),NA="" Q:'PSN21  F  S NA=$O(^PS(50.416,PSN21,1,"B",NA)) Q:NA=""  S PSN2(NA)=""
 .S PSN1="" F  S PSN1=$O(PSN1(PSN1)),PSN2="" Q:PSN1=""  F  S PSN2=$O(PSN2(PSN2)) Q:PSN2=""  S ^PS(56,"APD",PSN1,PSN2,DA)="",^PS(56,"APD",PSN2,PSN1,DA)=""
 ;
MORE ;MESSAGE CONTINUED
 F J=1:1 S X=$P($T(TEXT1+J),";",3) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X,LINE=LINE+1
 I '$D(^TMP($J,2)) S ^TMP("PSN",$J,LINE,0)="none found" S LINE=LINE+1
 S NA="" F  S NA=$O(^TMP($J,2,NA)) Q:NA=""  Q:NA="^"  S X=^(NA),^TMP("PSN",$J,LINE,0)="Name: "_NA,LINE=LINE+1,^TMP("PSN",$J,LINE,0)="Actual Ingredients: "_X,LINE=LINE+1,^TMP("PSN",$J,LINE,0)=" ",LINE=LINE+1
 ;
 ;
 F J=1:1 S X=$P($T(TEXT2+J),";",3) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X,LINE=LINE+1
 I $O(^TMP($J,1,""))="" S ^TMP("PSN",$J,LINE,0)="none found",LINE=LINE+1
 S NA="" F  S NA=$O(^TMP($J,1,NA)) Q:NA=""  S ^TMP("PSN",$J,LINE,0)=NA,LINE=LINE+1
 F J=1:1 S X=$P($T(TEXT2A+J),";",3) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X,LINE=LINE+1
 I $O(^TMP($J,3,""))="" S ^TMP("PSN",$J,LINE,0)="none found",LINE=LINE+1
 S NA="" F  S NA=$O(^TMP($J,3,NA)) Q:NA=""  S X=^(NA),^TMP("PSN",$J,LINE,0)="Interaction "_NA,LINE=LINE+1,^TMP("PSN",$J,LINE,0)="was changed to "_X,LINE=LINE+1,^TMP("PSN",$J,LINE,0)=" ",LINE=LINE+1
 ;
ALLER ;now the allergies
 I ^XMB("NETNAME")["CMOP" G INTER
 ;skip allergies for CMOPs
 K ^TMP($J)
 S PSNFREE=$O(^GMRD(120.82,"B","OTHER ALLERGY/ADVERSE REACTION",0))_";GMRD(120,82,"
 S PSNDA=0 F  S PSNDA=$O(^GMR(120.8,PSNDA)) Q:'PSNDA  S PSNPAT=+^(PSNDA,0),PSNPAT=$P(^DPT(PSNPAT,0),"^") D
 .S PSNI=$P(^GMR(120.8,PSNDA,0),"^",3) I PSNI["PS(50.416",'$D(^PS(50.416,+PSNI,0)) S $P(^GMR(120.8,PSNDA,0),"^",3)=PSNFREE S DIE="^GMR(120.8,",DA=PSNDA,DR="22////1;23////"_$$NOW^XLFDT_";24////"_DUZ_";" D ^DIE S ^TMP($J,2,PSNPAT)="" D
 ..D ADCOM^GMRAFX(PSNDA,"E","Marked entered in error by patch PSN*4*107")
 .I PSNI["PS(50.416",$D(^PS(50.416,+PSNI,0)),$P(^(0),"^",2) S PSNI=$P(^(0),"^",2)_";PS(50.416,",$P(^GMR(120.8,PSNDA,0),"^",3)=PSNI
 .S PSNK=0 F  S PSNK=$O(^GMR(120.8,PSNDA,2,PSNK)) Q:'PSNK  S PSNI=^(PSNK,0) D
 ..I '$D(^PS(50.416,PSNI,0)) S DA(1)=PSNDA,DA=PSNK,DIE="^GMR(120.8,DA(1),2,",DR=".01///@" D ^DIE S ^TMP($J,2,PSNPAT)="" Q
 ..S PSNX=$P(^PS(50.416,PSNI,0),"^",2) I PSNX S DA(1)=PSNDA,DA=PSNK,DIE="^GMR(120.8,DA(1),2,",DR=".01////"_$S($D(^GMR(120.8,DA(1),2,"B",PSNX)):"@",1:PSNX) D ^DIE S ^TMP($J,1,PSNPAT,$P(^PS(50.416,PSNI,0),"^")_"^"_$P(^PS(50.416,PSNX,0),"^"))=""
 ;
 F J=1:1 S X=$P($T(TEXT3+J),";",3,300) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X,LINE=LINE+1
 I '$D(^TMP($J,1)) S ^TMP("PSN",J,LINE,0)="none found",LINE=LINE+1
 S NA="" F  S NA=$O(^TMP($J,1,NA)) Q:NA=""  S X="" F  S X=$O(^TMP($J,1,NA,X)) Q:X=""  S ^TMP("PSN",$J,LINE,0)="Patient: "_NA,LINE=LINE+1,^TMP("PSN",$J,LINE,0)="Non-primary ingredient "_$P(X,"^"),LINE=LINE+1 D
 .S ^TMP("PSN",$J,LINE,0)="was replaced with primary ingredient "_$P(X,"^",2),LINE=LINE+1,^TMP("PSN",$J,LINE,0)=" ",LINE=LINE+1
 F J=1:1 S X=$P($T(TEXT5+J),";",3,300) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X,LINE=LINE+1
 I '$D(^TMP($J,2)) S ^TMP("PSN",$J,LINE,0)="none found",LINE=LINE+1
 S NA="" F  S NA=$O(^TMP($J,2,NA)) Q:NA=""  S ^TMP("PSN",$J,LINE,0)=NA,LINE=LINE+1
 ;
INTER K PSN1 S PSN2=$P($T(LIST),";",3) F J=1:1:$L(PSN2,"^")-1 S PSN1($P(PSN2,"^",J))=""
 K ^TMP($J) S DA=0 F  S DA=$O(^PS(56,DA)) Q:'DA  Q:DA>14999  I '$D(PSN1(DA)) S X=^(DA,0),OLD=$P(X,"^"),PSNI1=$P(X,"^",2),PSNI2=$P(X,"^",3) K PSN,PSNN D
 .S PSN($P(^PS(50.416,PSNI1,0),"^"))="",PSN($P(^PS(50.416,PSNI2,0),"^"))="",PSNN=$O(PSN(""))_"/"_$O(PSN($O(PSN("")))) I PSNN'=OLD S ^TMP($J,OLD_"^"_DA)=""
 F J=1:1 S X=$P($T(TEXT6+J),";",3,300) Q:X=""  S ^TMP("PSN",$J,LINE,0)=X,LINE=LINE+1
 I '$D(^TMP($J)) S ^TMP("PSN",$J,LINE,0)="none found",LINE=LINE+1
 S NA="" F  S NA=$O(^TMP($J,NA)) Q:NA=""  S ^TMP("PSN",$J,LINE,0)=$P(NA,"^",2) S $E(^(0),12)=$P(NA,"^"),LINE=LINE+1
SENDIT ;
 S XMSUB="INGREDIENTS AND INTERACTIONS DELETED",XMDUZ="NDF MANAGER",XMTEXT="^TMP(""PSN"",$J," K XMY S XMY(DUZ)="",XMY("G.NDF DATA@"_^XMB("NETNAME"))="",DA=0 F  S DA=$O(^XUSEC("PSNMGR",DA)) Q:'DA  S XMY(DA)=""
 N DIFROM D ^XMD
 K DA,DIE,DIK,DR,J,K,LINE,NA,OLD,PSN,PSN1,PSN11,PSN2,PSN21,PSNA1,PSNA2,PSNDA,PSNFREE,PSNI,PSNI1,PSNI2,PSNAPT,PSNPSNI1,PSNK,PSNX,PSNN,PSNN1,PSNQ,X,XMDUZ,XMSUB,XMTEXT,XMY,^TMP($J),^TMP("PSN",$J)
 Q
TEXT ;
 ;;The following locally added ingredients have been deleted from the
 ;;INGREDIENTS file (#50.416).
 ;; 
 ;
TEXT1 ;
 ;;============================================================================
 ;; 
 ;;The following locally added interactions have been deleted from the
 ;;DRUG INTERACTIONS file (#56) because they check for ingredients other
 ;;than those indicated by the name.
 ;; 
 ;; 
 ;  
 ;; 
TEXT2 ;
 ;;============================================================================
 ;; 
 ;;The following locally added interactions have been deleted from the
 ;;DRUG INTERACTIONS file (#56) because they involve locally entered
 ;;ingredients which have been deleted.
 ;; 
 ;; 
 ;
TEXT2A ;
 ;;========================================================================
 ;; 
 ;;The following locally added interactions have been edited because they
 ;;involved ingredients that are not primary ingredients.
 ;; 
 ;; 
 ;; 
 ;
TEXT3 ; 
 ;; 
 ;;============================================================================
 ;;Allergy information for the following patients has been changed.
 ;; 
 ;;The allergy for the listed patients was created with a non-primary
 ;;ingredient.  These have been updated to replace the non-primary
 ;;ingredient with the proper primary ingredient.
 ;;  
TEXT5 ;
 ;; 
 ;;========================================================================
 ;;The patient allergy entries for the listed patients were created with
 ;;locally added ingredients.  Locally added ingredients are not supported
 ;;by the software and the allergies have been updated to 'entered in error'.
 ;;The patient allergy entry should be reviewed.
 ;; 
 ;
TEXT6 ;
 ;; 
 ;;========================================================================
 ;;  
 ;;The following nationally entered interactions have a discrepancy
 ;;between the name and the ingredients.  Please submit a remedy ticket
 ;;and attach the information in this section so that the proper cleanup
 ;;can be done.
 ;; 
 ;;IEN          Interaction
 ;; 
 ;
LIST ;;2084^2085^2086^2087^2088^2089^2090^2091^2092^2093^2094^2095^2096^2136^2237^2238^2239^2244^2289^