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