21. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 11/9/2017 4:31:02 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

21.1 Files compared

# Location File Last Modified
1 PPS-N_B397.zip\PPS-N_B397\PPS-N_B397\PS_PPS_domain\src\main\java\gov\va\med\pharmacy\peps\domain\common\utility\client\rxnorm RxNormClient.java Thu Nov 9 15:06:54 2017 UTC
2 PPS-N_B397.zip\PPS-N_B397\PPS-N_B397\PS_PPS_domain\src\main\java\gov\va\med\pharmacy\peps\domain\common\utility\client\rxnorm RxNormClient.java Thu Nov 9 19:38:47 2017 UTC

21.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 532
Changed 1 2
Inserted 0 0
Removed 0 0

21.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

21.4 Active regular expressions

No regular expressions were active.

21.5 Comparison detail

  1   package go v.va.med.p harmacy.pe ps.domain. common.uti lity.clien t.rxnorm;
  2  
  3   import jav a.security .cert.Cert ificateExc eption;
  4   import jav a.security .cert.X509 Certificat e;
  5   import jav a.util.Arr ayList;
  6   import jav a.util.Col lections;
  7   import jav a.util.Com parator;
  8   import jav a.util.Has hMap;
  9   import jav a.util.Lis t;
  10   import jav a.util.Map ;
  11   import jav a.util.UUI D;
  12  
  13   import jav ax.net.ssl .SSLContex t;
  14   import jav ax.net.ssl .TrustMana ger;
  15   import jav ax.net.ssl .X509Trust Manager;
  16  
  17   import org .springfra mework.htt p.client.H ttpCompone ntsClientH ttpRequest Factory;
  18   import org .springfra mework.web .client.Re stTemplate ;
  19  
  20   import gov .va.med.ph armacy.pep s.common.u tility.Con figFileUti lity;
  21   import gov .vha.isaac .rest.api1 .data.sear ch.RestSea rchResultP age;
  22   import gov .vha.isaac .rest.api1 .data.seme me.RestDyn amicSememe Version;
  23   import gov .vha.isaac .rest.api1 .data.seme me.RestSem emeDescrip tionVersio n;
  24  
  25   /**
  26    * This cl ass handle s the proc ess of kee ping RxNor m data up  to date on  the EPL_P RODUCTS ta ble. It us es two web  service c alls to
  27    * ISAAC a nd the pro duct DAO t o populate  the data  into the a ppropriate  columns.
  28    * 
  29    * @author  
D NS     RUSTRA
  30    *
  31    */
  32   public cla ss RxNormC lient {
  33  
  34       privat e static f inal UUID  SUPPRESS_U UID = UUID .fromStrin g("3e51fab 1-34ec-534 6-af99-c62 baec1f675" );
  35       privat e static f inal UUID  NOT_SUPPRE SIBBLE_UUI D = UUID.f romString( "8277b5c7- 5720-5eea- b802-8ad3f 28c9bf7");
  36  
  37       privat e static f inal UUID  SAB_UUID =  UUID.from String("bc c300c0-034 7-5c11-80c b-9fb7497e 44de");
  38       privat e static f inal UUID  RXNORM_UUI D = UUID.f romString( "d9e4f663- 497a-5da7- 8b4c-2846b 86c6971");
  39  
  40       privat e static f inal UUID  SCD_UUID =  UUID.from String("76 de667d-54c a-55a4-ba7 2-21a7e257 c928");
  41       privat e static f inal UUID  PSN_UUID =  UUID.from String("6e cd2b47-d1e e-571a-b21 c-7abda21c 9207");
  42       privat e static f inal UUID  SBD_UUID =  UUID.from String("9b e227c1-c7e 2-582f-b39 1-13ae1ffb 3e7c");
  43       privat e static f inal UUID  BPACK_UUID  = UUID.fr omString(" 02507be6-9 971-5c05-9 01a-cfcda4 eb0eb5");
  44       privat e static f inal UUID  GPACK_UUID  = UUID.fr omString(" 4bbeba6f-d 765-54e0-9 c58-6fe0f7 4d73e2");
  45  
  46       privat e static f inal Strin g NOT_SUPP RESSIBLE_S TRING = "N ot Suppres sible";
  47       privat e static f inal int S CD_RANK =  5;
  48       privat e static f inal int P SN_RANK =  4;
  49       privat e static f inal int S BD_RANK =  3;
  50       privat e static f inal int G PACK_RANK  = 2;
  51       privat e static f inal int B PACK_RANK  = 1;
  52  
  53       privat e static f inal Strin g VUID_PAR AM = "VUID ";
  54       privat e static f inal Strin g UUID_PAR AM = "UUID ";
  55       
  56       privat e static f inal org.a pache.logg ing.log4j. Logger LOG  = org.apa che.loggin g.log4j.Lo gManager.g etLogger(
  57           Rx NormClient .class);     
  58       
  59       /**
  60        * Cal ls the ISA AC web ser vice passi ng a produ ct VUID an d returnin g the Code  System Co de if the  web servic e contains  one for
  61        * the  given VUI D. Returns  null if n o code exi sts for th e VUID.
  62        *
  63        * @pa ram vuid S tring prop erty
  64        * @pa ram config File the c onfig file  utility
  65        * @re turn Strin g
  66        */
  67       public  String ge tCode(Stri ng vuid, C onfigFileU tility con figFile) {
  68           if  (vuid !=  null) {
  69                Map<Stri ng, String > params =  new HashM ap<String,  String>() ;
  70                params.p ut(VUID_PA RAM, vuid) ;
  71                RestTemp late restT emplate =  new RestTe mplate();
  72                restTemp late.setRe questFacto ry(new Htt pComponent sClientHtt pRequestFa ctory());
  73  
  74                RestSear chResultPa ge restSea rchResultP age = rest Template.g etForObjec t(configFi le.getIsaa cCodingCon ceptURL(),
  75                    Rest SearchResu ltPage.cla ss, params );
  76  
  77                if (rest SearchResu ltPage !=  null && re stSearchRe sultPage.g etResults( ) != null
  78                    && r estSearchR esultPage. getResults ().length  > 0
  79                    && r estSearchR esultPage. getResults ()[0].getR eferencedC oncept() ! = null) {
  80  
  81                    UUID  uuid = re stSearchRe sultPage.g etResults( )[0].getRe ferencedCo ncept().ge tIdentifie rs().getUu ids().get( 0);
  82                    para ms.clear() ;
  83                    para ms.put(UUI D_PARAM, S tring.valu eOf(uuid.t oString()) );
  84  
  85                    Rest DynamicSem emeVersion  restDynam icSememeVe rsion[] =  restTempla te
  86                         .getForObj ect(config File.getIs aacCodingC omponentUR L(), RestD ynamicSeme meVersion[ ].class, p arams);
  87  
  88                    if ( restDynami cSememeVer sion != nu ll && rest DynamicSem emeVersion .length >  0
  89                         && restDyn amicSememe Version[0] .getDataCo lumns() !=  null
  90                         && !restDy namicSemem eVersion[0 ].getDataC olumns().i sEmpty())  {
  91                         String obj ect = (Str ing) restD ynamicSeme meVersion[ 0].getData Columns(). get(0).get Data().toS tring();
  92                         return obj ect;
  93                    }
  94                }
  95           }
  96           re turn null;
  97       }
  98  
  99       /**
  100        * Cal ls the ISA AC web ser vice passi ng a produ ct VUID an d returnin g the rela ted RXNorm  informati on if the  web servic e
  101        * con tains one  for the gi ven VUID.  Returns nu ll if no r ecord for  that produ ct exists  or the pie ces of dat a that it  actually
  102        * fin ds.
  103        * 
  104        * @pa ram vuid S tring prop erty
  105        * @pa ram config File the c onfig file  utility
  106        * @re turn Strin g
  107        */
  108       public  RxNormDat a getRxNor mData(Stri ng vuid, C onfigFileU tility con figFile) {
  109           Rx NormData r esult = nu ll;
  110           if  (vuid !=  null) {
  111                Map<Stri ng, String > params =  new HashM ap<String,  String>() ;
  112                params.p ut(VUID_PA RAM, vuid) ;
  113                RestTemp late restT emplate =  new RestTe mplate();
  114                restTemp late.setRe questFacto ry(new Htt pComponent sClientHtt pRequestFa ctory());
  115  
  116                RestSear chResultPa ge restSea rchResultP age = rest Template.g etForObjec t(configFi le.getIsaa cCodingCon ceptURL(),
  117                    Rest SearchResu ltPage.cla ss, params );
  118  
  119                // Get t he product  name.
  120                if (rest SearchResu ltPage !=  null && re stSearchRe sultPage.g etResults( ) != null
  121                    && r estSearchR esultPage. getResults ().length  > 0
  122                    && r estSearchR esultPage. getResults ()[0].getR eferencedC oncept() ! = null) {
  123  
  124                    resu lt = new R xNormData( );
  125                    resu lt.setProd uctName(re stSearchRe sultPage.g etResults( )[0].getRe ferencedCo ncept().ge tDescripti on());
  126  
  127                    UUID  uuid = re stSearchRe sultPage.g etResults( )[0].getRe ferencedCo ncept().ge tIdentifie rs().getUu ids().get( 0);
  128                    para ms.clear() ;
  129                    para ms.put(UUI D_PARAM, S tring.valu eOf(uuid.t oString()) );
  130  
  131                    // G et the des criptions  to obtain  the TTY in formation.
  132                    Rest SememeDesc riptionVer sion[] des criptions  = restTemp late
  133                         .getForObj ect(config File.getIs aacCodingD escription sURL(), Re stSememeDe scriptionV ersion[].c lass, para ms);
  134  
  135                    List <RestSemem eDescripti onVersion>  potential Descriptio ns = getPo tentialDes cription(d escription s);
  136  
  137                    if ( !potential Descriptio ns.isEmpty ()) {
  138                         Collection s.sort(pot entialDesc riptions,  new Descri ptionSorte r());
  139                         result.set Suppress(N OT_SUPPRES SIBLE_STRI NG);
  140                         result.set Tty(typeTo String(pot entialDesc riptions.g et(0).getD escription ExtendedTy peConcept( ).getUuids ()));
  141                    }
  142  
  143                }
  144           }
  145                    
  146           if  (result = = null){
  147                LOG.debu g("No RXNo rm Data Fo und.");
  148           }
  149           
  150           re turn resul t;
  151       }
  152  
  153       /**
  154        * Get  the poten tial descr iptions wh ere we can  find the  TTY inform ation in t he calling  method.
  155        * @pa ram descri ptionVersi ons
  156        * @re turn
  157        */
  158       privat e List<Res tSememeDes criptionVe rsion> get PotentialD escription (RestSemem eDescripti onVersion[ ] descript ionVersion s) {
  159           Ar rayList<Re stSememeDe scriptionV ersion> po tentialDes criptionVe rsions = n ew ArrayLi st<>();
  160           fo r (RestSem emeDescrip tionVersio n d : desc riptionVer sions) {
  161                boolean  sabIsRxNor m = false;
  162                boolean  suppressIs N = false;
  163                for (Res tDynamicSe memeVersio n ns : d.g etNestedSe memes()) {
  164                    if ( ns.getSeme meChronolo gy().getAs semblage() .getUuids( ).contains (SUPPRESS_ UUID)
  165                         && ns.getD ataColumns ().get(0). getData(). toString() .equals(NO T_SUPPRESI BBLE_UUID. toString() )) {
  166                         suppressIs N = true;
  167                    }
  168                    if ( ns.getSeme meChronolo gy().getAs semblage() .getUuids( ).contains (SAB_UUID)
  169                         && ns.getD ataColumns ().get(0). getData(). toString() .equals(RX NORM_UUID. toString() )) {
  170                         sabIsRxNor m = true;
  171                    }
  172                    if ( suppressIs N && sabIs RxNorm) {
  173                         potentialD escription Versions.a dd(d);
  174                         break;
  175                    }
  176                }
  177           }
  178           re turn poten tialDescri ptionVersi ons;
  179       }
  180  
  181       privat e static S tring type ToString(L ist<UUID>  uuids) {
  182           if  (uuids.co ntains(SCD _UUID)) {
  183                return " SCD";
  184           }
  185           if  (uuids.co ntains(PSN _UUID)) {
  186                return " PSN";
  187           }
  188           if  (uuids.co ntains(SBD _UUID)) {
  189                return " SBD";
  190           }
  191           if  (uuids.co ntains(GPA CK_UUID))  {
  192                return " GPACK";
  193           }
  194           if  (uuids.co ntains(BPA CK_UUID))  {
  195                return " BPACK";
  196           }
  197           re turn null;
  198       }
  199  
  200       /**
  201        * Thi s method i s used to  bypass the  SSL certi ficate che cking. TO- DO: We nee d to work  with the I SAAC group  to get th e
  202        * cor rect certi ficates.
  203        */
  204       privat e static v oid trustS elfSignedS SL() {
  205           tr y {
  206                SSLConte xt ctx = S SLContext. getInstanc e("TLS");
  207                X509Trus tManager t m = new X5 09TrustMan ager() {
  208  
  209                    @Ove rride
  210                    publ ic void ch eckClientT rusted(X50 9Certifica te[] chain , String a uthType) t hrows Cert ificateExc eption {
  211                         // Do Noth ing
  212                    }
  213  
  214                    @Ove rride
  215                    publ ic void ch eckServerT rusted(X50 9Certifica te[] chain , String a uthType) t hrows Cert ificateExc eption {
  216                         // Do Noth ing
  217                    }
  218  
  219                    @Ove rride
  220                    publ ic X509Cer tificate[]  getAccept edIssuers( ) {
  221                         return nul l;
  222                    }
  223                };
  224                ctx.init (null, new  TrustMana ger[] { (T rustManage r) tm }, n ull);
  225                SSLConte xt.setDefa ult(ctx);
  226           }  catch (Exc eption ex)  {
  227                ex.print StackTrace ();
  228           }
  229       }
  230  
  231       /**
  232        * Ini tializes t he class w hen instan tiated by  Spring.
  233        */
  234       public  void init () {
  235           tr ustSelfSig nedSSL();
  236       }
  237  
  238       privat e class De scriptionS orter impl ements Com parator<Re stSememeDe scriptionV ersion> {
  239  
  240           //  Ranking:  SCD > PSN  > SBD > GP ACK > BPAC K
  241           pr ivate int  getRank(Re stSememeDe scriptionV ersion d)  {
  242                if (d.ge tDescripti onExtended TypeConcep t().getUui ds().conta ins(RxNorm Client.SCD _UUID)) {
  243                    retu rn SCD_RAN K;
  244                }
  245                if (d.ge tDescripti onExtended TypeConcep t().getUui ds().conta ins(RxNorm Client.PSN _UUID)) {
  246                    retu rn PSN_RAN K;
  247                }
  248  
  249                if (d.ge tDescripti onExtended TypeConcep t().getUui ds().conta ins(RxNorm Client.SBD _UUID)) {
  250                    retu rn SBD_RAN K;
  251                }
  252                if (d.ge tDescripti onExtended TypeConcep t().getUui ds().conta ins(RxNorm Client.GPA CK_UUID))  {
  253                    retu rn GPACK_R ANK;
  254                }
  255                if (d.ge tDescripti onExtended TypeConcep t().getUui ds().conta ins(RxNorm Client.BPA CK_UUID))  {
  256                    retu rn BPACK_R ANK;
  257                }
  258                return 0 ;
  259           }
  260  
  261           @O verride
  262           pu blic int c ompare(Res tSememeDes criptionVe rsion d1,  RestSememe Descriptio nVersion d 2) {
  263                return g etRank(d2)  - getRank (d1);
  264           }
  265  
  266       }
  267   }