56. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/5/2017 4:21:46 PM Central 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.

56.1 Files compared

# Location File Last Modified
1 C:\working_scrub\Unredacted\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterEJB\src\test\java\gov\va\med\nhin\adapter\patientcorrelation AdapterPatientCorrelationTest.java Fri Feb 10 15:41:44 2017 UTC
2 eHX-CIF.zip\eHX-CIF\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterEJB\src\test\java\gov\va\med\nhin\adapter\patientcorrelation AdapterPatientCorrelationTest.java Mon Apr 3 14:23:42 2017 UTC

56.2 Comparison summary

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

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

56.4 Active regular expressions

No regular expressions were active.

56.5 Comparison detail

  1   /*
  2    * To chan ge this te mplate, ch oose Tools  | Templat es
  3    * and ope n the temp late in th e editor.
  4    */
  5   package go v.va.med.n hin.adapte r.patientc orrelation ;
  6  
  7   import gov .hhs.fha.n hinc.commo n.nhinccom mon.Assert ionType;
  8   import gov .hhs.fha.n hinc.commo n.nhinccom mon.CeType ;
  9   import gov .hhs.fha.n hinc.commo n.nhinccom mon.HomeCo mmunityTyp e;
  10   import gov .hhs.fha.n hinc.commo n.nhinccom mon.Person NameType;
  11   import gov .hhs.fha.n hinc.commo n.nhinccom mon.UserTy pe;
  12   import jav a.text.*;
  13   import jav a.util.*;
  14   import jav ax.xml.bin d.*;
  15  
  16   import org .jmock.*;
  17   import org .jmock.int egration.j unit4.*;
  18   import org .junit.*;
  19   import org .junit.run ner.*;
  20   import sta tic org.ju nit.Assert .*;
  21  
  22   import gov .hhs.fha.n hinc.trans form.subdi sc.*;
  23   import org .hl7.v3.*;
  24  
  25   import gov .va.med.nh in.adapter .audit.*;
  26   import gov .va.med.nh in.adapter .datamanag er.*;
  27   import gov .va.med.nh in.adapter .facilitym anager.*;
  28   import gov .va.med.nh in.adapter .propertyl ookup.*;
  29   import gov .va.med.nh in.adapter .utils.*;
  30  
  31   /**
  32    *
  33    * @author   DN S      VAZQUD
  34    */
  35   @RunWith(J Mock.class )
  36   public cla ss Adapter PatientCor relationTe st
  37   {
  38       static  private f inal Strin g TEST_SEN DING_HCID  = "1.1";
  39       static  private f inal Strin g TEST_SEN DING_AA =  "1.1";
  40       static  private f inal Strin g TEST_REC EIVING_HCI D = "2.2";
  41       static  private f inal Strin g TEST_REC EIVING_AA  = "2.2";
  42       static  private f inal Strin g TEST_AA_ NAME = "Te st Assigni ng Authori ty";
  43       
  44       privat e Mockery  context =  new JUnit4 Mockery();
  45  
  46       public  AdapterPa tientCorre lationTest ()
  47       {
  48       }
  49  
  50       /**
  51        * Tes t of retri evePatient Correlatio ns method,  of class  AdapterPat ientCorrel ation.
  52        */
  53       /*
  54       @Test
  55       public  void test RetrievePa tientCorre lations()
  56       {
  57           Sy stem.out.p rintln("re trievePati entCorrela tions");
  58           Re trievePati entCorrela tionsReque stType ret rievePatie ntCorrelat ionsReques t = null;
  59           Ad apterPatie ntCorrelat ion instan ce = new A dapterPati entCorrela tion();
  60           Re trievePati entCorrela tionsRespo nseType ex pResult =  null;
  61           Re trievePati entCorrela tionsRespo nseType re sult = ins tance.retr ievePatien tCorrelati ons(retrie vePatientC orrelation sRequest);
  62           as sertEquals (expResult , result);
  63           //  TODO revi ew the gen erated tes t code and  remove th e default  call to fa il.
  64           fa il("The te st case is  a prototy pe.");
  65       }
  66       */
  67       
  68       /**
  69        * Tes t of addPa tientCorre lation met hod, of cl ass Adapte rPatientCo rrelation.
  70        */
  71       @Test
  72       public  void test AddPatient Correlatio nNullReque st()
  73       {
  74           Sy stem.out.p rintln("ad dPatientCo rrelationN ullRequest ");
  75           Ad dPatientCo rrelationR equestType  request =  null;
  76           Ad apterPatie ntCorrelat ion instan ce = new A dapterPati entCorrela tion();
  77           Ad dPatientCo rrelationR esponseTyp e expResul t = null;
  78           
  79           tr y {
  80                AddPatie ntCorrelat ionRespons eType resu lt = insta nce.addPat ientCorrel ation(requ est);
  81                fail("Th is should  not happen !");
  82           }
  83           ca tch (Throw able t) {
  84                assertTr ue(true);
  85           }
  86       }
  87  
  88       @Test
  89       public  void test AddPatient Correlatio nNoPatient ()
  90       {
  91           Sy stem.out.p rintln("ad dPatientCo rrelationN ullRequest ");
  92           Ad dPatientCo rrelationR equestType  request =  new AddPa tientCorre lationRequ estType();
  93           Ad apterPatie ntCorrelat ion instan ce = new A dapterPati entCorrela tion();
  94           Ad dPatientCo rrelationR esponseTyp e expResul t = null;
  95           
  96           tr y {
  97                AddPatie ntCorrelat ionRespons eType resu lt = insta nce.addPat ientCorrel ation(requ est);
  98                fail("Th is should  not happen !");
  99           }
  100           ca tch (Throw able t) {
  101                assertTr ue(true);
  102           }
  103       }
  104       
  105       @Test
  106       public  void test AddPatient Correlatio n()
  107       {
  108           Sy stem.out.p rintln("ad dPatientCo rrelationN ullRequest ");
  109           Ad dPatientCo rrelationR equestType  request =  new AddPa tientCorre lationRequ estType();
  110           
  111           fi nal Map de mographics  = new Has hMap() {{
  112                put("nam eGiven", n ew ArrayLi st() {{
  113                    add( "Test");
  114                    add( "Middle");
  115                }});
  116                put("nam ePrefix",  null);
  117                put("nam eSuffix",  null);
  118                put("nam eFamily",  "Patient") ;
  119                put("gen derCode",  "M");
  120                put("bir thDate", " 20120724") ;
  121                put("SSN ", "666003 333");
  122                put("MRN ", "123456 7890V12345 6");
  123           }} ;
  124  
  125           fi nal Map de mographics Ext = new  HashMap()  {{
  126                put("hom eAddressSt reet", new  ArrayList () {{
  127                    add( "1234 Test  Lane");
  128                    add( "Apt 37");
  129                }});
  130                put("hom eAddressCi ty", "Test  City");
  131                put("hom eAddressSt ate", "LA" );
  132                put("hom eAddressPo stal", "70 124");
  133                put("pho neHome", " tel:+1-333 -777-8888" );
  134                put("mar italStatus Cod", "S") ;
  135                put("mul tipleBirth Code", "N" );
  136           }} ;
  137           
  138           PR PAIN201305 UV02 prpai n201305UV0 2 = create PRPAIN2013 05(
  139                    (Str ing)demogr aphics.get ("nameFami ly"),
  140                    (Lis t<String>) demographi cs.get("na meGiven"),
  141                    (Str ing)demogr aphics.get ("namePref ix"),
  142                    (Str ing)demogr aphics.get ("nameSuff ix"),
  143                    (Str ing)demogr aphics.get ("birthDat e"),
  144                    (Str ing)demogr aphicsExt. get("homeA ddressCity "),
  145                    (Str ing)demogr aphicsExt. get("homeA ddressStat e"),
  146                    (Lis t<String>) demographi csExt.get( "homeAddre ssStreet") ,
  147                    (Str ing)demogr aphicsExt. get("homeA ddressPost al"),
  148                    (Str ing)demogr aphicsExt. get("phone Home"),
  149                    (Str ing)demogr aphics.get ("genderCo de"),
  150                    (Str ing)demogr aphicsExt. get("multi pleBirthCo de"),
  151                    (Str ing)demogr aphicsExt. get("marit alStatusCo de"),
  152                    (Str ing)demogr aphics.get ("MRN"),
  153                    TEST _SENDING_H CID,
  154                    TEST _SENDING_A A,
  155                    (Str ing)demogr aphics.get ("SSN"));
  156           PR PAIN201301 UV02 prpai n201301UV0 2 = HL7PRP A201301Tra nsforms.cr eatePRPA20 1301(prpai n201305UV0 2, TEST_RE CEIVING_HC ID);
  157           II  localPati entId = ne w II();
  158           lo calPatient Id.setAssi gningAutho rityName(T EST_AA_NAM E);
  159           lo calPatient Id.setRoot (TEST_RECE IVING_AA);
  160           lo calPatient Id.setExte nsion("123 4567890V12 3456");
  161           pr pain201301 UV02.getCo ntrolActPr ocess().ge tSubject() .get(0).ge tRegistrat ionEvent() .getSubjec t1().getPa tient().ge tId().add( localPatie ntId);
  162           re quest.setP RPAIN20130 1UV02(prpa in201301UV 02);
  163  
  164           As sertionTyp e assertio n = new As sertionTyp e();
  165           Ho meCommunit yType home Community  = new Home CommunityT ype();
  166           ho meCommunit y.setHomeC ommunityId ("urn:oid: " + TEST_S ENDING_HCI D);
  167           as sertion.se tHomeCommu nity(homeC ommunity);
  168           Us erType use r = new Us erType();
  169           us er.setUser Name("remo teUser");
  170           Pe rsonNameTy pe personN ame = new  PersonName Type();
  171           pe rsonName.s etFamilyNa me("User") ;
  172           pe rsonName.s etGivenNam e("Test");
  173           us er.setPers onName(per sonName);
  174           us er.setOrg( homeCommun ity);
  175           as sertion.se tUserInfo( user);
  176           Ce Type role  = new CeTy pe();
  177           ro le.setCode ("12345");
  178           us er.setRole Coded(role );
  179           Ce Type pou =  new CeTyp e();
  180           po u.setCode( "TREATMENT ");
  181           as sertion.se tPurposeOf Disclosure Coded(pou) ;
  182           re quest.setA ssertion(a ssertion);
  183           
  184           fi nal Facili ty facilit y = new Fa cility();
  185           fa cility.set FacilityNu mber("VA") ;
  186           fa cility.set HomeCommun ityId(TEST _RECEIVING _HCID);
  187           fa cility.set FullHomeCo mmunityId( "urn:oid:"  + TEST_RE CEIVING_HC ID);
  188  
  189           fi nal Map pa tient = ne w HashMap( ) {{
  190                put("dem ographics" , demograp hics);
  191                put("dem ographicsE xt", demog raphicsExt );
  192                put("pat ientPrefer redFacilit yNumber",  "TEST");
  193                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  194           }} ;
  195  
  196           fi nal List p atients =  new ArrayL ist() {{
  197                add(pati ent);
  198           }} ;
  199           
  200           fi nal Audit  audit = ne w Audit();
  201           au dit.setAct ion("AddPa tientCorre lation");
  202           au dit.setDet ails(
  203                "ICN=" +  demograph ics.get("M RN")
  204                + ", cor relatedPat ientId=" +  demograph ics.get("M RN")
  205                + ", cor relatedAss igningAuth ority=" +  TEST_SENDI NG_AA
  206                + ", cor relatedAss igningFaci lity=" + T EST_SENDIN G_HCID
  207                + ", fam ilyName="  + demograp hics.get(" nameFamily ")
  208                + ", fir stName=" +  ((List<St ring>)demo graphics.g et("nameGi ven")).get (0)
  209                + ", mid dleName="  + ((List<S tring>)dem ographics. get("nameG iven")).ge t(1)
  210                + ", gen der=" + de mographics .get("gend erCode")
  211                + ", dob =" + demog raphics.ge t("birthDa te")
  212                + ", hom eAddressCi ty=" + dem ographicsE xt.get("ho meAddressC ity")
  213                + ", hom eAddressSt ate=" + de mographics Ext.get("h omeAddress State")
  214                + ", hom eAddressSt reet=" + ( (List<Stri ng>)demogr aphicsExt. get("homeA ddressStre et")).get( 0)
  215                + ", hom eAddressSt reet=" + ( (List<Stri ng>)demogr aphicsExt. get("homeA ddressStre et")).get( 1)
  216                + ", hom eAddressPo stal=" + d emographic sExt.get(" homeAddres sPostal")
  217                + ", hom ePhone=" +  ((String) demographi csExt.get( "phoneHome ")).substr ing(5)
  218                + ", ssn =" + demog raphics.ge t("SSN")
  219           );
  220           au dit.setOrg anizationI d(assertio n.getHomeC ommunity() .getHomeCo mmunityId( ));
  221           au dit.setPat ientFacili tyName((St ring)patie nt.get("pa tientPrefe rredFacili tyName"));
  222           au dit.setPat ientFacili tyNumber(( String)pat ient.get(" patientPre ferredFaci lityNumber "));
  223           au dit.setPat ientGivenN ame(((List <String>)d emographic s.get("nam eGiven")). get(0));
  224           au dit.setPat ientId((St ring)demog raphics.ge t("MRN"));
  225           au dit.setPat ientLastNa me((String )demograph ics.get("n ameFamily" ));
  226           au dit.setPat ientSSN((S tring)demo graphics.g et("SSN")) ;
  227           au dit.setPur poseForUse (assertion .getPurpos eOfDisclos ureCoded() .getCode() );
  228           au dit.setRem oteOrganiz ationId("u rn:oid:" +  TEST_RECE IVING_HCID );
  229           au dit.setUse rFacilityN ame(assert ion.getUse rInfo().ge tOrg().get Name());
  230           au dit.setUse rFacilityN umber(asse rtion.getU serInfo(). getOrg().g etHomeComm unityId()) ;
  231           au dit.setUse rId(assert ion.getUse rInfo().ge tUserName( ));
  232           au dit.setUse rName(asse rtion.getU serInfo(). getPersonN ame().getG ivenName()  + " " + a ssertion.g etUserInfo ().getPers onName().g etFamilyNa me());
  233           au dit.setUse rRole(asse rtion.getU serInfo(). getRoleCod ed().getCo de());
  234           
  235           Ad apterPatie ntCorrelat ion instan ce = new A dapterPati entCorrela tion();
  236           
  237           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  238           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  239           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  240           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  241           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  242           
  243           in stance.set PropertyLo okup(prope rtyLookup) ;
  244           in stance.set DataManage r(dataMana ger);
  245           in stance.set FacilityMa nager(faci lityManage r);
  246           in stance.set AuditManag er(auditMa nager);
  247           
  248           co ntext.chec king(new E xpectation s() {{
  249                allowing (propertyL ookup).get Property(" AssigningA uthority") ;
  250                will(ret urnValue(T EST_RECEIV ING_AA));
  251                
  252                oneOf(da taManager) .getQuery( "MPI.linkP atient");
  253                will(ret urnValue(d ataQuery)) ;
  254                oneOf(da taQuery).s etParamete r("patient Id", (Stri ng)demogra phics.get( "MRN"));
  255                oneOf(da taQuery).s etParamete r("correla tedPatient Id", (Stri ng)demogra phics.get( "MRN"));
  256                oneOf(da taQuery).s etParamete r("correla tedAssigni ngAuthorit y", TEST_S ENDING_AA) ;
  257                oneOf(da taQuery).s etParamete r("correla tedAssigni ngFacility ", TEST_SE NDING_HCID );
  258                oneOf(da taQuery).s etParamete r("familyN ame", (Str ing)demogr aphics.get ("nameFami ly"));
  259                oneOf(da taQuery).g etParamete r("firstNa me");
  260                will(ret urnValue(n ull));
  261                oneOf(da taQuery).s etParamete r("firstNa me", ((Lis t<String>) demographi cs.get("na meGiven")) .get(0));
  262                oneOf(da taQuery).g etParamete r("firstNa me");
  263                will(ret urnValue(( (List<Stri ng>)demogr aphics.get ("nameGive n")).get(0 )));
  264                oneOf(da taQuery).g etParamete r("middleN ame");
  265                will(ret urnValue(n ull));
  266                oneOf(da taQuery).s etParamete r("middleN ame", ((Li st<String> )demograph ics.get("n ameGiven") ).get(1));
  267                oneOf(da taQuery).s etParamete r("gender" , demograp hics.get(" genderCode "));
  268                oneOf(da taQuery).s etParamete r("dob", d emographic s.get("bir thDate"));
  269                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 1", ((List <String>)d emographic sExt.get(" homeAddres sStreet")) .get(0));
  270                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 2", ((List <String>)d emographic sExt.get(" homeAddres sStreet")) .get(1));
  271                oneOf(da taQuery).s etParamete r("homeAdd ressCity",  demograph icsExt.get ("homeAddr essCity")) ;
  272                oneOf(da taQuery).s etParamete r("homeAdd ressState" , demograp hicsExt.ge t("homeAdd ressState" ));
  273                oneOf(da taQuery).s etParamete r("homeAdd ressPostal ", demogra phicsExt.g et("homeAd dressPosta l"));
  274                oneOf(da taQuery).s etParamete r("homePho ne", ((Str ing)demogr aphicsExt. get("phone Home")).su bstring(5) );
  275                oneOf(da taQuery).s etParamete r("ssn", d emographic s.get("SSN "));
  276                oneOf(da taQuery).g etResults( );
  277                
  278                oneOf(fa cilityMana ger).addAs signingAut horityToFa cility(TES T_SENDING_ HCID, TEST _SENDING_A A, TEST_AA _NAME);
  279                
  280                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  281                will(ret urnValue(d ataQuery)) ;
  282                oneOf(da taQuery).s etParamete r("icn", " 1234567890 V123456");
  283                oneOf(da taQuery).g etResults( );
  284                will(ret urnValue(p atients));
  285                
  286                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  287                will(ret urnValue(f acility));
  288                
  289                oneOf(au ditManager ).storeAud it(audit);
  290           }} );
  291           
  292           Ad dPatientCo rrelationR esponseTyp e result =  instance. addPatient Correlatio n(request) ;
  293           as sert(resul t != null) ;
  294       }
  295       
  296       @Test
  297       public  void test AddPatient Correlatio nNoMiddleN ame()
  298       {
  299           Sy stem.out.p rintln("ad dPatientCo rrelationN oMiddleNam e");
  300           Ad dPatientCo rrelationR equestType  request =  new AddPa tientCorre lationRequ estType();
  301           
  302           fi nal Map de mographics  = new Has hMap() {{
  303                put("nam eGiven", n ew ArrayLi st() {{
  304                    add( "Test");
  305                }});
  306                put("nam ePrefix",  null);
  307                put("nam eSuffix",  null);
  308                put("nam eFamily",  "Patient") ;
  309                put("gen derCode",  "M");
  310                put("bir thDate", " 20120724") ;
  311                put("SSN ", "666003 333");
  312                put("MRN ", "123456 7890V12345 6");
  313           }} ;
  314  
  315           fi nal Map de mographics Ext = new  HashMap()  {{
  316                put("hom eAddressSt reet", new  ArrayList () {{
  317                    add( "1234 Test  Lane");
  318                }});
  319                put("hom eAddressCi ty", "Test  City");
  320                put("hom eAddressSt ate", "LA" );
  321                put("hom eAddressPo stal", "70 124");
  322                put("pho neHome", " tel:+1-333 -777-8888" );
  323                put("mar italStatus Cod", "S") ;
  324                put("mul tipleBirth Code", "N" );
  325           }} ;
  326           
  327           PR PAIN201305 UV02 prpai n201305UV0 2 = create PRPAIN2013 05(
  328                    (Str ing)demogr aphics.get ("nameFami ly"),
  329                    (Lis t<String>) demographi cs.get("na meGiven"),
  330                    (Str ing)demogr aphics.get ("namePref ix"),
  331                    (Str ing)demogr aphics.get ("nameSuff ix"),
  332                    (Str ing)demogr aphics.get ("birthDat e"),
  333                    (Str ing)demogr aphicsExt. get("homeA ddressCity "),
  334                    (Str ing)demogr aphicsExt. get("homeA ddressStat e"),
  335                    (Lis t<String>) demographi csExt.get( "homeAddre ssStreet") ,
  336                    (Str ing)demogr aphicsExt. get("homeA ddressPost al"),
  337                    (Str ing)demogr aphicsExt. get("phone Home"),
  338                    (Str ing)demogr aphics.get ("genderCo de"),
  339                    (Str ing)demogr aphicsExt. get("multi pleBirthCo de"),
  340                    (Str ing)demogr aphicsExt. get("marit alStatusCo de"),
  341                    (Str ing)demogr aphics.get ("MRN"),
  342                    TEST _SENDING_H CID,
  343                    TEST _SENDING_A A,
  344                    (Str ing)demogr aphics.get ("SSN"));
  345           PR PAIN201301 UV02 prpai n201301UV0 2 = HL7PRP A201301Tra nsforms.cr eatePRPA20 1301(prpai n201305UV0 2, TEST_RE CEIVING_HC ID);
  346           II  localPati entId = ne w II();
  347           lo calPatient Id.setAssi gningAutho rityName(T EST_AA_NAM E);
  348           lo calPatient Id.setRoot (TEST_RECE IVING_AA);
  349           lo calPatient Id.setExte nsion("123 4567890V12 3456");
  350           pr pain201301 UV02.getCo ntrolActPr ocess().ge tSubject() .get(0).ge tRegistrat ionEvent() .getSubjec t1().getPa tient().ge tId().add( localPatie ntId);
  351           re quest.setP RPAIN20130 1UV02(prpa in201301UV 02);
  352  
  353           As sertionTyp e assertio n = new As sertionTyp e();
  354           Ho meCommunit yType home Community  = new Home CommunityT ype();
  355           ho meCommunit y.setHomeC ommunityId ("urn:oid: " + TEST_S ENDING_HCI D);
  356           as sertion.se tHomeCommu nity(homeC ommunity);
  357           Us erType use r = new Us erType();
  358           us er.setUser Name("remo teUser");
  359           Pe rsonNameTy pe personN ame = new  PersonName Type();
  360           pe rsonName.s etFamilyNa me("User") ;
  361           pe rsonName.s etGivenNam e("Test");
  362           us er.setPers onName(per sonName);
  363           us er.setOrg( homeCommun ity);
  364           as sertion.se tUserInfo( user);
  365           Ce Type role  = new CeTy pe();
  366           ro le.setCode ("12345");
  367           us er.setRole Coded(role );
  368           Ce Type pou =  new CeTyp e();
  369           po u.setCode( "TREATMENT ");
  370           as sertion.se tPurposeOf Disclosure Coded(pou) ;
  371           re quest.setA ssertion(a ssertion);
  372           
  373           fi nal Facili ty facilit y = new Fa cility();
  374           fa cility.set FacilityNu mber("VA") ;
  375           fa cility.set HomeCommun ityId(TEST _RECEIVING _HCID);
  376           fa cility.set FullHomeCo mmunityId( "urn:oid:"  + TEST_RE CEIVING_HC ID);
  377  
  378           fi nal Map pa tient = ne w HashMap( ) {{
  379                put("dem ographics" , demograp hics);
  380                put("dem ographicsE xt", demog raphicsExt );
  381                put("pat ientPrefer redFacilit yNumber",  "TEST");
  382                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  383           }} ;
  384  
  385           fi nal List p atients =  new ArrayL ist() {{
  386                add(pati ent);
  387           }} ;
  388           
  389           fi nal Audit  audit = ne w Audit();
  390           au dit.setAct ion("AddPa tientCorre lation");
  391           au dit.setDet ails(
  392                "ICN=" +  demograph ics.get("M RN")
  393                + ", cor relatedPat ientId=" +  demograph ics.get("M RN")
  394                + ", cor relatedAss igningAuth ority=" +  TEST_SENDI NG_AA
  395                + ", cor relatedAss igningFaci lity=" + T EST_SENDIN G_HCID
  396                + ", fam ilyName="  + demograp hics.get(" nameFamily ")
  397                + ", fir stName=" +  ((List<St ring>)demo graphics.g et("nameGi ven")).get (0)
  398                + ", gen der=" + de mographics .get("gend erCode")
  399                + ", dob =" + demog raphics.ge t("birthDa te")
  400                + ", hom eAddressCi ty=" + dem ographicsE xt.get("ho meAddressC ity")
  401                + ", hom eAddressSt ate=" + de mographics Ext.get("h omeAddress State")
  402                + ", hom eAddressSt reet=" + ( (List<Stri ng>)demogr aphicsExt. get("homeA ddressStre et")).get( 0)
  403                + ", hom eAddressPo stal=" + d emographic sExt.get(" homeAddres sPostal")
  404                + ", hom ePhone=" +  ((String) demographi csExt.get( "phoneHome ")).substr ing(5)
  405                + ", ssn =" + demog raphics.ge t("SSN")
  406           );
  407           au dit.setOrg anizationI d(assertio n.getHomeC ommunity() .getHomeCo mmunityId( ));
  408           au dit.setPat ientFacili tyName((St ring)patie nt.get("pa tientPrefe rredFacili tyName"));
  409           au dit.setPat ientFacili tyNumber(( String)pat ient.get(" patientPre ferredFaci lityNumber "));
  410           au dit.setPat ientGivenN ame(((List <String>)d emographic s.get("nam eGiven")). get(0));
  411           au dit.setPat ientId((St ring)demog raphics.ge t("MRN"));
  412           au dit.setPat ientLastNa me((String )demograph ics.get("n ameFamily" ));
  413           au dit.setPat ientSSN((S tring)demo graphics.g et("SSN")) ;
  414           au dit.setPur poseForUse (assertion .getPurpos eOfDisclos ureCoded() .getCode() );
  415           au dit.setRem oteOrganiz ationId("u rn:oid:" +  TEST_RECE IVING_HCID );
  416           au dit.setUse rFacilityN ame(assert ion.getUse rInfo().ge tOrg().get Name());
  417           au dit.setUse rFacilityN umber(asse rtion.getU serInfo(). getOrg().g etHomeComm unityId()) ;
  418           au dit.setUse rId(assert ion.getUse rInfo().ge tUserName( ));
  419           au dit.setUse rName(asse rtion.getU serInfo(). getPersonN ame().getG ivenName()  + " " + a ssertion.g etUserInfo ().getPers onName().g etFamilyNa me());
  420           au dit.setUse rRole(asse rtion.getU serInfo(). getRoleCod ed().getCo de());
  421           
  422           Ad apterPatie ntCorrelat ion instan ce = new A dapterPati entCorrela tion();
  423           
  424           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  425           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  426           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  427           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  428           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  429           
  430           in stance.set PropertyLo okup(prope rtyLookup) ;
  431           in stance.set DataManage r(dataMana ger);
  432           in stance.set FacilityMa nager(faci lityManage r);
  433           in stance.set AuditManag er(auditMa nager);
  434           
  435           co ntext.chec king(new E xpectation s() {{
  436                allowing (propertyL ookup).get Property(" AssigningA uthority") ;
  437                will(ret urnValue(T EST_RECEIV ING_AA));
  438                
  439                oneOf(da taManager) .getQuery( "MPI.linkP atient");
  440                will(ret urnValue(d ataQuery)) ;
  441                oneOf(da taQuery).s etParamete r("patient Id", (Stri ng)demogra phics.get( "MRN"));
  442                oneOf(da taQuery).s etParamete r("correla tedPatient Id", (Stri ng)demogra phics.get( "MRN"));
  443                oneOf(da taQuery).s etParamete r("correla tedAssigni ngAuthorit y", TEST_S ENDING_AA) ;
  444                oneOf(da taQuery).s etParamete r("correla tedAssigni ngFacility ", TEST_SE NDING_HCID );
  445                oneOf(da taQuery).s etParamete r("familyN ame", (Str ing)demogr aphics.get ("nameFami ly"));
  446                oneOf(da taQuery).g etParamete r("firstNa me");
  447                will(ret urnValue(n ull));
  448                oneOf(da taQuery).s etParamete r("firstNa me", ((Lis t<String>) demographi cs.get("na meGiven")) .get(0));
  449                oneOf(da taQuery).s etParamete r("gender" , demograp hics.get(" genderCode "));
  450                oneOf(da taQuery).s etParamete r("dob", d emographic s.get("bir thDate"));
  451                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 1", ((List <String>)d emographic sExt.get(" homeAddres sStreet")) .get(0));
  452                oneOf(da taQuery).s etParamete r("homeAdd ressCity",  demograph icsExt.get ("homeAddr essCity")) ;
  453                oneOf(da taQuery).s etParamete r("homeAdd ressState" , demograp hicsExt.ge t("homeAdd ressState" ));
  454                oneOf(da taQuery).s etParamete r("homeAdd ressPostal ", demogra phicsExt.g et("homeAd dressPosta l"));
  455                oneOf(da taQuery).s etParamete r("homePho ne", ((Str ing)demogr aphicsExt. get("phone Home")).su bstring(5) );
  456                oneOf(da taQuery).s etParamete r("ssn", d emographic s.get("SSN "));
  457                oneOf(da taQuery).g etResults( );
  458                
  459                oneOf(fa cilityMana ger).addAs signingAut horityToFa cility(TES T_SENDING_ HCID, TEST _SENDING_A A, TEST_AA _NAME);
  460                
  461                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  462                will(ret urnValue(d ataQuery)) ;
  463                oneOf(da taQuery).s etParamete r("icn", " 1234567890 V123456");
  464                oneOf(da taQuery).g etResults( );
  465                will(ret urnValue(p atients));
  466                
  467                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  468                will(ret urnValue(f acility));
  469                
  470                oneOf(au ditManager ).storeAud it(audit);
  471           }} );
  472           
  473           Ad dPatientCo rrelationR esponseTyp e result =  instance. addPatient Correlatio n(request) ;
  474           as sert(resul t != null) ;
  475       }
  476       
  477       privat e PRPAIN20 1305UV02 c reatePRPAI N201305(St ring lastN ame,
  478                                                       Li st<String>  givenName ,
  479                                                       St ring prefi x,
  480                                                       St ring suffi x,
  481                                                       St ring dob,
  482                                                       St ring city,
  483                                                       St ring state ,
  484                                                       Li st<String>  address,
  485                                                       St ring zip,
  486                                                       St ring phone ,
  487                                                       St ring gende r,
  488                                                       St ring multi Birth,
  489                                                       St ring marit alStatus,
  490                                                       St ring patie ntId,
  491                                                       St ring homeC ommunityId ,
  492                                                       St ring assig ningAuthor ity,
  493                                                       St ring ssn)
  494       {
  495           JA XBElement< PRPAMT2013 01UV02Pers on> patien tPerson =
  496                    buil dPRPAIN201 301Patient Person(las tName,
  497                                                      giv enName,
  498                                                      pre fix,
  499                                                      suf fix,
  500                                                      dob ,
  501                                                      cit y,
  502                                                      sta te,
  503                                                      add ress,
  504                                                      zip ,
  505                                                      pho ne,
  506                                                      gen der,
  507                                                      mul tiBirth,
  508                                                      mar italStatus );
  509  
  510           II  ii = new  II();
  511           ii .setRoot(a ssigningAu thority);
  512           ii .setExtens ion(patien tId);
  513           St ring assig ningAuthor ityName =  TEST_AA_NA ME;
  514           if  (!NullChe cker.isNul lOrEmpty(a ssigningAu thorityNam e)) {
  515                ii.setAs signingAut horityName (assigning AuthorityN ame);
  516           }
  517  
  518           PR PAMT201301 UV02Patien t patient  =
  519                    HL7P atientTran sforms.cre ate201301P atient(pat ientPerson , ii);
  520  
  521           PR PAIN201305 UV02 ret =
  522                    HL7P RPA201305T ransforms. createPRPA 201305(pat ient, home CommunityI d, "1.1",  assigningA uthority);
  523  
  524           //  add ssn.
  525           PR PAMT201306 UV02Parame terList pa ramList =  ret.getCon trolActPro cess().get QueryByPar ameter().g etValue(). getParamet erList();
  526           PR PAMT201306 UV02Living SubjectId  ssnId = ne w PRPAMT20 1306UV02Li vingSubjec tId();
  527           ii  = new II( );
  528           ii .setRoot(" 2.16.840.1 .113883.4. 1");
  529           ii .setExtens ion(ssn);
  530           ss nId.getVal ue().add(i i);
  531           ST  text = ne w ST();
  532           ss nId.setSem anticsText (text);
  533           pa ramList.ge tLivingSub jectId().a dd(ssnId);
  534  
  535           //  fix the i nteraction  id.
  536           re t.setInter actionId(H L7DataTran sformHelpe r.IIFactor y(HL7Const ants.INTER ACTION_ID_ ROOT, "PRP A_IN201305 UV02"));
  537  
  538           //  fix the c ontrolActP roccess/co de.
  539           re t.getContr olActProce ss().setCo de(HL7Data TransformH elper.CDFa ctory("PRP A_TE201305 UV02", HL7 Constants. INTERACTIO N_ID_ROOT) );
  540  
  541           //  fix the a cceptAckCo de.
  542           re t.setAccep tAckCode(H L7DataTran sformHelpe r.CSFactor y("NE"));
  543           
  544           //  fix the p rocessingM odeCode.
  545           re t.setProce ssingModeC ode(HL7Dat aTransform Helper.CSF actory("T" ));
  546           
  547           re t.getContr olActProce ss().setCl assCode(Ac tClassCont rolAct.CAC T);
  548           re t.getContr olActProce ss().getAu thorOrPerf ormer().ge t(0).getAs signedDevi ce().getVa lue().setC lassCode(" ASSIGNED") ;
  549           
  550           //  fix the c reation ti me of the  message.
  551           TS Explicit t e = new TS Explicit() ;
  552           Da te now = n ew Date();
  553           Si mpleDateFo rmat forma tter = new  SimpleDat eFormat("y yyyMMddHHm mss");
  554           fo rmatter.se tTimeZone( TimeZone.g etTimeZone ("UTC"));
  555           te .setValue( formatter. format(now ));
  556           re t.setCreat ionTime(te );
  557  
  558           CS  responseM odalityCod e = new CS ();
  559           re sponseModa lityCode.s etCode("R" );
  560           re t.getContr olActProce ss().getQu eryByParam eter().get Value().se tResponseM odalityCod e(response ModalityCo de);
  561           
  562           CS  responseP riorityCod e = new CS ();
  563           re sponsePrio rityCode.s etCode("I" );
  564           re t.getContr olActProce ss().getQu eryByParam eter().get Value().se tResponseP riorityCod e(response PriorityCo de);
  565                    
  566           re turn ret;
  567       }
  568  
  569       privat e JAXBElem ent<PRPAMT 201301UV02 Person> bu ildPRPAIN2 01301Patie ntPerson(S tring last Name,
  570                                                                                         L ist<String > givenNam e,
  571                                                                                         S tring pref ix,
  572                                                                                         S tring suff ix,
  573                                                                                         S tring dob,
  574                                                                                         S tring city ,
  575                                                                                         S tring stat e,
  576                                                                                         L ist<String > address,
  577                                                                                         S tring zip,
  578                                                                                         S tring phon e,
  579                                                                                         S tring gend er,
  580                                                                                         S tring mult iBirth,
  581                                                                                         S tring mari talStatus)
  582       {
  583           PR PAMT201301 UV02Person  patientPe rson = new  PRPAMT201 301UV02Per son();
  584  
  585           // ---------- ---------- ---------- ---------- ---------- ---------- --
  586           // build name
  587           or g.hl7.v3.O bjectFacto ry factory  = new org .hl7.v3.Ob jectFactor y();
  588           PN Explicit n ame = (PNE xplicit) ( factory.cr eatePNExpl icit());
  589           Li st namelis t = name.g etContent( );
  590  
  591           // Last name
  592           En ExplicitFa mily famil yName = ne w EnExplic itFamily() ;
  593           fa milyName.s etPartType ("FAM");
  594           fa milyName.s etContent( lastName);
  595           na melist.add (factory.c reatePNExp licitFamil y(familyNa me));
  596  
  597           // First name
  598           if  (NullChec ker.isNotN ullOrEmpty (givenName )) {
  599                for (Str ing n : gi venName) {
  600                    if ( !NullCheck er.isNullO rEmpty(n))  {
  601                         EnExplicit Given gn =  new EnExp licitGiven ();
  602                         gn.setPart Type("GIV" );
  603                         gn.setCont ent(n);
  604                         namelist.a dd(factory .createPNE xplicitGiv en(gn));
  605  
  606                    }
  607                }
  608           }
  609  
  610           En ExplicitPr efix pfx =  new EnExp licitPrefi x();
  611           pf x.setConte nt(prefix) ;
  612           pf x.setPartT ype("PFX") ;
  613           na melist.add (factory.c reateENExp licitPrefi x(pfx));
  614  
  615           En ExplicitSu ffix sfx =  new EnExp licitSuffi x();
  616           sf x.setConte nt(suffix) ;
  617           sf x.setPartT ype("SFX") ;
  618           na melist.add (factory.c reateENExp licitSuffi x(sfx));
  619  
  620           pa tientPerso n.getName( ).add(name );
  621           // ---------- ---------- ---------- ---------- ---------- ----------
  622  
  623  
  624           // Date of Bi rth
  625           TS Explicit v alueTSExpl icit = new  TSExplici t();
  626           va lueTSExpli cit.setVal ue(dob);
  627           pa tientPerso n.setBirth Time(value TSExplicit );
  628  
  629  
  630           // Gender
  631           CE  valueCE =  new CE();
  632           va lueCE.setC ode(gender );
  633           pa tientPerso n.setAdmin istrativeG enderCode( valueCE);
  634  
  635           // ---------- ---------- ---------- ---------- ---------- ---------- -
  636           //   build ad dress
  637           AD Explicit a ddr = (ADE xplicit) ( factory.cr eateADExpl icit());
  638           Li st addrlis t = addr.g etContent( );
  639  
  640           // address
  641           Ad xpExplicit City value City = new  AdxpExpli citCity();
  642           va lueCity.se tContent(c ity);
  643           ad drlist.add (factory.c reateADExp licitCity( valueCity) );
  644  
  645           Ad xpExplicit State valu eState = n ew AdxpExp licitState ();
  646           va lueState.s etContent( state);
  647           ad drlist.add (factory.c reateADExp licitState (valueStat e));
  648  
  649           if  (NullChec ker.isNotN ullOrEmpty (address))  {
  650                for (Str ing a : ad dress) {
  651                    if ( !NullCheck er.isNullO rEmpty(a))  {
  652                         AdxpExplic itStreetAd dressLine  line = new  AdxpExpli citStreetA ddressLine ();
  653                         line.setCo ntent(a);
  654                         addrlist.a dd(factory .createADE xplicitStr eetAddress Line(line) );
  655                    }
  656                }
  657           }
  658           
  659           Ad xpExplicit PostalCode  valueZip  = new Adxp ExplicitPo stalCode() ;
  660           va lueZip.set Content(zi p);
  661           ad drlist.add (factory.c reateADExp licitPosta lCode(valu eZip));
  662  
  663  
  664           pa tientPerso n.getAddr( ).add(addr );
  665           // ---------- ---------- ---------- ---------- ---------- ---------- --
  666  
  667  
  668           // telephone
  669           TE LExplicit  valueTELE  = new TELE xplicit();
  670           va lueTELE.se tValue(pho ne);
  671           pa tientPerso n.getTelec om().add(v alueTELE);
  672  
  673           // multi birt h
  674           BL  valueBL =  new BL();
  675           if  (multiBir th == null  || multiB irth.lengt h() == 0 | | multiBir th.startsW ith("NO")  || multiBi rth.starts With("no") ) {
  676                valueBL. setValue(f alse);
  677           }
  678           el se {
  679                valueBL. setValue(t rue);
  680           }
  681           pa tientPerso n.setMulti pleBirthIn d(valueBL) ;  //BL va lue
  682  
  683           //  marital s tatus
  684           CE  maritalSt atusCode =  new CE();
  685           ma ritalStatu sCode.setC ode(marita lStatus);
  686           pa tientPerso n.setMarit alStatusCo de(marital StatusCode );
  687  
  688           re turn facto ry.createP RPAMT20130 1UV02Patie ntPatientP erson(pati entPerson) ;
  689       }
  690   }