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

55.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\mpi AdapterMPITest.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\mpi AdapterMPITest.java Mon Apr 3 14:23:41 2017 UTC

55.2 Comparison summary

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

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

55.4 Active regular expressions

No regular expressions were active.

55.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.mpi;
  6  
  7   import gov .va.med.nh in.adapter .mvi.Adapt erMVI;
  8   import jav a.text.*;
  9   import jav a.util.*;
  10  
  11   import jav ax.xml.bin d.*;
  12  
  13   import gov .hhs.fha.n hinc.commo n.nhinccom mon.*;
  14   import gov .hhs.fha.n hinc.trans form.subdi sc.*;
  15   import org .junit.*;
  16   import org .junit.run ner.*;
  17   import sta tic org.ju nit.Assert .*;
  18   import org .hl7.v3.*;
  19   import org .jmock.*;
  20   import org .jmock.int egration.j unit4.*;
  21  
  22           
  23   import gov .va.med.nh in.adapter .audit.*;
  24   import gov .va.med.nh in.adapter .datamanag er.*;
  25   import gov .va.med.nh in.adapter .facilitym anager.*;
  26   import gov .va.med.nh in.adapter .propertyl ookup.*;
  27   import gov .va.med.nh in.adapter .utils.Nul lChecker;
  28  
  29   /**
  30    *
  31    * @author   DN S      VAZQUD
  32    */
  33   @RunWith(J Mock.class )
  34   public cla ss Adapter MPITest
  35   {
  36       static  final pri vate Strin g TEST_SEN DING_HCID  = "1.1";
  37       static  final pri vate Strin g TEST_SEN DING_AA =  "1.1";
  38       static  final pri vate Strin g TEST_REC EIVING_HCI D = "2.2";
  39       static  final pri vate Strin g TEST_REC EIVING_AA  = "2.2";
  40       static  final pri vate Strin g TEST_AA_ NAME = "Te st Assigni ng Authori ty";
  41       
  42       privat e Mockery  context =  new JUnit4 Mockery();
  43       
  44       public  AdapterMP ITest()
  45       {
  46       }
  47  
  48       @Test
  49       public  void test FindCandid atesNullRe quest()
  50       {
  51           Sy stem.out.p rintln("fi ndCandidat esNullRequ est");
  52           Re spondingGa tewayPRPAI N201305UV0 2RequestTy pe request  = null;
  53           Ad apterMVI i nstance =  new Adapte rMVI();
  54           PR PAIN201306 UV02 expRe sult = nul l;
  55           
  56           tr y {
  57                PRPAIN20 1306UV02 r esult = in stance.fin dCandidate s(request) ;
  58                fail("Th is shouldn 't happen! ");
  59           }
  60           ca tch (Throw able t) {
  61                assertTr ue(true);
  62           }
  63       }
  64       
  65       @Test
  66       public  void test FindCandid atesNullPR PAIN201305 UV02()
  67       {
  68           Sy stem.out.p rintln("fi ndCandidat esNullPRPA IN201305UV 02");
  69           Re spondingGa tewayPRPAI N201305UV0 2RequestTy pe request  = new Res pondingGat ewayPRPAIN 201305UV02 RequestTyp e();
  70           
  71           Ad apterMVI i nstance =  new Adapte rMVI();
  72           PR PAIN201306 UV02 expRe sult = nul l;
  73           
  74           tr y {
  75                PRPAIN20 1306UV02 r esult = in stance.fin dCandidate s(request) ;
  76                fail("Th is shouldn 't happen! ");
  77           }
  78           ca tch (Throw able t) {
  79                assertTr ue(true);
  80           }
  81       }
  82       
  83       @Test
  84       public  void test FindCandid ates()
  85       {
  86           Sy stem.out.p rintln("fi ndCandidat es");
  87           Re spondingGa tewayPRPAI N201305UV0 2RequestTy pe request  = new Res pondingGat ewayPRPAIN 201305UV02 RequestTyp e();
  88           
  89           PR PAIN201305 UV02 prpai n201305UV0 2 = create PRPAIN2013 05(
  90                    "Pat ient",
  91                    Arra ys.asList( new String []{"Test",  "Middle"} ),
  92                    null ,
  93                    null ,
  94                    "201 20724",
  95                    "New  Orleans",
  96                    "LA" ,
  97                    Arra ys.asList( new String []{"1234 T est Lane"} ),
  98                    "701 43",
  99                    "tel :+1-504-52 9-6111",
  100                    "M",
  101                    "no" ,
  102                    "M",
  103                    "123 4567890V12 3456",
  104                    TEST _SENDING_H CID,
  105                    TEST _SENDING_A A,
  106                    "666 003333");
  107           re quest.setP RPAIN20130 5UV02(prpa in201305UV 02);
  108           
  109           As sertionTyp e assertio n = new As sertionTyp e();
  110           Ho meCommunit yType home Community  = new Home CommunityT ype();
  111           ho meCommunit y.setHomeC ommunityId ("urn:oid: " + TEST_S ENDING_HCI D);
  112           as sertion.se tHomeCommu nity(homeC ommunity);
  113           Us erType use r = new Us erType();
  114           us er.setUser Name("remo teUser");
  115           Pe rsonNameTy pe personN ame = new  PersonName Type();
  116           pe rsonName.s etFamilyNa me("User") ;
  117           pe rsonName.s etGivenNam e("Test");
  118           us er.setPers onName(per sonName);
  119           us er.setOrg( homeCommun ity);
  120           as sertion.se tUserInfo( user);
  121           Ce Type role  = new CeTy pe();
  122           ro le.setCode ("12345");
  123           us er.setRole Coded(role );
  124           Ce Type pou =  new CeTyp e();
  125           po u.setCode( "TREATMENT ");
  126           as sertion.se tPurposeOf Disclosure Coded(pou) ;
  127           re quest.setA ssertion(a ssertion);
  128           
  129           Si mpleDateFo rmat forma tter = new  SimpleDat eFormat("y yyyMMdd");
  130           fi nal Date d ob;
  131           Da te dobInne r = null;
  132           tr y {
  133                dobInner  = formatt er.parse(" 20120724") ;
  134           }
  135           ca tch (Parse Exception  pe) {
  136                fail("Fa iled to pa rse dob");
  137           }
  138           fi nally {
  139                dob = do bInner;
  140           }
  141           
  142           fi nal Facili ty sending Facility =  new Facil ity();
  143           se ndingFacil ity.setFac ilityNumbe r("200TEST ");
  144           se ndingFacil ity.setHom eCommunity Id(TEST_SE NDING_HCID );
  145           se ndingFacil ity.setFul lHomeCommu nityId("ur n:oid:" +  TEST_SENDI NG_HCID);
  146           
  147           fi nal Facili ty facilit y = new Fa cility();
  148           fa cility.set FacilityNu mber("VA") ;
  149           fa cility.set HomeCommun ityId(TEST _RECEIVING _HCID);
  150           fa cility.set FullHomeCo mmunityId( "urn:oid:"  + TEST_RE CEIVING_HC ID);
  151           
  152           fi nal Map mp iResult =  new HashMa p();
  153           mp iResult.pu t("icn", " 1234567890 V123456");
  154           mp iResult.pu t("ssn", " 666003333" );
  155           mp iResult.pu t("firstNa me", "Test ");
  156           mp iResult.pu t("middleN ame", null );
  157           mp iResult.pu t("lastNam e", "Patie nt");
  158           mp iResult.pu t("gender" , "M");
  159           mp iResult.pu t("dob", d ob);
  160           
  161           fi nal List<M ap> mpiRes ults = new  ArrayList <Map>();
  162           mp iResults.a dd(mpiResu lt);
  163           
  164           fi nal Map de mographics Ext = new  HashMap()  {{
  165                put("hom eAddressSt reet", new  ArrayList () {{
  166                    add( "1234 Test  Lane");
  167                    add( "Apt 37");
  168                }});
  169                put("hom eAddressCi ty", "Test  City");
  170                put("hom eAddressSt ate", "LA" );
  171                put("hom eAddressPo stal", "70 124");
  172                put("pho neHome", " tel:+1-333 -777-8888" );
  173                put("mar italStatus Cod", "S") ;
  174                put("mul tipleBirth Code", "N" );
  175           }} ;
  176  
  177           fi nal Map pa tient = ne w HashMap( ) {{
  178                put("dem ographicsE xt", demog raphicsExt );
  179                put("pat ientPrefer redFacilit yNumber",  "TEST");
  180                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  181           }} ;
  182           
  183           fi nal List<M ap> patien ts = new A rrayList<M ap>();
  184           pa tients.add (patient);
  185           
  186           fi nal Audit  audit = ne w Audit();
  187           au dit.setAct ion("MPI f indMatch") ;
  188           au dit.setDet ails(
  189                "MATCH F OUND ICN=  " + mpiRes ult.get("i cn")
  190                + " Remo te Facilit y=" + TEST _SENDING_H CID
  191                + " ssn= 666003333"
  192                + ", las tName=Pati ent"
  193                + ", mid dleName=Mi ddle"
  194                + ", fir stName=Tes t"
  195                + ", add ress[0]=12 34 Test La ne"
  196                + ", cit y=New Orle ans"
  197                + ", sta te=LA"
  198                + ", zip =70143"
  199                + ", pho neNumber=t el:+1-504- 529-6111"
  200                + ", gen der=M"
  201                + ", dob =2012-07-2 4 00:00:00 .0, "
  202           );
  203           au dit.setOrg anizationI d("urn:oid :" + TEST_ SENDING_HC ID);
  204           au dit.setPat ientFacili tyName("Te st Facilit y");
  205           au dit.setPat ientFacili tyNumber(" TEST");
  206           au dit.setPat ientGivenN ame("Test" );
  207           au dit.setPat ientId("12 34567890V1 23456");
  208           au dit.setPat ientLastNa me("Patien t");
  209           au dit.setPat ientSSN("6 66003333") ;
  210           au dit.setPur poseForUse ("TREATMEN T");
  211           au dit.setRem oteOrganiz ationId("u rn:oid:" +  TEST_RECE IVING_HCID );
  212           au dit.setUse rFacilityN ame(null);
  213           au dit.setUse rFacilityN umber("urn :oid:" + T EST_SENDIN G_AA);
  214           au dit.setUse rId("remot eUser");
  215           au dit.setUse rName("Tes t User");
  216           au dit.setUse rRole("123 45");
  217           
  218           Ad apterMVI i nstance =  new Adapte rMVI();
  219           
  220           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  221           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  222           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  223           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  224           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  225           
  226           in stance.set FacilityMa nager(faci lityManage r);
  227           in stance.set DataManage r(dataMana ger);
  228           in stance.set PropertyLo okup(prope rtyLookup) ;
  229           in stance.set AuditManag er(auditMa nager);
  230           
  231           co ntext.chec king(new E xpectation s() {{
  232                oneOf(fa cilityMana ger).getFa cilityByHo meCommunit yId(TEST_S ENDING_HCI D);
  233                will(ret urnValue(s endingFaci lity));
  234                
  235                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  236                will(ret urnValue(f acility));
  237                
  238                oneOf(da taManager) .getQuery( "MPI.findM atch");
  239                will(ret urnValue(d ataQuery)) ;
  240                
  241                oneOf(da taQuery).s etParamete r("sending Facility",  sendingFa cility.get FacilityNu mber());
  242                oneOf(da taQuery).s etParamete r("firstNa me", "Test ");
  243                oneOf(da taQuery).s etParamete r("middleN ame", "Mid dle");
  244                oneOf(da taQuery).s etParamete r("lastNam e", "Patie nt");
  245                oneOf(da taQuery).s etParamete r("gender" , "M");
  246                oneOf(da taQuery).s etParamete r("dob", d ob);
  247                oneOf(da taQuery).s etParamete r("prefix" , null);
  248                oneOf(da taQuery).s etParamete r("suffix" , null);
  249                oneOf(da taQuery).s etParamete r("ssn", " 666003333" );
  250                oneOf(da taQuery).s etParamete r("sourceP atientId",  "12345678 90V123456" );
  251                oneOf(da taQuery).s etParamete r("sourceP atientAssi gningAutho rity", TES T_SENDING_ AA);
  252                oneOf(da taQuery).s etParamete r("sourceP atientAssi gningFacil ity", TEST _SENDING_H CID);
  253                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 1", "1234  Test Lane" );
  254                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 2", null);
  255                oneOf(da taQuery).s etParamete r("homeAdd ressCity",  "New Orle ans");
  256                oneOf(da taQuery).s etParamete r("homeAdd ressState" , "LA");
  257                oneOf(da taQuery).s etParamete r("homeAdd ressPostal ", "70143" );
  258                oneOf(da taQuery).s etParamete r("homePho ne", "1-50 4-529-6111 ");
  259                oneOf(da taQuery).s etParamete r("numReco rds", "1") ;
  260                oneOf(da taQuery).g etResults( );
  261                will(ret urnValue(m piResults) );
  262                
  263                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  264                will(ret urnValue(d ataQuery)) ;
  265                
  266                oneOf(da taQuery).s etParamete r("icn", m piResult.g et("icn")) ;
  267                oneOf(da taQuery).g etResults( );
  268                will(ret urnValue(p atients));
  269                
  270                allowing (propertyL ookup).get Property(" AssigningA uthority") ;
  271                will(ret urnValue(T EST_RECEIV ING_AA));
  272                
  273                oneOf(au ditManager ).storeAud it(audit);
  274           }} );
  275           
  276           PR PAIN201306 UV02 resul t = instan ce.findCan didates(re quest);
  277           as sertTrue(r esult != n ull
  278                       & & result.g etControlA ctProcess( ) != null
  279                       & & NullChec ker.isNotN ullOrEmpty (result.ge tControlAc tProcess() .getSubjec t()));
  280       }
  281       
  282       @Test
  283       public  void test FindCandid atesNoMidd leName()
  284       {
  285           Sy stem.out.p rintln("fi ndCandidat esNoMiddle Name");
  286           Re spondingGa tewayPRPAI N201305UV0 2RequestTy pe request  = new Res pondingGat ewayPRPAIN 201305UV02 RequestTyp e();
  287           
  288           PR PAIN201305 UV02 prpai n201305UV0 2 = create PRPAIN2013 05(
  289                    "Pat ient",
  290                    Arra ys.asList( new String []{"Test"} ),
  291                    null ,
  292                    null ,
  293                    "201 20724",
  294                    "New  Orleans",
  295                    "LA" ,
  296                    Arra ys.asList( new String []{"1234 T est Lane"} ),
  297                    "701 43",
  298                    "tel :+1-504-52 9-6111",
  299                    "M",
  300                    "no" ,
  301                    "M",
  302                    "123 4567890V12 3456",
  303                    TEST _SENDING_H CID,
  304                    TEST _SENDING_A A,
  305                    "666 003333");
  306           re quest.setP RPAIN20130 5UV02(prpa in201305UV 02);
  307           
  308           As sertionTyp e assertio n = new As sertionTyp e();
  309           Ho meCommunit yType home Community  = new Home CommunityT ype();
  310           ho meCommunit y.setHomeC ommunityId ("urn:oid: " + TEST_S ENDING_HCI D);
  311           as sertion.se tHomeCommu nity(homeC ommunity);
  312           Us erType use r = new Us erType();
  313           us er.setUser Name("remo teUser");
  314           Pe rsonNameTy pe personN ame = new  PersonName Type();
  315           pe rsonName.s etFamilyNa me("User") ;
  316           pe rsonName.s etGivenNam e("Test");
  317           us er.setPers onName(per sonName);
  318           us er.setOrg( homeCommun ity);
  319           as sertion.se tUserInfo( user);
  320           Ce Type role  = new CeTy pe();
  321           ro le.setCode ("12345");
  322           us er.setRole Coded(role );
  323           Ce Type pou =  new CeTyp e();
  324           po u.setCode( "TREATMENT ");
  325           as sertion.se tPurposeOf Disclosure Coded(pou) ;
  326           re quest.setA ssertion(a ssertion);
  327           
  328           Si mpleDateFo rmat forma tter = new  SimpleDat eFormat("y yyyMMdd");
  329           fi nal Date d ob;
  330           Da te dobInne r = null;
  331           tr y {
  332                dobInner  = formatt er.parse(" 20120724") ;
  333           }
  334           ca tch (Parse Exception  pe) {
  335                fail("Fa iled to pa rse dob");
  336           }
  337           fi nally {
  338                dob = do bInner;
  339           }
  340           
  341           fi nal Facili ty sending Facility =  new Facil ity();
  342           se ndingFacil ity.setFac ilityNumbe r("200TEST ");
  343           se ndingFacil ity.setHom eCommunity Id(TEST_SE NDING_HCID );
  344           se ndingFacil ity.setFul lHomeCommu nityId("ur n:oid:" +  TEST_SENDI NG_HCID);
  345           
  346           fi nal Facili ty facilit y = new Fa cility();
  347           fa cility.set FacilityNu mber("VA") ;
  348           fa cility.set HomeCommun ityId(TEST _RECEIVING _HCID);
  349           fa cility.set FullHomeCo mmunityId( "urn:oid:"  + TEST_RE CEIVING_HC ID);
  350           
  351           fi nal Map mp iResult =  new HashMa p();
  352           mp iResult.pu t("icn", " 1234567890 V123456");
  353           mp iResult.pu t("ssn", " 666003333" );
  354           mp iResult.pu t("firstNa me", "Test ");
  355           mp iResult.pu t("middleN ame", null );
  356           mp iResult.pu t("lastNam e", "Patie nt");
  357           mp iResult.pu t("gender" , "M");
  358           mp iResult.pu t("dob", d ob);
  359           
  360           fi nal List<M ap> mpiRes ults = new  ArrayList <Map>();
  361           mp iResults.a dd(mpiResu lt);
  362           
  363           fi nal Map de mographics Ext = new  HashMap()  {{
  364                put("hom eAddressSt reet", new  ArrayList () {{
  365                    add( "1234 Test  Lane");
  366                    add( "Apt 37");
  367                }});
  368                put("hom eAddressCi ty", "Test  City");
  369                put("hom eAddressSt ate", "LA" );
  370                put("hom eAddressPo stal", "70 124");
  371                put("pho neHome", " tel:+1-333 -777-8888" );
  372                put("mar italStatus Cod", "S") ;
  373                put("mul tipleBirth Code", "N" );
  374           }} ;
  375  
  376           fi nal Map pa tient = ne w HashMap( ) {{
  377                put("dem ographicsE xt", demog raphicsExt );
  378                put("pat ientPrefer redFacilit yNumber",  "TEST");
  379                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  380           }} ;
  381           
  382           fi nal List<M ap> patien ts = new A rrayList<M ap>();
  383           pa tients.add (patient);
  384           
  385           fi nal Audit  audit = ne w Audit();
  386           au dit.setAct ion("MPI f indMatch") ;
  387           au dit.setDet ails(
  388                "MATCH F OUND ICN=  " + mpiRes ult.get("i cn")
  389                + " Remo te Facilit y=" + TEST _SENDING_H CID
  390                + " ssn= 666003333"
  391                + ", las tName=Pati ent"
  392                + ", mid dleName="
  393                + ", fir stName=Tes t"
  394                + ", add ress[0]=12 34 Test La ne"
  395                + ", cit y=New Orle ans"
  396                + ", sta te=LA"
  397                + ", zip =70143"
  398                + ", pho neNumber=t el:+1-504- 529-6111"
  399                + ", gen der=M"
  400                + ", dob =2012-07-2 4 00:00:00 .0, "
  401           );
  402           au dit.setOrg anizationI d("urn:oid :" + TEST_ SENDING_HC ID);
  403           au dit.setPat ientFacili tyName("Te st Facilit y");
  404           au dit.setPat ientFacili tyNumber(" TEST");
  405           au dit.setPat ientGivenN ame("Test" );
  406           au dit.setPat ientId("12 34567890V1 23456");
  407           au dit.setPat ientLastNa me("Patien t");
  408           au dit.setPat ientSSN("6 66003333") ;
  409           au dit.setPur poseForUse ("TREATMEN T");
  410           au dit.setRem oteOrganiz ationId("u rn:oid:" +  TEST_RECE IVING_HCID );
  411           au dit.setUse rFacilityN ame(null);
  412           au dit.setUse rFacilityN umber("urn :oid:" + T EST_SENDIN G_AA);
  413           au dit.setUse rId("remot eUser");
  414           au dit.setUse rName("Tes t User");
  415           au dit.setUse rRole("123 45");
  416           
  417           Ad apterMVI i nstance =  new Adapte rMVI();
  418           
  419           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  420           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  421           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  422           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  423           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  424           
  425           in stance.set FacilityMa nager(faci lityManage r);
  426           in stance.set DataManage r(dataMana ger);
  427           in stance.set PropertyLo okup(prope rtyLookup) ;
  428           in stance.set AuditManag er(auditMa nager);
  429           
  430           co ntext.chec king(new E xpectation s() {{
  431                oneOf(fa cilityMana ger).getFa cilityByHo meCommunit yId(TEST_S ENDING_HCI D);
  432                will(ret urnValue(s endingFaci lity));
  433                
  434                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  435                will(ret urnValue(f acility));
  436                
  437                oneOf(da taManager) .getQuery( "MPI.findM atch");
  438                will(ret urnValue(d ataQuery)) ;
  439                
  440                oneOf(da taQuery).s etParamete r("sending Facility",  sendingFa cility.get FacilityNu mber());
  441                oneOf(da taQuery).s etParamete r("firstNa me", "Test ");
  442                oneOf(da taQuery).s etParamete r("middleN ame", null );
  443                oneOf(da taQuery).s etParamete r("lastNam e", "Patie nt");
  444                oneOf(da taQuery).s etParamete r("gender" , "M");
  445                oneOf(da taQuery).s etParamete r("dob", d ob);
  446                oneOf(da taQuery).s etParamete r("prefix" , null);
  447                oneOf(da taQuery).s etParamete r("suffix" , null);
  448                oneOf(da taQuery).s etParamete r("ssn", " 666003333" );
  449                oneOf(da taQuery).s etParamete r("sourceP atientId",  "12345678 90V123456" );
  450                oneOf(da taQuery).s etParamete r("sourceP atientAssi gningAutho rity", TES T_SENDING_ AA);
  451                oneOf(da taQuery).s etParamete r("sourceP atientAssi gningFacil ity", TEST _SENDING_H CID);
  452                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 1", "1234  Test Lane" );
  453                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 2", null);
  454                oneOf(da taQuery).s etParamete r("homeAdd ressCity",  "New Orle ans");
  455                oneOf(da taQuery).s etParamete r("homeAdd ressState" , "LA");
  456                oneOf(da taQuery).s etParamete r("homeAdd ressPostal ", "70143" );
  457                oneOf(da taQuery).s etParamete r("homePho ne", "1-50 4-529-6111 ");
  458                oneOf(da taQuery).s etParamete r("numReco rds", "1") ;
  459                oneOf(da taQuery).g etResults( );
  460                will(ret urnValue(m piResults) );
  461                
  462                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  463                will(ret urnValue(d ataQuery)) ;
  464                
  465                oneOf(da taQuery).s etParamete r("icn", m piResult.g et("icn")) ;
  466                oneOf(da taQuery).g etResults( );
  467                will(ret urnValue(p atients));
  468                
  469                allowing (propertyL ookup).get Property(" AssigningA uthority") ;
  470                will(ret urnValue(T EST_RECEIV ING_AA));
  471                
  472                oneOf(au ditManager ).storeAud it(audit);
  473           }} );
  474           
  475           PR PAIN201306 UV02 resul t = instan ce.findCan didates(re quest);
  476           as sertTrue(r esult != n ull
  477                       & & result.g etControlA ctProcess( ) != null
  478                       & & NullChec ker.isNotN ullOrEmpty (result.ge tControlAc tProcess() .getSubjec t()));
  479       }
  480  
  481       @Test
  482       public  void test FindCandid atesMatchF ailed()
  483       {
  484           Sy stem.out.p rintln("fi ndCandidat esMatchFai led");
  485           Re spondingGa tewayPRPAI N201305UV0 2RequestTy pe request  = new Res pondingGat ewayPRPAIN 201305UV02 RequestTyp e();
  486           
  487           PR PAIN201305 UV02 prpai n201305UV0 2 = create PRPAIN2013 05(
  488                    "Pat ient",
  489                    Arra ys.asList( new String []{"Test",  "Middle"} ),
  490                    null ,
  491                    null ,
  492                    "201 20724",
  493                    "New  Orleans",
  494                    "LA" ,
  495                    Arra ys.asList( new String []{"1234 T est Lane"} ),
  496                    "701 43",
  497                    "tel :+1-504-52 9-6111",
  498                    "M",
  499                    "no" ,
  500                    "M",
  501                    "123 4567890V12 3456",
  502                    TEST _SENDING_H CID,
  503                    TEST _SENDING_A A,
  504                    "666 003333");
  505           re quest.setP RPAIN20130 5UV02(prpa in201305UV 02);
  506           
  507           As sertionTyp e assertio n = new As sertionTyp e();
  508           Ho meCommunit yType home Community  = new Home CommunityT ype();
  509           ho meCommunit y.setHomeC ommunityId ("urn:oid: " + TEST_S ENDING_HCI D);
  510           as sertion.se tHomeCommu nity(homeC ommunity);
  511           Us erType use r = new Us erType();
  512           us er.setUser Name("remo teUser");
  513           Pe rsonNameTy pe personN ame = new  PersonName Type();
  514           pe rsonName.s etFamilyNa me("User") ;
  515           pe rsonName.s etGivenNam e("Test");
  516           us er.setPers onName(per sonName);
  517           us er.setOrg( homeCommun ity);
  518           as sertion.se tUserInfo( user);
  519           Ce Type role  = new CeTy pe();
  520           ro le.setCode ("12345");
  521           us er.setRole Coded(role );
  522           Ce Type pou =  new CeTyp e();
  523           po u.setCode( "TREATMENT ");
  524           as sertion.se tPurposeOf Disclosure Coded(pou) ;
  525           re quest.setA ssertion(a ssertion);
  526           
  527           Si mpleDateFo rmat forma tter = new  SimpleDat eFormat("y yyyMMdd");
  528           fi nal Date d ob;
  529           Da te dobInne r = null;
  530           tr y {
  531                dobInner  = formatt er.parse(" 20120724") ;
  532           }
  533           ca tch (Parse Exception  pe) {
  534                fail("Fa iled to pa rse dob");
  535           }
  536           fi nally {
  537                dob = do bInner;
  538           }
  539           
  540           fi nal Facili ty sending Facility =  new Facil ity();
  541           se ndingFacil ity.setFac ilityNumbe r("200TEST ");
  542           se ndingFacil ity.setHom eCommunity Id(TEST_SE NDING_HCID );
  543           se ndingFacil ity.setFul lHomeCommu nityId("ur n:oid:" +  TEST_SENDI NG_HCID);
  544           
  545           fi nal Facili ty facilit y = new Fa cility();
  546           fa cility.set FacilityNu mber("VA") ;
  547           fa cility.set HomeCommun ityId(TEST _RECEIVING _HCID);
  548           fa cility.set FullHomeCo mmunityId( "urn:oid:"  + TEST_RE CEIVING_HC ID);
  549           
  550           fi nal List<M ap> mpiRes ults = new  ArrayList <Map>();
  551           
  552           fi nal Audit  audit = ne w Audit();
  553           au dit.setAct ion("MPI f indMatch") ;
  554           au dit.setDet ails(
  555                "MATCH F AILED"
  556                + " Remo te Facilit y=" + TEST _SENDING_H CID
  557                + " ssn= 666003333"
  558                + ", las tName=Pati ent"
  559                + ", mid dleName=Mi ddle"
  560                + ", fir stName=Tes t"
  561                + ", add ress[0]=12 34 Test La ne"
  562                + ", cit y=New Orle ans"
  563                + ", sta te=LA"
  564                + ", zip =70143"
  565                + ", pho neNumber=t el:+1-504- 529-6111"
  566                + ", gen der=M"
  567                + ", dob =2012-07-2 4 00:00:00 .0, "
  568           );
  569           au dit.setOrg anizationI d("urn:oid :" + TEST_ SENDING_HC ID);
  570           au dit.setPur poseForUse ("TREATMEN T");
  571           au dit.setRem oteOrganiz ationId("u rn:oid:" +  TEST_RECE IVING_HCID );
  572           au dit.setUse rFacilityN ame(null);
  573           au dit.setUse rFacilityN umber("urn :oid:" + T EST_SENDIN G_AA);
  574           au dit.setUse rId("remot eUser");
  575           au dit.setUse rName("Tes t User");
  576           au dit.setUse rRole("123 45");
  577           
  578           Ad apterMVI i nstance =  new Adapte rMVI();
  579           
  580           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  581           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  582           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  583           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  584           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  585           
  586           in stance.set FacilityMa nager(faci lityManage r);
  587           in stance.set DataManage r(dataMana ger);
  588           in stance.set PropertyLo okup(prope rtyLookup) ;
  589           in stance.set AuditManag er(auditMa nager);
  590           
  591           co ntext.chec king(new E xpectation s() {{
  592                oneOf(fa cilityMana ger).getFa cilityByHo meCommunit yId(TEST_S ENDING_HCI D);
  593                will(ret urnValue(s endingFaci lity));
  594                
  595                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  596                will(ret urnValue(f acility));
  597                
  598                oneOf(da taManager) .getQuery( "MPI.findM atch");
  599                will(ret urnValue(d ataQuery)) ;
  600                
  601                oneOf(da taQuery).s etParamete r("sending Facility",  sendingFa cility.get FacilityNu mber());
  602                oneOf(da taQuery).s etParamete r("firstNa me", "Test ");
  603                oneOf(da taQuery).s etParamete r("middleN ame", "Mid dle");
  604                oneOf(da taQuery).s etParamete r("lastNam e", "Patie nt");
  605                oneOf(da taQuery).s etParamete r("gender" , "M");
  606                oneOf(da taQuery).s etParamete r("dob", d ob);
  607                oneOf(da taQuery).s etParamete r("prefix" , null);
  608                oneOf(da taQuery).s etParamete r("suffix" , null);
  609                oneOf(da taQuery).s etParamete r("ssn", " 666003333" );
  610                oneOf(da taQuery).s etParamete r("sourceP atientId",  "12345678 90V123456" );
  611                oneOf(da taQuery).s etParamete r("sourceP atientAssi gningAutho rity", TES T_SENDING_ AA);
  612                oneOf(da taQuery).s etParamete r("sourceP atientAssi gningFacil ity", TEST _SENDING_H CID);
  613                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 1", "1234  Test Lane" );
  614                oneOf(da taQuery).s etParamete r("homeAdd ressStreet 2", null);
  615                oneOf(da taQuery).s etParamete r("homeAdd ressCity",  "New Orle ans");
  616                oneOf(da taQuery).s etParamete r("homeAdd ressState" , "LA");
  617                oneOf(da taQuery).s etParamete r("homeAdd ressPostal ", "70143" );
  618                oneOf(da taQuery).s etParamete r("homePho ne", "1-50 4-529-6111 ");
  619                oneOf(da taQuery).s etParamete r("numReco rds", "1") ;
  620                oneOf(da taQuery).g etResults( );
  621                will(ret urnValue(m piResults) );
  622                
  623                never(da taManager) .getQuery( "Composite .findDemog raphics");
  624                
  625                allowing (propertyL ookup).get Property(" AssigningA uthority") ;
  626                will(ret urnValue(T EST_RECEIV ING_AA));
  627                
  628                oneOf(au ditManager ).storeAud it(audit);
  629           }} );
  630           
  631           PR PAIN201306 UV02 resul t = instan ce.findCan didates(re quest);
  632           as sertTrue(r esult != n ull
  633                       & & result.g etControlA ctProcess( ) != null
  634                       & & NullChec ker.isNull OrEmpty(re sult.getCo ntrolActPr ocess().ge tSubject() ));
  635       }
  636       
  637       privat e PRPAIN20 1305UV02 c reatePRPAI N201305(St ring lastN ame,
  638                                                       Li st<String>  givenName ,
  639                                                       St ring prefi x,
  640                                                       St ring suffi x,
  641                                                       St ring dob,
  642                                                       St ring city,
  643                                                       St ring state ,
  644                                                       Li st<String>  address,
  645                                                       St ring zip,
  646                                                       St ring phone ,
  647                                                       St ring gende r,
  648                                                       St ring multi Birth,
  649                                                       St ring marit alStatus,
  650                                                       St ring patie ntId,
  651                                                       St ring homeC ommunityId ,
  652                                                       St ring assig ningAuthor ity,
  653                                                       St ring ssn)
  654       {
  655           JA XBElement< PRPAMT2013 01UV02Pers on> patien tPerson =
  656                    buil dPRPAIN201 301Patient Person(las tName,
  657                                                      giv enName,
  658                                                      pre fix,
  659                                                      suf fix,
  660                                                      dob ,
  661                                                      cit y,
  662                                                      sta te,
  663                                                      add ress,
  664                                                      zip ,
  665                                                      pho ne,
  666                                                      gen der,
  667                                                      mul tiBirth,
  668                                                      mar italStatus );
  669  
  670           II  ii = new  II();
  671           ii .setRoot(a ssigningAu thority);
  672           ii .setExtens ion(patien tId);
  673           St ring assig ningAuthor ityName =  TEST_AA_NA ME;
  674           if  (!NullChe cker.isNul lOrEmpty(a ssigningAu thorityNam e)) {
  675                ii.setAs signingAut horityName (assigning AuthorityN ame);
  676           }
  677  
  678           PR PAMT201301 UV02Patien t patient  =
  679                    HL7P atientTran sforms.cre ate201301P atient(pat ientPerson , ii);
  680  
  681           PR PAIN201305 UV02 ret =
  682                    HL7P RPA201305T ransforms. createPRPA 201305(pat ient, home CommunityI d, "1.1",  assigningA uthority);
  683  
  684           //  add ssn.
  685           PR PAMT201306 UV02Parame terList pa ramList =  ret.getCon trolActPro cess().get QueryByPar ameter().g etValue(). getParamet erList();
  686           PR PAMT201306 UV02Living SubjectId  ssnId = ne w PRPAMT20 1306UV02Li vingSubjec tId();
  687           ii  = new II( );
  688           ii .setRoot(" 2.16.840.1 .113883.4. 1");
  689           ii .setExtens ion(ssn);
  690           ss nId.getVal ue().add(i i);
  691           ST  text = ne w ST();
  692           ss nId.setSem anticsText (text);
  693           pa ramList.ge tLivingSub jectId().a dd(ssnId);
  694  
  695           //  fix the i nteraction  id.
  696           re t.setInter actionId(H L7DataTran sformHelpe r.IIFactor y(HL7Const ants.INTER ACTION_ID_ ROOT, "PRP A_IN201305 UV02"));
  697  
  698           //  fix the c ontrolActP roccess/co de.
  699           re t.getContr olActProce ss().setCo de(HL7Data TransformH elper.CDFa ctory("PRP A_TE201305 UV02", HL7 Constants. INTERACTIO N_ID_ROOT) );
  700  
  701           //  fix the a cceptAckCo de.
  702           re t.setAccep tAckCode(H L7DataTran sformHelpe r.CSFactor y("NE"));
  703           
  704           //  fix the p rocessingM odeCode.
  705           re t.setProce ssingModeC ode(HL7Dat aTransform Helper.CSF actory("T" ));
  706           
  707           re t.getContr olActProce ss().setCl assCode(Ac tClassCont rolAct.CAC T);
  708           re t.getContr olActProce ss().getAu thorOrPerf ormer().ge t(0).getAs signedDevi ce().getVa lue().setC lassCode(" ASSIGNED") ;
  709           
  710           //  fix the c reation ti me of the  message.
  711           TS Explicit t e = new TS Explicit() ;
  712           Da te now = n ew Date();
  713           Si mpleDateFo rmat forma tter = new  SimpleDat eFormat("y yyyMMddHHm mss");
  714           fo rmatter.se tTimeZone( TimeZone.g etTimeZone ("UTC"));
  715           te .setValue( formatter. format(now ));
  716           re t.setCreat ionTime(te );
  717  
  718           CS  responseM odalityCod e = new CS ();
  719           re sponseModa lityCode.s etCode("R" );
  720           re t.getContr olActProce ss().getQu eryByParam eter().get Value().se tResponseM odalityCod e(response ModalityCo de);
  721           
  722           CS  responseP riorityCod e = new CS ();
  723           re sponsePrio rityCode.s etCode("I" );
  724           re t.getContr olActProce ss().getQu eryByParam eter().get Value().se tResponseP riorityCod e(response PriorityCo de);
  725                    
  726           re turn ret;
  727       }
  728  
  729       privat e JAXBElem ent<PRPAMT 201301UV02 Person> bu ildPRPAIN2 01301Patie ntPerson(S tring last Name,
  730                                                                                         L ist<String > givenNam e,
  731                                                                                         S tring pref ix,
  732                                                                                         S tring suff ix,
  733                                                                                         S tring dob,
  734                                                                                         S tring city ,
  735                                                                                         S tring stat e,
  736                                                                                         L ist<String > address,
  737                                                                                         S tring zip,
  738                                                                                         S tring phon e,
  739                                                                                         S tring gend er,
  740                                                                                         S tring mult iBirth,
  741                                                                                         S tring mari talStatus)
  742       {
  743           PR PAMT201301 UV02Person  patientPe rson = new  PRPAMT201 301UV02Per son();
  744  
  745           // ---------- ---------- ---------- ---------- ---------- ---------- --
  746           // build name
  747           or g.hl7.v3.O bjectFacto ry factory  = new org .hl7.v3.Ob jectFactor y();
  748           PN Explicit n ame = (PNE xplicit) ( factory.cr eatePNExpl icit());
  749           Li st namelis t = name.g etContent( );
  750  
  751           // Last name
  752           En ExplicitFa mily famil yName = ne w EnExplic itFamily() ;
  753           fa milyName.s etPartType ("FAM");
  754           fa milyName.s etContent( lastName);
  755           na melist.add (factory.c reatePNExp licitFamil y(familyNa me));
  756  
  757           // First name
  758           if  (NullChec ker.isNotN ullOrEmpty (givenName )) {
  759                for (Str ing n : gi venName) {
  760                    if ( !NullCheck er.isNullO rEmpty(n))  {
  761                         EnExplicit Given gn =  new EnExp licitGiven ();
  762                         gn.setPart Type("GIV" );
  763                         gn.setCont ent(n);
  764                         namelist.a dd(factory .createPNE xplicitGiv en(gn));
  765  
  766                    }
  767                }
  768           }
  769  
  770           En ExplicitPr efix pfx =  new EnExp licitPrefi x();
  771           pf x.setConte nt(prefix) ;
  772           pf x.setPartT ype("PFX") ;
  773           na melist.add (factory.c reateENExp licitPrefi x(pfx));
  774  
  775           En ExplicitSu ffix sfx =  new EnExp licitSuffi x();
  776           sf x.setConte nt(suffix) ;
  777           sf x.setPartT ype("SFX") ;
  778           na melist.add (factory.c reateENExp licitSuffi x(sfx));
  779  
  780           pa tientPerso n.getName( ).add(name );
  781           // ---------- ---------- ---------- ---------- ---------- ----------
  782  
  783  
  784           // Date of Bi rth
  785           TS Explicit v alueTSExpl icit = new  TSExplici t();
  786           va lueTSExpli cit.setVal ue(dob);
  787           pa tientPerso n.setBirth Time(value TSExplicit );
  788  
  789  
  790           // Gender
  791           CE  valueCE =  new CE();
  792           va lueCE.setC ode(gender );
  793           pa tientPerso n.setAdmin istrativeG enderCode( valueCE);
  794  
  795           // ---------- ---------- ---------- ---------- ---------- ---------- -
  796           //   build ad dress
  797           AD Explicit a ddr = (ADE xplicit) ( factory.cr eateADExpl icit());
  798           Li st addrlis t = addr.g etContent( );
  799  
  800           // address
  801           Ad xpExplicit City value City = new  AdxpExpli citCity();
  802           va lueCity.se tContent(c ity);
  803           ad drlist.add (factory.c reateADExp licitCity( valueCity) );
  804  
  805           Ad xpExplicit State valu eState = n ew AdxpExp licitState ();
  806           va lueState.s etContent( state);
  807           ad drlist.add (factory.c reateADExp licitState (valueStat e));
  808  
  809           if  (NullChec ker.isNotN ullOrEmpty (address))  {
  810                for (Str ing a : ad dress) {
  811                    if ( !NullCheck er.isNullO rEmpty(a))  {
  812                         AdxpExplic itStreetAd dressLine  line = new  AdxpExpli citStreetA ddressLine ();
  813                         line.setCo ntent(a);
  814                         addrlist.a dd(factory .createADE xplicitStr eetAddress Line(line) );
  815                    }
  816                }
  817           }
  818           
  819           Ad xpExplicit PostalCode  valueZip  = new Adxp ExplicitPo stalCode() ;
  820           va lueZip.set Content(zi p);
  821           ad drlist.add (factory.c reateADExp licitPosta lCode(valu eZip));
  822  
  823  
  824           pa tientPerso n.getAddr( ).add(addr );
  825           // ---------- ---------- ---------- ---------- ---------- ---------- --
  826  
  827  
  828           // telephone
  829           TE LExplicit  valueTELE  = new TELE xplicit();
  830           va lueTELE.se tValue(pho ne);
  831           pa tientPerso n.getTelec om().add(v alueTELE);
  832  
  833           // multi birt h
  834           BL  valueBL =  new BL();
  835           if  (multiBir th == null  || multiB irth.lengt h() == 0 | | multiBir th.startsW ith("NO")  || multiBi rth.starts With("no") ) {
  836                valueBL. setValue(f alse);
  837           }
  838           el se {
  839                valueBL. setValue(t rue);
  840           }
  841           pa tientPerso n.setMulti pleBirthIn d(valueBL) ;  //BL va lue
  842  
  843           //  marital s tatus
  844           CE  maritalSt atusCode =  new CE();
  845           ma ritalStatu sCode.setC ode(marita lStatus);
  846           pa tientPerso n.setMarit alStatusCo de(marital StatusCode );
  847  
  848           re turn facto ry.createP RPAMT20130 1UV02Patie ntPatientP erson(pati entPerson) ;
  849       }
  850   }