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

ABSPICNV.m

Go to the documentation of this file.
  1. ABSPICNV ; IHS/OIT/CASSevern/Pieran ran 2/24/2011 - Convert Insurance Profiles based on Formats
  1. ;;1.0;PHARMACY POINT OF SALE;**D.0,48**;JUN 21, 2001;Build 38
  1. ;
  1. ; This routine will go through each ABSP Insurer entry and get the information off the corresponding Format and populate the necessary entries in the insurer file
  1. EN ;EP
  1. N ABSPINS,ABSPFMT
  1. I $D(^ABSP(9002313.99,1,"ABSPICNV")) Q ;TESTING ONLY => D REVERSE ;This conversion program has already been run...reverse it before running again
  1. S ABSPINS=0
  1. F S ABSPINS=$O(^ABSPEI(ABSPINS)) Q:ABSPINS="" D
  1. . S ABSPFMT=$P($G(^ABSPEI(ABSPINS,100)),U)
  1. . Q:'ABSPFMT
  1. . D PROCESS(ABSPINS,ABSPFMT)
  1. S ^ABSP(9002313.99,1,"ABSPICNV")=1 ;This is how we know if this conversion has been run or not.
  1. Q
  1. PROCESS(ABSPINS,ABSPFMT) ;Process the format here
  1. N ABSPBIN,ABSPPCN,ABSPMPD,ABSPVER,ABSPMAX,ABSPDISP,ABSPCONT,ABSPEXCL,ABSPHELP,ABSPSPEC,ABSPSPSG,ABSPSPFL
  1. D GETINFO(ABSPFMT)
  1. D POPTOP(ABSPINS,ABSPBIN,ABSPPCN,ABSPMPD,ABSPVER,ABSPMAX,ABSPDISP,ABSPCONT,ABSPEXCL,ABSPHELP)
  1. D POPSPEC(ABSPINS,.ABSPSPEC)
  1. D POPSEG(ABSPINS,.ABSPSPSG)
  1. D POPFLD(ABSPINS,.ABSPSPFL)
  1. Q
  1. GETINFO(ABSPFMT)
  1. N ABSPFARY,ABSPINCL,ABSPSUPP
  1. D GETS^DIQ(9002313.92,ABSPFMT_",","**","","ABSPFARY")
  1. S ABSPBIN=ABSPFARY(9002313.92,ABSPFMT_",",1.01)
  1. S ABSPPCN=ABSPFARY(9002313.92,ABSPFMT_",",1.3)
  1. S ABSPVER=5.1
  1. S ABSPHELP=ABSPFARY(9002313.92,ABSPFMT_",",1.05)
  1. S ABSPMPD=ABSPFARY(9002313.92,ABSPFMT_",",1.2)
  1. S:ABSPMPD="" ABSPMPD="N"
  1. S ABSPMAX=ABSPFARY(9002313.92,ABSPFMT_",",1.03)
  1. S ABSPDISP=ABSPFARY(9002313.92,ABSPFMT_",",1.08)
  1. S ABSPCONT=ABSPFARY(9002313.92,ABSPFMT_",",1.09)
  1. S ABSPEXCL=ABSPFARY(9002313.92,ABSPFMT_",",1.1)
  1. D GETSUPSEGS(.ABSPFARY,.ABSPSPSG)
  1. D GETSPEFLDS(.ABSPFARY,.ABSPSPEC)
  1. D GETSUPFLDS(.ABSPFARY,.ABSPSPSG,.ABSPSPFL)
  1. Q
  1. GETINCFLDS(ABSPFARY,ABSPINCL) ;Get list of all fields included on this format
  1. N ARR
  1. S ARR="ABSPFARY(9002313.9205)"
  1. F S ARR=$Q(@ARR) Q:ARR'["ABSPFARY(9002313" S:($QS(ARR,3)=.02)&&(@ARR'="") ABSPINCL(@ARR)=""
  1. Q
  1. GETSPEFLDS(ABSPFARY,ABSPSPEC) ;Get list of all fields requiring special coding
  1. N ARR
  1. S ARR="ABSPFARY(9002313.9205)"
  1. F S ARR=$Q(@ARR) Q:ARR'["ABSPFARY(9002313" D:($QS(ARR,3)=.03)&&(@ARR="SPECIAL")
  1. . N LINE,X,Y
  1. . S LINE=0
  1. . F S LINE=$O(ABSPFARY($QS(ARR,1),$QS(ARR,2),1,LINE)) Q:LINE="" D
  1. . . S X=ABSPFARY($QS(ARR,1),$QS(ARR,2),1,LINE),X=$P(X,";") F S Y=$E(X,$L(X)) Q:Y'=" " S X=$E(X,1,$L(X)-1)
  1. . . I LINE=1 S ABSPSPEC(ABSPFARY($QS(ARR,1),$QS(ARR,2),.02))=X
  1. . . ELSE S ABSPSPEC(ABSPFARY($QS(ARR,1),$QS(ARR,2),.02))=ABSPSPEC(ABSPFARY($QS(ARR,1),$QS(ARR,2),.02))_" "_X
  1. Q
  1. GETSUPSEGS(ABSPFARY,ABSPSPSG) ;Get list of all Segments to be suppressed
  1. I '$D(ABSPFARY(9002313.9209)) S ABSPSPSG(2)="" ;Suppress Provider Segment
  1. I '$D(ABSPFARY(9002313.9213)) S ABSPSPSG(5)="" ;Suppress COB Segment
  1. I '$D(ABSPFARY(9002313.9214)) S ABSPSPSG(6)="" ;Suppress Workers Comp Segment
  1. I '$D(ABSPFARY(9002313.9215)) S ABSPSPSG(8)="" ;Suppress DURR/PPS Segment
  1. I '$D(ABSPFARY(9002313.9217)) S ABSPSPSG(9)="" ;Suppress Coupon Segment
  1. I '$D(ABSPFARY(9002313.9218)) S ABSPSPSG(10)="" ;Suppress Compound Segment
  1. I '$D(ABSPFARY(9002313.9219)) S ABSPSPSG(12)="" ;Suppress Prior Auth Segment
  1. I '$D(ABSPFARY(9002313.922)) S ABSPSPSG(13)="" ;Suppress Clinical Segment
  1. ;Since these are new segments in D.0 We'll have to suppress them all for now
  1. S ABSPSPSG(14)="" ;Suppress Additional Doc Segment
  1. S ABSPSPSG(15)="" ;Suppress Facility Segment
  1. S ABSPSPSG(16)="" ;Suppress Narrative Segment
  1. Q
  1. GETSUPFLDS(ABSPFARY,ABSPSPSG,ABSPSPFL) ;Get list of all fields to be suppressed
  1. N FLDARR,FLDNUM,NCPDPFLD,ABSPINCL,SEG,SEGMENT,SEGFLDS
  1. S SEG("CLAIM")="455^402^436^407^456^457^458^459^415^419^354^420^460^308^429^453^445^446^330^454^600^418^461^462^463^464^343^344^345^357^391^995^996^147^114"
  1. S SEG("PATIENT")="331^332^310^322^323^324^325^326^307^333^334^335^350^384"
  1. S SEG("INSURANCE")="302^312^313^314^524^309^301^303^306^359^360^361^997^115^116"
  1. S SEG("PRESCRIBER")="466^411^467^427^498^468^421^469^470^364^365^366^367^368"
  1. S SEG("PRICING")="433^438^478^479^480^481^482^483^484^426^423^113"
  1. S SEG("COB")="337^338^339^340^443^993^341^342^431^471^472^353^351^352^392^393^394"
  1. S SEG("WORKCOMP")="434^315^316^317^318^319^320^321^327^435^117^118^119^120^121^122^123^124^125^126"
  1. S SEG("DURRPPS")="473^439^440^441^474^475^476"
  1. S SEG("COUPON")="485^486^487"
  1. S SEG("COMPOUND")="450^451^452^447^488^489^448^449^490^362^363"
  1. S SEG("CLINICAL")="491^492^424^493^494^495^496^497^499"
  1. S SEG("PRIORAUTH")="498.01^498.02^498.03^498.04^498.05^498.06^498.07^498.08^498.09^498.11^498.13^498.14^503"
  1. S SEG("PROVIDER")="465^444"
  1. ;No reason to do these...they are new to D.0 and won't exist on ANY Format.
  1. ;S SEG("ADDOC")="369^374^375^373^371^370^372^376^377^378^379^380^381^382^383"
  1. ;S SEG("FACILITY")="336^385^386^388^387^389"
  1. ;S SEG("NARRATIVE")="390"
  1. ;First set up an array of all NCPDP FIELDS currently on this format
  1. D GETINCFLDS(.ABSPFARY,.ABSPINCL)
  1. ;Now go through the list of all possible fields and suppress any that aren't on the format currently and aren't on an already suppressed SEGMENT
  1. S SEGMENT=""
  1. F S SEGMENT=$O(SEG(SEGMENT)) Q:SEGMENT="" D
  1. . S SEGFLDS=SEG(SEGMENT)
  1. . F I=1:1:$L(SEGFLDS,"^") D
  1. . . S NCPDPFLD=$P(SEGFLDS,"^",I)
  1. . . ;B:NCPDPFLD=301
  1. . . ;These Segments are all mandatory...and therefore can't be suppressed
  1. . . I "^CLAIM^PATIENT^INSURANCE^PRESCRIBER^PRICING^"[("^"_SEGMENT_"^") D
  1. . . . I '$D(ABSPINCL(NCPDPFLD)) S ABSPSPFL(NCPDPFLD)=""
  1. . . ;If the Segment is already suppressed don't waste time and disk space suppressing the individual field
  1. . . ELSE D
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="COB")&&('$D(ABSPSPSG(5))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="WORKCOMP")&&('$D(ABSPSPSG(6))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="DURRPPS")&&('$D(ABSPSPSG(8))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="COUPON")&&('$D(ABSPSPSG(9))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="COMPOUND")&&('$D(ABSPSPSG(10))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="CLINICAL")&&('$D(ABSPSPSG(5))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="PRIORAUTH")&&('$D(ABSPSPSG(12))) S ABSPSPFL(NCPDPFLD)=""
  1. . . . I ('$D(ABSPINCL(NCPDPFLD)))&&(SEGMENT="PROVIDER")&&('$D(ABSPSPSG(2))) S ABSPSPFL(NCPDPFLD)=""
  1. Q
  1. POPTOP(ABSPINS,ABSPBIN,ABSPPCN,ABSPMPD,ABSPVER,ABSPMAX,ABSPDISP,ABSPCONT,ABSPEXCL,ABSPHELP) ;Populate things that go on top level of Insurance
  1. N INS,CURHELP,ZERR ; /IHS/OIT/RAM ; 9 JUN 17 ; ADD DBS CALL ERROR RETURN VARIABLE
  1. S CURHELP=$$GET1^DIQ(9002313.4,ABSPINS_",",100.05)
  1. I CURHELP="" S INS(1,9002313.4,ABSPINS_",",100.05)=ABSPHELP ;Don't over-write if they already have this field on the Insurer
  1. S INS(1,9002313.4,ABSPINS_",",100.15)=ABSPVER
  1. S INS(1,9002313.4,ABSPINS_",",100.16)=ABSPBIN
  1. S INS(1,9002313.4,ABSPINS_",",100.17)=ABSPPCN
  1. S INS(1,9002313.4,ABSPINS_",",100.18)=ABSPMPD
  1. S INS(1,9002313.4,ABSPINS_",",100.19)=ABSPMAX
  1. S INS(1,9002313.4,ABSPINS_",",100.2)=ABSPDISP
  1. S INS(1,9002313.4,ABSPINS_",",100.3)=ABSPCONT
  1. S INS(1,9002313.4,ABSPINS_",",100.4)=ABSPEXCL
  1. ; D UPDATE^DIE("E","INS(1)")
  1. D UPDATE^DIE("E","INS(1)",,"ZERR") ; /IHS/OIT/RAM ; 9 JUN 17 ; UPDATE DBS CALL TO ALLOW FOR ERROR RETURN.
  1. I $D(ZERR) D LOG^ABSPOSL2("POPTOP^ABSPICNV",.ZERR) ; /IHS/OIT/RAM ; 9 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
  1. Q
  1. POPSPEC(ABSPINS,ABSPSPEC) ;Now populate the Special Code stuff
  1. N NCPDPCD,INS,STRING,ZERR ; /IHS/OIT/RAM ; 9 JUN 17 ; ADD DBS CALL ERROR RETURN VARIABLE
  1. S NCPDPCD=""
  1. F S NCPDPCD=$O(ABSPSPEC(NCPDPCD)) Q:NCPDPCD="" D
  1. . Q:(NCPDPCD=111)!(NCPDPCD=103) ;These are the fields that can't be overriden
  1. . S STRING=$TR(ABSPSPEC(NCPDPCD),"^","|") ;Fileman won't store this string with a ^ (caret) in it
  1. . S INS(1,9002313.42,"+1,"_ABSPINS_",",.01)=NCPDPCD
  1. . S INS(1,9002313.42,"+1,"_ABSPINS_",",.02)=STRING
  1. . ; D UPDATE^DIE("E","INS(1)")
  1. . D UPDATE^DIE("E","INS(1)",,"ZERR") ; /IHS/OIT/RAM ; 9 JUN 17 ; UPDATE DBS CALL TO ALLOW FOR ERROR RETURN.
  1. . I $D(ZERR) D LOG^ABSPOSL2("POPSPEC^ABSPICNV",.ZERR) ; /IHS/OIT/RAM ; 9 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
  1. Q
  1. POPSEG(ABSPINS,ABSPSPSG) ;Next we populate the suppressed segments
  1. N SEGCD,INS,ZERR ; /IHS/OIT/RAM ; 9 JUN 17 ; ADD DBS CALL ERROR RETURN VARIABLE
  1. S SEGCD=""
  1. F S SEGCD=$O(ABSPSPSG(SEGCD)) Q:SEGCD="" D
  1. . S INS(1,9002313.48,"+1,"_ABSPINS_",",.01)=SEGCD
  1. . ; D UPDATE^DIE("","INS(1)") ;On this one we are using the Internal value
  1. . D UPDATE^DIE("","INS(1)",,"ZERR") ; /IHS/OIT/RAM ; 9 JUN 17 ; UPDATE DBS CALL TO ALLOW FOR ERROR RETURN.
  1. . I $D(ZERR) D LOG^ABSPOSL2("POPSEG^ABSPICNV",.ZERR) ; /IHS/OIT/RAM ; 9 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
  1. Q
  1. POPFLD(ABSPINS,ABSPSPFL) ;Next we populate the suppressed fields
  1. N NCPDPCD,ZERR ; /IHS/OIT/RAM ; 9 JUN 17 ; ADD DBS CALL ERROR RETURN VARIABLE
  1. S NCPDPCD=""
  1. F S NCPDPCD=$O(ABSPSPFL(NCPDPCD)) Q:NCPDPCD="" D
  1. . S INS(1,9002313.46,"+1,"_ABSPINS_",",.01)=NCPDPCD
  1. . ; D UPDATE^DIE("E","INS(1)")
  1. . D UPDATE^DIE("E","INS(1)",,"ZERR") ; /IHS/OIT/RAM ; 9 JUN 17 ; UPDATE DBS CALL TO ALLOW FOR ERROR RETURN.
  1. . I $D(ZERR) D LOG^ABSPOSL2("POPFLD^ABSPICNV",.ZERR) ; /IHS/OIT/RAM ; 9 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
  1. Q
  1. REVERSE
  1. N ABSPINS,ABSPFMT
  1. S ABSPINS=0
  1. F S ABSPINS=$O(^ABSPEI(ABSPINS)) Q:ABSPINS="" D
  1. . S ABSPFMT=$P($G(^ABSPEI(ABSPINS,100)),U)
  1. . Q:'ABSPFMT
  1. . K ^ABSPEI(ABSPINS,210)
  1. . K ^ABSPEI(ABSPINS,220)
  1. . K ^ABSPEI(ABSPINS,221)
  1. S ^ABSP(9002313.99,1,"ABSPICNV")=0 ;This is how we know if this conversion has been run or not.
  1. Q