44485. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 8/1/2019 1:42:44 PM Eastern Daylight 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.

44485.1 Files compared

# Location File Last Modified
1 JLV_2_8_0_0_0_July_2019.zip\JLV_2_8_0_0_0_July_2019\jMeadows\src\main\java\gov\va\med\jmeadows\smartbeans\patient SmartDemographicsDetail.java Mon Jul 8 19:18:42 2019 UTC
2 JLV_2_8_0_0_0_July_2019.zip\JLV_2_8_0_0_0_July_2019\jMeadows\src\main\java\gov\va\med\jmeadows\smartbeans\patient SmartDemographicsDetail.java Wed Jul 31 18:41:36 2019 UTC

44485.2 Comparison summary

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

44485.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

44485.4 Active regular expressions

No regular expressions were active.

44485.5 Comparison detail

  1   /**
  2    * Janus 4 .0 (c)
  3    * Copyrig ht (c) 201 1 Hawaii R esource Gr oup LLC. A ll Rights  Reserved.
  4    * Develop ed for the  Pacific T elehealth  & Technolo gy Hui and  the Pacif ic Joint I nformation  Technolog y Center
  5    * Contrib utors:
  6    *     Hon orable Sen ator Danie l K. Inouy e
  7    *     VA  Pacific Is lands Heal th Care Sy stem
  8    *     Tri pler Army  Medical Ce nter
  9    */
  10    
  11    
  12   package go v.va.med.j meadows.sm artbeans.p atient;
  13  
  14   import gov .va.med.bh ie.Demogra phicV4;
  15   import gov .va.med.bh ie.RecordI dentifierV 4;
  16   import gov .va.med.bh ie.V4Resul tCollectio n;
  17   import gov .va.med.fo undations. utilities. HashCodeUt il;
  18   import gov .va.med.fo undations. utilities. Messages;
  19   import gov .va.med.jm eadows.com mon.JMeado wsExceptio n;
  20   import gov .va.med.jm eadows.dao .beans.Res ponsePatie ntQuery;
  21   import gov .va.med.jm eadows.dao .hdd.Conce ptCodeMapp er;
  22   import gov .va.med.jm eadows.dao .hdd.HDDDa o;
  23   import gov .va.med.jm eadows.dao .util.Data SourceFact ory;
  24   import gov .va.med.jm eadows.dao .util.Loca tion;
  25   import gov .va.med.jm eadows.dao .util.Pati entLocatio n;
  26   import gov .va.med.vd s.webservi ce.*;
  27   import org .slf4j.Log ger;
  28   import org .slf4j.Log gerFactory ;
  29  
  30   import jav ax.sql.Dat aSource;
  31   import jav a.text.Sim pleDateFor mat;
  32   import jav a.util.*;
  33  
  34   //import o rg.slf4j.L ogger;
  35   //import o rg.slf4j.L oggerFacto ry;
  36  
  37   /**
  38    * @author   DNS
  39    */
  40   public cla ss SmartDe mographics Detail ext ends Smart Bean {
  41  
  42       public  static fi nal int SI TE = 1;
  43       protec ted static  final Dat aSource sm _dbConnect ionPool =  DataSource Factory.cr eateDataSo urce();
  44       protec ted static  final HDD Dao hddDao  = new HDD Dao(sm_dbC onnectionP ool);
  45       privat e static f inal Logge r LOGGER =  LoggerFac tory.getLo gger(Smart Demographi csDetail.c lass);
  46       public  PatientDe mographics Detail m_d emographic Detail;
  47  
  48       public  SmartDemo graphicsDe tail() {
  49           su per();
  50           m_ demographi cDetail =  null;
  51           m_ sortBy = 1 ;
  52           m_ bAscending  = false;
  53       }
  54       public  SmartDemo graphicsDe tail(Patie ntDemograp hicsDetail  demograph icDetail,  String sor t) {
  55           su per();
  56           m_ demographi cDetail =  demographi cDetail;
  57           ge tSortValue (sort);
  58       }
  59  
  60       @Overr ide
  61       public  boolean e quals(Obje ct obj) {
  62           bo olean rtc;
  63           if  (this ==  obj) {
  64                rtc = tr ue;
  65           }  else if (o bj instanc eof SmartD emographic sDetail) {
  66                rtc = co mpareTo(ob j) == 0;
  67           }  else {
  68                rtc = fa lse;
  69           }
  70           re turn rtc;
  71       }
  72  
  73       @Overr ide
  74       public  int hashC ode() {
  75           in t result =  HashCodeU til.SEED;
  76           re sult = Has hCodeUtil. hash(resul t, m_demog raphicDeta il);
  77           re sult = Has hCodeUtil. hash(resul t, m_bAsce nding);
  78           re sult = Has hCodeUtil. hash(resul t, m_sortB y);
  79  
  80           re turn resul t;
  81       }
  82  
  83       @Overr ide
  84       public  Object[]  combineDat a(Object[]  array1, O bject[] ar ray2, Stri ng sort) {
  85           Ob ject[] rtc ;
  86           if  (array2 = = null) {
  87                rtc = so rt(array1,  sort);
  88           }  else if (a rray1 == n ull) {
  89                rtc = so rt(array2,  sort);
  90           }  else {
  91                int size  = array1. length + a rray2.leng th;
  92                SmartDem ographicsD etail[] te mp = new S martDemogr aphicsDeta il[size];
  93                int cnt  = 0;
  94                for (int  i = 0; i  < array1.l ength; i++ ) {
  95                    Smar tDemograph icsDetail  newAll = n ew SmartDe mographics Detail((Pa tientDemog raphicsDet ail) array 1[i], sort );
  96                    temp [cnt] = ne wAll;
  97                    cnt+ +;
  98                }
  99                for (int  i = 0; i  < array2.l ength; i++ ) {
  100                    Smar tDemograph icsDetail  newAll = n ew SmartDe mographics Detail((Pa tientDemog raphicsDet ail) array 2[i], sort );
  101                    temp [cnt] = ne wAll;
  102                    cnt+ +;
  103                }
  104                Arrays.s ort(temp);
  105                PatientD emographic sDetail[]  ret = new  PatientDem ographicsD etail[temp .length];
  106                for (int  i = 0; i  < temp.len gth; i++)  {
  107                    ret[ i] = temp[ i].m_demog raphicDeta il;
  108                }
  109                rtc = re t;
  110           }
  111           re turn rtc;
  112       }
  113  
  114       public  Object[]  sort(Objec t[] array1 , String s ort) {
  115           Ob ject[] rtc ;
  116           if  (array1 = = null) {
  117                rtc = nu ll;
  118           }  else {
  119                int size  = array1. length;
  120                SmartDem ographicsD etail[] te mp = new S martDemogr aphicsDeta il[size];
  121                int cnt  = 0;
  122                for (int  i = 0; i  < array1.l ength; i++ ) {
  123                    Smar tDemograph icsDetail  newAll = n ew SmartDe mographics Detail((Pa tientDemog raphicsDet ail) array 1[i], sort );
  124                    temp [cnt] = ne wAll;
  125                    cnt+ +;
  126                }
  127                Arrays.s ort(temp);
  128                PatientD emographic sDetail[]  ret = new  PatientDem ographicsD etail[temp .length];
  129                for (int  i = 0; i  < temp.len gth; i++)  {
  130                    ret[ i] = temp[ i].m_demog raphicDeta il;
  131                }
  132                rtc = re t;
  133           }
  134           re turn rtc;
  135       }
  136  
  137   //    publ ic Patient Demographi csDetail[]  mapPatien tDemograph icsDetails FromCHCS(O bject[] do dBean) {
  138   //         PatientDem ographicsD etail[] de tails = ne w PatientD emographic sDetail[do dBean.leng th];
  139   //
  140   //         StringBuil der report Bldr = new  StringBui lder();
  141   //         for (int i  = 0; i <  dodBean.le ngth; i++)  {
  142   //             org.hu i.chcs.Dem ographicsB ean chcsBe an = (org. hui.chcs.D emographic sBean) dod Bean[i];
  143   //             if (ch csBean !=  null) {
  144   //                 re portBldr.s etLength(0 );
  145   //
  146   //                 re portBldr.a ppend(repo rtCHCSItem Str("Name" , chcsBean .getName() ));
  147   //                 re portBldr.a ppend(repo rtCHCSItem Str("Addre ss1", chcs Bean.getAd dress1())) ;
  148   //                 re portBldr.a ppend(repo rtCHCSItem Str("Addre ss2", chcs Bean.getAd dress2())) ;
  149   //                 re portBldr.a ppend(repo rtCHCSItem Str("City" , chcsBean .getCity() ));
  150   //                 re portBldr.a ppend(repo rtCHCSItem Str("State ", chcsBea n.getState ()));
  151   //                 re portBldr.a ppend(repo rtCHCSItem Str("Zip c ode:", chc sBean.getZ ipCode())) ;
  152   //                 re portBldr.a ppend(repo rtCHCSItem Str("SSN",  chcsBean. getSSN())) ;
  153   //                 re portBldr.a ppend(repo rtCHCSItem Str("PCM D ates", chc sBean.getP cmDates()) );
  154   //                 re portBldr.a ppend(repo rtCHCSItem Str("PCM",  chcsBean. getPcm())) ;
  155   //                 re portBldr.a ppend(repo rtCHCSItem Str("Clini c", chcsBe an.getClin ic()));
  156   //                 re portBldr.a ppend(repo rtCHCSItem Str("Age",  chcsBean. getAge())) ;
  157   //                 re portBldr.a ppend(repo rtCHCSItem Str("DOB",  chcsBean. getDob())) ;
  158   //                 re portBldr.a ppend(repo rtCHCSItem Str("Sex",  chcsBean. getSex())) ;
  159   //                 re portBldr.a ppend(repo rtCHCSItem Str("Phone 1", chcsBe an.getPhon e1()));
  160   //                 re portBldr.a ppend(repo rtCHCSItem Str("Phone 2", chcsBe an.getPhon e2()));
  161   //                 re portBldr.a ppend(repo rtCHCSItem Str("Rank" , chcsBean .getRank() ));
  162   //                 re portBldr.a ppend(repo rtCHCSItem Str("Spons or", chcsB ean.getSpo nsor()));
  163   //                 re portBldr.a ppend(repo rtCHCSItem Str("Spons or ID", ch csBean.get SponsorId( )));
  164   //                 re portBldr.a ppend(repo rtCHCSItem Str("Patie nt ID", ch csBean.get PatientId( )));
  165   //                 re portBldr.a ppend(repo rtCHCSItem Str("Enrol led", chcs Bean.getEn rolled())) ;
  166   //                 re portBldr.a ppend(repo rtCHCSItem Str("Unit" , chcsBean .getUnit() ));
  167   //                 re portBldr.a ppend(repo rtCHCSItem Str("Organ  Donor", c hcsBean.ge tOrganDono r()));
  168   //                 re portBldr.a ppend(repo rtCHCSItem Str("Clini c Phone",  chcsBean.g etClinicPh one()));
  169   //                 de tails[i] =  new Patie ntDemograp hicsDetail ();
  170   //                 ad dCHCSSiteD ataToVista Bean(detai ls[i]);
  171   //                 de tails[i].s etReport(r eportBldr. toString() );
  172   //             }
  173   //         }
  174   //
  175   //         return det ails;
  176   //    }
  177  
  178       public  PatientDe mographics Detail[] m apPatientD emographic sDetailsFr omPDWS(Obj ect result Collection ) {
  179           Pa tientDemog raphicsDet ail[] rtc  = new Pati entDemogra phicsDetai l[1];
  180           rt c[0] = new  PatientDe mographics Detail();
  181           St ringBuilde r reportBl dr = new S tringBuild er();
  182           re portBldr.s etLength(0 );
  183  
  184           Re sponsePati entQuery r esponse =  (ResponseP atientQuer y) resultC ollection;
  185  
  186           if  (response  == null | | response .getDemogr aphics() = = null) {
  187                List<Pat ientDemogr aphicsDeta il> detail s = new Ar rayList<Pa tientDemog raphicsDet ail>();
  188                PatientL ocation bh ieLoc = ne w PatientL ocation();
  189                bhieLoc. setSystemT ype(SYSTEM _TYPE_DOD_ ADAPTER);
  190  
  191                details. addAll(Arr ays.asList (
  192                         (gov.va.me d.vds.webs ervice.Pat ientDemogr aphicsDeta il[])
  193                                 ge nerateConn ectionUnav ailableBea n(bhieLoc,
  194                                          Mess ages.get(" demographi cs.dod.res ults.empty ") + "\n\n "
  195                                          + Me ssages.get ("demograp hics.dod.r esults.hel pdesk") +  "\n\n")));
  196                rtc = de tails.toAr ray(new Pa tientDemog raphicsDet ail[detail s.size()]) ;
  197           }  else {
  198                PatientD emographic s patDemo  = response .getDemogr aphics();
  199  
  200                List<Pat ientDemogr aphics> de mographics  = new Arr ayList<Pat ientDemogr aphics>();
  201                demograp hics.add(p atDemo);
  202                try {
  203                    Conc eptCodeMap per.getIns tance().ma pDemograph ics(hddDao , demograp hics);
  204                    patD emo = demo graphics.g et(0);
  205                } catch  (JMeadowsE xception e ){
  206                    //fa iled to ma p
  207                    LOGG ER.error(" Demographi cs - faile d to map t erminology  for PDWS  demographi cs. ");
  208                }
  209  
  210   //             if (pa tDemo.getS ponsorSSN( ) == null  || patDemo .getSponso rSSN().len gth() == 0 ) {
  211   //                 pa tDemo.setS ponsorSSN( patDemo.ge tSSN());
  212   //             }
  213   //             if (pa tDemo.getS ponsorName () == null  || patDem o.getSpons orName().l ength() ==  0) {
  214   //                 pa tDemo.setS ponsorName (patDemo.g etName());
  215   //             }
  216                if (patD emo.getNam e() != nul l) {
  217                    repo rtBldr.app end(report CHCSItemSt r("Name",  patDemo.ge tName()));
  218                } else {
  219                    repo rtBldr.app end(report CHCSItemSt r("Name",  ""));
  220                }
  221                if (patD emo.getDob () != null ) {
  222                    repo rtBldr.app end(report CHCSItemSt r("DOB", p atDemo.get Dob()));
  223                } else {
  224                    repo rtBldr.app end(report CHCSItemSt r("DOB", " "));
  225                }
  226                if (patD emo.getGen der() != n ull) {
  227                    repo rtBldr.app end(report CHCSItemSt r("Gender" , patDemo. getGender( )));
  228                } else {
  229                    repo rtBldr.app end(report CHCSItemSt r("Gender" , ""));
  230                }
  231                if (patD emo.getAdd ress() !=  null && pa tDemo.getA ddress().s ize() > 0)  {
  232  
  233                    for( Address ad dress : pa tDemo.getA ddress()){
  234                         if(address .getType()  != null)  {
  235                             report Bldr.appen d(address. getType()) ;
  236                         }
  237                         reportBldr .append("\ n");
  238                         reportBldr .append(re portCHCSIt emStr("  S treet 1",  address.ge tStreet1() ));
  239                         reportBldr .append(re portCHCSIt emStr("  S treet 2",  address.ge tStreet2() ));
  240                         reportBldr .append(re portCHCSIt emStr("  C ity", addr ess.getCit y()));
  241                         reportBldr .append(re portCHCSIt emStr("  S tate", add ress.getSt ateProvinc e()));
  242                         reportBldr .append(re portCHCSIt emStr("  Z ip", addre ss.getPost alCode())) ;
  243                    }
  244                }
  245                if (patD emo.getPho ne1() != n ull) {
  246                    repo rtBldr.app end(report CHCSItemSt r("Phone1" , patDemo. getPhone1( )));
  247                } else {
  248                    repo rtBldr.app end(report CHCSItemSt r("Phone1" , ""));
  249                }
  250                if (patD emo.getPho ne2() != n ull) {
  251                    repo rtBldr.app end(report CHCSItemSt r("Phone2" , patDemo. getPhone1( )));
  252                } else {
  253                    repo rtBldr.app end(report CHCSItemSt r("Phone2" , ""));
  254                }
  255                if (patD emo.getSSN () != null ) {
  256                    repo rtBldr.app end(report CHCSItemSt r("SSN", p atDemo.get SSN()));
  257                } else {
  258                    repo rtBldr.app end(report CHCSItemSt r("SSN", " "));
  259                }
  260                if (patD emo.getMar italStatus () != null ) {
  261                    repo rtBldr.app end(report CHCSItemSt r("Marital  Status",  patDemo.ge tMaritalSt atus()));
  262                } else {
  263                    repo rtBldr.app end(report CHCSItemSt r("Marital  Status",  ""));
  264                }
  265                if (patD emo.getRel igion() !=  null && ! patDemo.ge tReligion( ).isEmpty( ) && patDe mo.getReli gion().get (0) != nul l && patDe mo.getReli gion().get (0).length () > 0) {
  266                    repo rtBldr.app end(report CHCSItemSt r("Religio n", patDem o.getRelig ion().get( 0)));
  267                } else {
  268                    repo rtBldr.app end(report CHCSItemSt r("Religio n", ""));
  269                }
  270                if (patD emo.getRac e() != nul l && !patD emo.getRac e().isEmpt y()
  271                         && patDemo .getRace() .get(0) !=  null
  272                         && patDemo .getRace() .get(0).ge tDisplay()  != null)  {
  273                    repo rtBldr.app end(report CHCSItemSt r("Race",  patDemo.ge tRace().ge t(0).getDi splay()));
  274                } else {
  275                    repo rtBldr.app end(report CHCSItemSt r("Race",  ""));
  276                }
  277                if (patD emo.getEth nicGroup()  != null & & !patDemo .getEthnic Group().is Empty()
  278                         && patDemo .getEthnic Group().ge t(0) != nu ll
  279                         && patDemo .getEthnic Group().ge t(0).getDi splay() !=  null) {
  280                    repo rtBldr.app end(report CHCSItemSt r("Ethnici ty", patDe mo.getEthn icGroup(). get(0).get Display()) );
  281                } else {
  282                    repo rtBldr.app end(report CHCSItemSt r("Ethnici ty", ""));
  283                }
  284                for(Pers on sponsor  : patDemo .getSponso rs()){
  285                    if ( sponsor.ge tName() !=  null) {
  286                         reportBldr .append(re portCHCSIt emStr("Spo nsor Name" , sponsor. getName()) );
  287                    } el se {
  288                         reportBldr .append(re portCHCSIt emStr("Spo nsor Name" , ""));
  289                    }
  290                    if ( sponsor.ge tIdentifie r() != nul l) {
  291                         reportBldr .append(re portCHCSIt emStr("  S ponsor SSN ", sponsor .getIdenti fier()));
  292                    } el se {
  293                         reportBldr .append(re portCHCSIt emStr("  S ponsor SSN ", ""));
  294                    }
  295                    if ( sponsor.ge tRelations hip() != n ull) {
  296                         reportBldr .append(re portCHCSIt emStr("  S ponsor Rel ation", sp onsor.getR elationshi p()));
  297                    } el se {
  298                         reportBldr .append(re portCHCSIt emStr("  S ponsor Rel ation", "" ));
  299                    }
  300  
  301                }
  302   //
  303                if (patD emo.getEli gibility()  != null & & !patDemo .getEligib ility().is Empty()) {
  304                    repo rtBldr.app end(report CHCSItemSt r("Deers E ligibility ", patDemo .getEligib ility()));
  305                } else {
  306                    repo rtBldr.app end(report CHCSItemSt r("Deers E ligibility ", ""));
  307                }
  308                if (patD emo.getEli gibilitySt atus() !=  null && !p atDemo.get Eligibilit yStatus(). isEmpty())  {
  309                    repo rtBldr.app end(report CHCSItemSt r("Deers E ligibility  Status",  patDemo.ge tEligibili tyStatus() ));
  310                } else {
  311                    repo rtBldr.app end(report CHCSItemSt r("Deers E ligibility  Status",  ""));
  312                }
  313                if (patD emo.getRan k() != nul l && !patD emo.getRan k().isEmpt y()) {
  314                    repo rtBldr.app end(report CHCSItemSt r("Rank",  patDemo.ge tRank()));
  315                } else {
  316                    repo rtBldr.app end(report CHCSItemSt r("Rank",  ""));
  317                }
  318  
  319                List<Per son> emerg encyContac t =  patDe mo.getEmer gencyConta ct();
  320                if (emer gencyConta ct==null)
  321                {
  322                    emer gencyConta ct = new A rrayList<P erson>();
  323                }
  324                if (emer gencyConta ct.isEmpty ())
  325                {
  326                    emer gencyConta ct.add(new  Person()) ;
  327                }
  328  
  329                reportBl dr.append( "\nEmergen cy Contact \n");
  330                for (Per son p:emer gencyConta ct){
  331                    repo rtBldr.app end(report CHCSItemSt r("Relatio nship", p. getRelatio nship()));
  332                    repo rtBldr.app end(report CHCSItemSt r("Name",  p.getName( )));
  333                    if(p .getAddres s() != nul l && p.get Address(). size() > 0 ){
  334                         reportBldr .append(re portCHCSIt emStr("Str eet1", p.g etAddress( ).get(0).g etStreet1( )));
  335                         reportBldr .append(re portCHCSIt emStr("Str eet2", p.g etAddress( ).get(0).g etStreet2( )));
  336                         reportBldr .append(re portCHCSIt emStr("Cit y", p.getA ddress().g et(0).getC ity()));
  337                         reportBldr .append(re portCHCSIt emStr("Sta te", p.get Address(). get(0).get StateProvi nce()));
  338                         reportBldr .append(re portCHCSIt emStr("Zip  Code", p. getAddress ().get(0). getPostalC ode()));
  339                    } el se {
  340                         reportBldr .append(re portCHCSIt emStr("Str eet1", "") );
  341                         reportBldr .append(re portCHCSIt emStr("Str eet2", "") );
  342                         reportBldr .append(re portCHCSIt emStr("Cit y", ""));
  343                         reportBldr .append(re portCHCSIt emStr("Sta te", ""));
  344                         reportBldr .append(re portCHCSIt emStr("Zip  Code", "" ));
  345                    }
  346  
  347                    if ( p.getTelco ms()!=null  && !p.get Telcoms(). isEmpty())  {
  348                         for (Telec om tel:p.g etTelcoms( ))
  349                             report Bldr.appen d(reportCH CSItemStr( "Phone", t el.getValu e()));
  350                    }
  351                    else
  352                    {
  353                         reportBldr .append(re portCHCSIt emStr("Pho ne", ""));
  354                    }
  355                }
  356  
  357                List<Per son> nok =   patDemo. getNextOfK in();
  358                if (nok= =null)
  359                {
  360                    nok  = new Arra yList<Pers on>();
  361                }
  362                if (nok. isEmpty())
  363                {
  364                    nok. add(new Pe rson());
  365                }
  366  
  367                reportBl dr.append( "\nNext of  Kin\n");
  368                for (Per son p:nok) {
  369                    repo rtBldr.app end(report CHCSItemSt r("Relatio nship", p. getRelatio nship()));
  370                    repo rtBldr.app end(report CHCSItemSt r("Name",  p.getName( )));
  371                    if(p .getAddres s() != nul l && p.get Address(). size() > 0 ) {
  372                         reportBldr .append(re portCHCSIt emStr("Str eet1", p.g etAddress( ).get(0).g etStreet1( )));
  373                         reportBldr .append(re portCHCSIt emStr("Str eet2", p.g etAddress( ).get(0).g etStreet2( )));
  374                         reportBldr .append(re portCHCSIt emStr("Cit y", p.getA ddress().g et(0).getC ity()));
  375                         reportBldr .append(re portCHCSIt emStr("Sta te", p.get Address(). get(0).get StateProvi nce()));
  376                         reportBldr .append(re portCHCSIt emStr("Zip  Code", p. getAddress ().get(0). getPostalC ode()));
  377                    } el se {
  378                         reportBldr .append(re portCHCSIt emStr("Str eet1", "") );
  379                         reportBldr .append(re portCHCSIt emStr("Str eet2", "") );
  380                         reportBldr .append(re portCHCSIt emStr("Cit y", ""));
  381                         reportBldr .append(re portCHCSIt emStr("Sta te", ""));
  382                         reportBldr .append(re portCHCSIt emStr("Zip  Code", "" ));
  383                    }
  384  
  385                    if ( p.getTelco ms()!=null  && !p.get Telcoms(). isEmpty())  {
  386                         for (Telec om tel:p.g etTelcoms( ))
  387                             report Bldr.appen d(reportCH CSItemStr( "Phone", t el.getValu e()));
  388                    }
  389                    else
  390                    {
  391                         reportBldr .append(re portCHCSIt emStr("Pho ne", ""));
  392                    }
  393  
  394                }
  395  
  396                rtc[0].s etReport(r eportBldr. toString() );
  397                addBHIES iteDataToV istaBean(" ", "PDWS",  "PDWS", " ", rtc[0]) ;
  398           }
  399           re turn rtc;
  400       }
  401       
  402       public  PatientDe mographics Detail[] m apPatientD emographic sDetailsFr omBHIE(Obj ect result Collection ) {
  403           V4 ResultColl ection pat DemoResult Collection  = (V4Resu ltCollecti on) result Collection ;
  404           Li st<Patient Demographi csDetail>  details =  new ArrayL ist<Patien tDemograph icsDetail> ();
  405  
  406           // If data re cord is em pty, infor m user
  407           if  (patDemoR esultColle ction.getD ataRecordL ist() == n ull || pat DemoResult Collection .getDataRe cordList() .getDemogr aphics() = = null) {
  408                PatientL ocation bh ieLoc = ne w PatientL ocation();
  409                bhieLoc. setSystemT ype(SYSTEM _TYPE_DOD_ ADAPTER);
  410  
  411                details. addAll(Arr ays.asList (
  412                         (gov.va.me d.vds.webs ervice.Pat ientDemogr aphicsDeta il[])
  413                                 ge nerateConn ectionUnav ailableBea n(bhieLoc,
  414                                          Mess ages.get(" demographi cs.dod.res ults.empty ") + "\n\n "
  415                                          + Me ssages.get ("demograp hics.dod.r esults.hel pdesk") +  "\n\n")));
  416           }  else {
  417                StringBu ilder repo rtBldr = n ew StringB uilder();
  418                SimpleDa teFormat s df = new S impleDateF ormat("dd  MMM yyyy",  Locale.ge tDefault() );
  419                if (patD emoResultC ollection. getDataRec ordList(). getDemogra phics() !=  null) {
  420                    for  (Demograph icV4 patDe mo : patDe moResultCo llection.g etDataReco rdList().g etDemograp hics()) {
  421                         //PatientD emographic s patDemo  = dataReco rd.getPati entDemogra phics();
  422                         reportBldr .setLength (0);
  423                         if (patDem o.getName( ) != null)  {
  424                             report Bldr.appen d(reportCH CSItemStr( "Name", pa tDemo.getN ame().getL ast() + ", " + patDem o.getName( ).getFirst () + " " +  patDemo.g etName().g etMiddle() ));
  425                             report Bldr.appen d(reportCH CSItemStr( "Suffix",  patDemo.ge tName().ge tSuffix()) );
  426                         }
  427  
  428                         if (patDem o.getBirth Date() !=  null && pa tDemo.getB irthDate() .getStart( ) != null)  {
  429                             report Bldr.appen d(reportCH CSItemStr( "DOB", sdf .format(bh ieToCal(pa tDemo.getB irthDate() .getStart( )).getTime ())));
  430                         }
  431                         if (patDem o.getSex()  != null & & !patDemo .getSex(). isEmpty()  && patDemo .getSex(). get(0) !=  null) {
  432                             report Bldr.appen d(reportCH CSItemStr( "Gender",  patDemo.ge tSex().get (0).getCod e()));
  433                         }
  434                         if (patDem o.getAddre sses() !=  null && !p atDemo.get Addresses( ).isEmpty( )) {
  435                             if (pa tDemo.getA ddresses() .get(0).ge tStreet()  != null &&  !patDemo. getAddress es().get(0 ).getStree t().isEmpt y()) {
  436                                 re portBldr.a ppend(repo rtCHCSItem Str("Stree t 1", patD emo.getAdd resses().g et(0).getS treet().ge t(0)));
  437                                 if  (patDemo. getAddress es().get(0 ).getStree t().size()  > 1) {
  438                                      reportBl dr.append( reportCHCS ItemStr("S treet 2",  patDemo.ge tAddresses ().get(0). getStreet( ).get(1))) ;
  439                                 }
  440                             }
  441                             report Bldr.appen d(reportCH CSItemStr( "City", pa tDemo.getA ddresses() .get(0).ge tCity()));
  442                             report Bldr.appen d(reportCH CSItemStr( "State", p atDemo.get Addresses( ).get(0).g etState()) );
  443                             report Bldr.appen d(reportCH CSItemStr( "Zip Code" , patDemo. getAddress es().get(0 ).getPosta lCode()));
  444                             report Bldr.appen d(reportCH CSItemStr( "County",  patDemo.ge tAddresses ().get(0). getCounty( )));
  445                             report Bldr.appen d(reportCH CSItemStr( "Country",  patDemo.g etAddresse s().get(0) .getCountr y()));
  446                         }
  447                         if (patDem o.getTelec oms() != n ull && !pa tDemo.getT elecoms(). isEmpty())  {
  448                             report Bldr.appen d(reportCH CSItemStr( "Phone", p atDemo.get Telecoms() .get(0).ge tValue())) ;
  449                         }
  450                         reportBldr .append(re portCHCSIt emStr("Ema il", patDe mo.getEmai l()));
  451   //                 re portBldr.a ppend(repo rtCHCSItem Str("SSN",  patDemo.g etSocialSe curityNumb er()));
  452                         String ssn  = "";
  453                         if (patDem o.getPatie ntId() !=  null) {
  454                             Iterat or<RecordI dentifierV 4> iter =  patDemo.ge tPatientId ().iterato r();
  455                             while  (iter.hasN ext()) {
  456                                 Re cordIdenti fierV4 rec ordid = it er.next();
  457                                 if  ("2.16.84 0.1.113883 .3.42.126. 100001.2". equals(rec ordid.getA ssigningAu thority()) ) {
  458                                      ssn = re cordid.get Id();
  459                                      break;
  460                                 }
  461   //                      if ("2.1 6.840.1.11 3883.3.42. 10001.1000 01.12".equ als(id.get AssigningA uthority() )) {
  462   //                          Stri ng edi = i d.getId();
  463   //                          if ( edi != nul l && edi.s tartsWith( "D") && ed i.length()  > 1) {
  464   //                               edi = edi. substring( 1);
  465   //                          }
  466   //                          if ( edi != nul l && edi.l ength() >  0 && PDWSB lackList.g etInstance ().isBlack Listed(edi )) {
  467   //                               reportBldr .append(re portCHCSIt emStr("Sen sitive", " true"));
  468   //                          }
  469   //                      }
  470                             }
  471                         }
  472                         reportBldr .append(re portCHCSIt emStr("SSN ", ssn));
  473                         reportBldr .append(re portCHCSIt emStr("Mar ital Statu s", getFir stSpdcV4(p atDemo.get MaritalSta tus()).get Display()) );
  474                         reportBldr .append(re portCHCSIt emStr("Rel igion", ge tFirstSpdc V4(patDemo .getReligi on()).getD isplay())) ;
  475                         reportBldr .append(re portCHCSIt emStr("Rac e", getFir stSpdcV4Fr omWrapper( patDemo.ge tRace()).g etDisplay( )));
  476                         if (patDem o.getEnrol lmentLocat ion() != n ull) {
  477                             report Bldr.appen d(reportCH CSItemStr( "Enrollmen t Facility ", patDemo .getEnroll mentLocati on().getNa me()));
  478                         }
  479   // fmp mia                  repo rtBldr.app end(report CHCSItemSt r("FMP", p atDemo.get Fmp()));
  480                         if (patDem o.getSpons or() != nu ll && patD emo.getSpo nsor().get Ssn() != n ull && pat Demo.getSp onsor().ge tSsn().len gth() > 0)  {
  481                             report Bldr.appen d(reportCH CSItemStr( "FMP", pat Demo.getFm p() + "/"  + patDemo. getSponsor ().getSsn( )));
  482                         } else {
  483                             report Bldr.appen d(reportCH CSItemStr( "FMP", pat Demo.getFm p()));
  484                         }
  485                         if (patDem o.getAssig nedUnit()  != null) {
  486                             report Bldr.appen d(reportCH CSItemStr( "UIC", pat Demo.getAs signedUnit ().getName ()));
  487                         }
  488                         reportBldr .append(re portCHCSIt emStr("Pat ient Categ ory", getF irstSpdcV4 (patDemo.g etPatientC ategory()) .getDispla y()));
  489                         reportBldr .append(re portCHCSIt emStr("Dee rs Eligibi lity", get FirstSpdcV 4(patDemo. getDeersEl igibility( )).getDisp lay()));
  490                         reportBldr .append(re portCHCSIt emStr("Ran k", getFir stSpdcV4(p atDemo.get Rank()).ge tDisplay() ));
  491                         reportBldr .append(re portCHCSIt emStr("Bra nch of Ser vice", get FirstSpdcV 4(patDemo. getBranch( )).getDisp lay()));
  492                         if (patDem o.getSpons or() != nu ll) {
  493                             report Bldr.appen d(reportCH CSItemStr( "Sponsor R ank", getF irstSpdcV4 (patDemo.g etSponsor( ).getRank( )).getDisp lay()));
  494                             report Bldr.appen d(reportCH CSItemStr( "Sponsor B ranch of S ervice", g etFirstSpd cV4(patDem o.getSpons or().getBr anch()).ge tDisplay() ));
  495   //                 re portBldr.a ppend(repo rtCHCSItem Str("Spons or SSN", p atDemo.get SponsorSsn ()));
  496                             report Bldr.appen d(reportCH CSItemStr( "Sponsor S SN", patDe mo.getSpon sor().getS sn()));
  497                             if (pa tDemo.getS ponsor().g etAssigned Unit() !=  null) {
  498                                 re portBldr.a ppend(repo rtCHCSItem Str("Spons or UIC", p atDemo.get Sponsor(). getAssigne dUnit().ge tName()));
  499                             }
  500                         }
  501                         PatientDem ographicsD etail patD etail = ne w PatientD emographic sDetail();
  502  
  503   //                 ad dBHIESiteD ataToVista Bean(patDe mo.getCust odianId(),
  504   //                          patD emo.getCus todianName (), getFir stSpdc(pat Demo.getFa cility()). getDisplay (), patDem o.getEvent Id(), patD etail);
  505   //                 ad dBHIESiteD ataToVista Bean(patDe mo.getRepo sitory().g etId().get (0).getId( ),
  506   //                          patD emo.getRep ository(). getName(),  patDemo.g etFacility ().getName (), patDem o.getRecor dId().getI d(), patDe tail);
  507                         String rep ositoryId  = "";
  508                         String rep ositoryNam e = "";
  509                         String fac ilityName  = "";
  510                         String eve ntId = "";
  511                         if (patDem o.getRepos itory() !=  null && p atDemo.get Repository ().getIds( ) != null  && !patDem o.getRepos itory().ge tIds().isE mpty()) {
  512                             reposi toryId = p atDemo.get Repository ().getIds( ).get(0).g etId();
  513                         }
  514                         if (patDem o.getRepos itory() !=  null) {
  515                             reposi toryName =  patDemo.g etReposito ry().getNa me();
  516                         }
  517                         if (patDem o.getFacil ity() != n ull) {
  518                             facili tyName = p atDemo.get Facility() .getName() ;
  519                         }
  520                         if (patDem o.getRecor dId() != n ull) {
  521                             eventI d = patDem o.getRecor dId().getI d();
  522                         }
  523                         if (reposi toryId ==  null || re positoryId .length()  == 0) {
  524                             reposi toryId = " 2.16.840.1 .113883.3. 42.126.100 001.13";
  525                         }
  526                         if (reposi toryName = = null ||  repository Name.lengt h() == 0)  {
  527                             reposi toryName =  "ahlta";
  528                         }
  529                         addBHIESit eDataToVis taBean(rep ositoryId,  repositor yName,
  530                                 fa cilityName , eventId,  patDetail );
  531  
  532                         patDetail. setReport( reportBldr .toString( ));
  533  
  534                         details.ad d(patDetai l);
  535                    }
  536                }
  537           }
  538  
  539           // include si te status  report
  540           St ring siteS tatusRepor t = genera teBhieStat usReportV4 (patDemoRe sultCollec tion.getSt atusListv4 (),
  541                    patD emoResultC ollection. getErrorLi stv4(), pa tDemoResul tCollectio n.isVler() );
  542  
  543           de tails.addA ll(Arrays. asList(
  544                (Patient Demographi csDetail[] ) generate Connection Unavailabl eBean(
  545                         BHIE_STATU S_REPORT_L OCATION,
  546                         siteStatus Report)
  547           )) ;
  548  
  549           re turn detai ls.toArray (new Patie ntDemograp hicsDetail [details.s ize()]);
  550       }
  551  
  552       //Vers ion 2
  553   //    publ ic Patient Demographi cs[] mapPa tientDemog raphicsFro mBHIE(Obje ct resultC ollection)
  554   //    {
  555   //       P atientDemo graphicsRe sultCollec tion patDe moResultCo llection =  (PatientD emographic sResultCol lection) r esultColle ction;
  556   //       L ist<Patien tDemograph ics> vista Beans = ne w ArrayLis t<PatientD emographic s>();
  557   //
  558   //       / /If data r ecord is e mpty, info rm user.
  559   //       i f (patDemo ResultColl ection.get DataRecord List() ==  null || pa tDemoResul tCollectio n.getDataR ecordList( ).isEmpty( ))
  560   //       {
  561   //            Patient Location b hieLoc = n ew Patient Location() ;
  562   //            bhieLoc .setSystem Type(SYSTE M_TYPE_DOD _ADAPTER);
  563   //
  564   //            vistaBe ans.addAll (Arrays.as List(
  565   //                     (PatientD emographic s[]) gener ateBHIEPat RegErrorBe an(bhieLoc )));
  566   //       }
  567   //       e lse
  568   //       {
  569   //            SimpleD ateFormat  df = new S impleDateF ormat("dd  MMM yyyy") ;
  570   //            for (Pa tientDemog raphicsDat aRecord da taRecord :  patDemoRe sultCollec tion.getDa taRecordLi st())
  571   //            {
  572   //
  573   //                if  (dataRecor d == null  || dataRec ord.getPat ientDemogr aphics() = = null) co ntinue;
  574   //
  575   //                gov .va.med.bh ie.Patient Demographi cs bhiePat  = dataRec ord.getPat ientDemogr aphics();
  576   //                Pat ientDemogr aphics pat  = new Pat ientDemogr aphics();
  577   //                pat .setAddres s1(bhiePat .getStreet ());
  578   //                pat .setAddres s2(bhiePat .getStreet 2());
  579   //                //p at.setAge( chcsPat.ge tAge());
  580   //                pat .setCity(b hiePat.get City());
  581   //                //p at.setClin ic(bhiePat .get);
  582   //                pat .setDob(df .format(bh ieToCal(bh iePat.getD ateOfBirth ()).getTim e()));
  583   //                pat .setGender (bhiePat.g etSex());
  584   ////                p at.getRace ().addAll( getCodes(b hiePat.get Race()));
  585   //try {
  586   //                pat .getRace() .clear();
  587   //                if  (bhiePat.g etRace() ! = null &&  !bhiePat.g etRace().i sEmpty())  {
  588   //                     pat.getRa ce().addAl l(Arrays.a sList(getC odes(bhieP at.getRace ())));
  589   //System.o ut.println ("RACE HAS  DATA!!!") ;
  590   //                } e lse {
  591   //System.o ut.println ("RACE IS  EMPTY!!!") ;
  592   //}
  593   //} catch  (Exception  ex) {
  594   //ex.print StackTrace ();
  595   //System.o ut.println ("RACE ERR OR "+ex.ge tMessage() );
  596   //}
  597   //                //p at.setPati entId(chcs Pat.getPat ientId());
  598   //                pat .setName(b hiePat.get LastName()  + ", " +  bhiePat.ge tFirstName () + " " +  bhiePat.g etMiddleNa me());
  599   //                //p at.setPrim aryProvide r(chcsPat. getPcm());
  600   //                pat .setPhone1 (bhiePat.g etPhoneNum ber());
  601   //                //p at.setPhon e2(chcsPat .getPhone2 ());
  602   //                pat .setSSN(bh iePat.getS ocialSecur ityNumber( ));
  603   //                pat .setState( bhiePat.ge tState());
  604   //                pat .setZipCod e(bhiePat. getPostCod e());
  605   //                pat .setCodeGr een("0");
  606   //
  607   //                add BHIESiteDa taToVistaB ean(bhiePa t.getCusto dianId(),
  608   //                         bhieP at.getCust odianName( ), getFirs tSpdc(bhie Pat.getFac ility()).g etDisplay( ), bhiePat .getEventI d(), pat);
  609   //
  610   //                vis taBeans.ad d(pat);
  611   //            }
  612   //       }
  613   //
  614   //       / /include s ite status  report
  615   //       S tring site StatusRepo rt = gener ateBhieSta tusReport( patDemoRes ultCollect ion.getSta tusList(),
  616   //                pat DemoResult Collection .getErrorL ist());
  617   //
  618   //       v istaBeans. addAll(Arr ays.asList (
  619   //            (Patien tDemograph ics[]) gen erateConne ctionUnava ilableBean (
  620   //                     BHIE_STAT US_REPORT_ LOCATION,
  621   //                     siteStatu sReport)
  622   //       ) );
  623   //
  624   //       r eturn vist aBeans.toA rray(new P atientDemo graphics[0 ]);
  625   //    }
  626  
  627       
  628  
  629       privat e String r eportCHCSI temStr(Str ing label,  String va lue) {
  630           St ringBuilde r str = ne w StringBu ilder("");
  631           st r.append(l abel);
  632           st r.append(" : ");
  633           if  (value !=  null) {
  634                str.appe nd(value);
  635           }
  636           st r.append(" \n");
  637  
  638           re turn str.t oString();
  639       }
  640  
  641       @Overr ide
  642       public  Object[]  generateCo nnectionUn availableB ean(Locati on locatio n, String  inerrorMsg ) {
  643           St ring error Msg = iner rorMsg;
  644           if  (errorMsg  == null)  {
  645                errorMsg  = ERROR_M SG_CONNECT ION_UNAVAI LABLE;
  646           }
  647  
  648           Pa tientDemog raphicsDet ail detail  = new Pat ientDemogr aphicsDeta il();
  649  
  650           de tail.setRe port(error Msg);
  651           de tail.setSi te(getConn ectionUnav ailableSit e(location ));
  652  
  653           re turn new P atientDemo graphicsDe tail[]{det ail};
  654       }
  655  
  656       public  int compa reTo(Objec t obj) {
  657           Sm artDemogra phicsDetai l tmp = (S martDemogr aphicsDeta il) obj;
  658           in t retVal =  0;
  659           if  (this.m_s ortBy == S ITE && thi s.m_demogr aphicDetai l.getSite( ) != null  && tmp.m_d emographic Detail.get Site() !=  null) {
  660                retVal =  compareSt ring(this. m_demograp hicDetail. getSite(). getSiteCod e(), tmp.m _demograph icDetail.g etSite().g etSiteCode ());
  661           }
  662  
  663           if  (!this.m_ bAscending ) {
  664                retVal =  -retVal;
  665           }
  666  
  667           re turn retVa l;
  668       }
  669  
  670       //TODO : sort is  always sit e
  671       privat e void get SortValue( String ins ort) {
  672           St ring sort  = insort;
  673           m_ sortBy = S ITE;
  674           m_ bAscending  = false;
  675           if  (sort !=  null) {
  676                sort = s etAscendin g(sort);
  677                if ("sit eCode".equ alsIgnoreC ase(sort))  {
  678                    m_so rtBy = SIT E;
  679                }
  680           }
  681       }
  682  
  683   //    priv ate String  generateA ddressStri ng(Address  address){
  684   //         StringBuil der report Bldr = new  StringBui lder();
  685   //         reportBldr .append(re portCHCSIt emStr("Str eet 1", ad dress.getS treet1())) ;
  686   //         reportBldr .append(re portCHCSIt emStr("Str eet 2", ad dress.getS treet2())) ;
  687   //         reportBldr .append(re portCHCSIt emStr("Cit y", addres s.getCity( )));
  688   //         reportBldr .append(re portCHCSIt emStr("Sta te", addre ss.getStat eProvince( )));
  689   //         reportBldr .append("Z ip: ");
  690   //         reportBldr .append(ad dress.getP ostalCode( ));
  691   //         if(address .getType()  != null)  {
  692   //             report Bldr.appen d(address. getType()) ;
  693   //         }
  694   //         reportBldr .append("\ n");
  695   //         return rep ortBldr.to String();
  696   //    }
  697   }