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

PSSNDCUT.m

Go to the documentation of this file.
  1. PSSNDCUT ;BIRM/MFR - NDC Utilities ;10/15/04
  1. ;;1.0;PHARMACY DATA MANAGEMENT;**90**;9/30/97
  1. ;
  1. SAVNDC(DRG,SITE,NDC,CMP) ; Saves the NDC in the DRUG file (Format: 5-4-2)
  1. ; Input: (r) DRG - Drug IEN (#50)
  1. ; (r) SITE - Outpatient Site IEN (#59)
  1. ; (r) NDC - NDC Number
  1. ; (o) CMP - CMOP? (1-YES/0-NO)
  1. N RFL,DIE,DIC,DA,DR,I,DD,DO,DINUM,X,Y
  1. ;
  1. S NDC=$$NDCFMT(NDC) I NDC="" Q
  1. ;
  1. ;- Saving the NDC in the DRUG file (#50)
  1. I '$D(^PSDRUG(DRG,"NDCOP",SITE)) D
  1. . S DIC="^PSDRUG("_DRG_",""NDCOP"","
  1. . S (X,DINUM)=SITE,DA(1)=DRG,DIC(0)=""
  1. . K DD,DO D FILE^DICN K DD,DO,DINUM,Y
  1. ;
  1. K DA,DIE,DR S DIE="^PSDRUG("_DRG_",""NDCOP"","
  1. S DA(1)=DRG,DA=SITE,DR=$S($G(CMP):2,1:1)_"///"_NDC
  1. D ^DIE
  1. Q
  1. ;
  1. GETNDC(DRG,SITE,CMOP) ; Retuns the NDC for a specific Drug/Site/CMOP or NON-CMOP
  1. N NDC,NDF
  1. ;
  1. I '$D(CMOP) S CMOP=$S($D(^PSDRUG("AQ",DRG)):1,1:0)
  1. ; - LOCAL NDC by DIVISION
  1. I $G(SITE),'CMOP S NDC=$$NDCFMT($$GET1^DIQ(50.032,SITE_","_DRG,1)) I NDC'="" Q NDC
  1. ; - CMOP NDC by DIVISION
  1. I $G(SITE),CMOP S NDC=$$NDCFMT($$GET1^DIQ(50.032,SITE_","_DRG,2)) I NDC'="" Q NDC
  1. ; - Drug File NDC
  1. S NDC=$$NDCFMT($$GET1^DIQ(50,DRG,31)) I NDC'="" Q NDC
  1. ; - National Drug File NDC
  1. I NDC="" S NDF=+$$GET1^DIQ(50,DRG,22,"I") I NDF'="" S NDC=$$NDCFMT($$GET1^DIQ(50.68,NDF,13)) I NDC'="" Q NDC
  1. Q NDC
  1. ;
  1. NDCFMT(NDC) ; Formats NDC codes into 5-4-2
  1. N S1,S2,S3
  1. I '$$CHKCH(NDC) Q ""
  1. I NDC?.N,NDC'?11N Q ""
  1. I NDC?11N Q ($E(NDC,1,5)_"-"_$E(NDC,6,9)_"-"_$E(NDC,10,11))
  1. ;
  1. I $L(NDC,"-")'=3 Q ""
  1. S S1=$P(NDC,"-"),S2=$P(NDC,"-",2),S3=$P(NDC,"-",3)
  1. I '$L(S1)!'$L(S2)!'$L(S3) Q ""
  1. I $L(S1)>6!($L(S2)>4)!($L(S3)>2) Q ""
  1. ;
  1. S:$L(S1)>5 S1=$E(S1,$L(S1)-4,$L(S1))
  1. S:$L(S1)<5 S1=$E(S1+100000,2,6)
  1. S S2=$E(S2+10000,2,5)
  1. S S3=$E(S3+100,2,3)
  1. ;
  1. Q (S1_"-"_S2_"-"_S3)
  1. ;
  1. CHKCH(STR) ; Checks characters different from "-" and numbers
  1. N CHKCH
  1. I STR="" Q 0
  1. S CHKCH=1 F I=1:1:$L(STR) I $E(STR,I)'?1N,$E(STR,I)'?1"-" S CHKCH=0 Q
  1. Q CHKCH