230. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:45: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.

230.1 Files compared

# Location File Last Modified
1 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\eHXE_Build3_2017-05-04.zip\NHIN_adapter\AdapterEJB\src\test\java\gov\va\med\nhin\adapter\adaptergateway\patientannounce AnnouncePatientTest.java Wed Apr 5 01:13:54 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\eHXE_Build3_2017-05-04.zip\NHIN_adapter\AdapterEJB\src\test\java\gov\va\med\nhin\adapter\adaptergateway\patientannounce AnnouncePatientTest.java Thu Jun 1 21:39:46 2017 UTC

230.2 Comparison summary

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

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

230.4 Active regular expressions

No regular expressions were active.

230.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.adapterg ateway.pat ientannoun ce;
  6  
  7   import jav a.util.*;
  8  
  9   import org .junit.*;
  10   import org .junit.run ner.*;
  11   import sta tic org.ju nit.Assert .*;
  12  
  13   import gov .hhs.fha.n hinc.entit ypatientdi scovery.*;
  14   import gov .va.med.nh in.adapter .adapterga teway.pati entdiscove ry.EntityP atientDisc overyPortT ypeLocal;
  15   import org .jmock.*;
  16   import org .jmock.int egration.j unit4.*;
  17   import org .hl7.v3.*;
  18  
  19   import gov .va.med.nh in.adapter .announcep atient.*;
  20   import gov .va.med.nh in.adapter .audit.*;
  21   import gov .va.med.nh in.adapter .datamanag er.*;
  22   import gov .va.med.nh in.adapter .facilitym anager.*;
  23   import gov .va.med.nh in.adapter .permissio n.*;
  24   import gov .va.med.nh in.adapter .propertyl ookup.*;
  25  
  26  
  27   /**
  28    *
  29    * @author  
D NS    
  30    */
  31   @RunWith(J Mock.class )
  32   public cla ss Announc ePatientTe st
  33   {
  34       privat e Mockery  context =  new JUnit4 Mockery();
  35       
  36       public  AnnounceP atientTest ()
  37       {
  38       }
  39  
  40       /**
  41        * Tes t of annou ncePatient  method, o f class An nouncePati ent.
  42        */
  43       @Test
  44       public  void test AnnouncePa tientNullR equest()
  45       {
  46           Sy stem.out.p rintln("an nouncePati entNullReq uest");
  47           An nouncePati entType bo dy = null;
  48           An nouncePati ent instan ce = new A nnouncePat ient();
  49           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  50           ex pResult.se tReturn(-1 );
  51           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  52           as sertEquals (expResult .getReturn (), result .getReturn ());
  53       }
  54       
  55       @Test
  56       public  void test AnnouncePa tientNoPat ientId()
  57       {
  58           Sy stem.out.p rintln("an nouncePati entNoPatie ntId");
  59           An nouncePati entType bo dy = new A nnouncePat ientType() ;
  60           An nouncePati ent instan ce = new A nnouncePat ient();
  61           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  62           ex pResult.se tReturn(-1 );
  63           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  64           as sertEquals (expResult .getReturn (), result .getReturn ());
  65       }
  66       
  67       @Test
  68       public  void test AnnouncePa tientInval idPatientI d()
  69       {
  70           Sy stem.out.p rintln("an nouncePati entInvalid PatientId" );
  71           
  72           fi nal String  patientId  = "1234";
  73           An nouncePati entType bo dy = new A nnouncePat ientType() ;
  74           bo dy.setPati entId(pati entId);
  75           
  76           An nouncePati ent instan ce = new A nnouncePat ient();
  77           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  78           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  79  
  80           in stance.set DataManage r(dataMana ger);
  81           
  82           co ntext.chec king(new E xpectation s() {
  83           {
  84                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  85                will(ret urnValue(d ataQuery)) ;
  86                oneOf(da taQuery).s etParamete r("icn", p atientId);
  87                oneOf(da taQuery).g etResults( );
  88                will(ret urnValue(n ew ArrayLi st()));
  89           }} );
  90           
  91           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  92           ex pResult.se tReturn(0) ;
  93           
  94           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  95           as sertEquals (expResult .getReturn (), result .getReturn ());
  96       }
  97       
  98       @Test
  99       public  void test AnnouncePa tientPatie ntNotFound ()
  100       {
  101           Sy stem.out.p rintln("te stAnnounce PatientPat ientNotFou nd");
  102           
  103           fi nal String  patientId  = "123456 789V123456 ";
  104           An nouncePati entType bo dy = new A nnouncePat ientType() ;
  105           bo dy.setPati entId(pati entId);
  106           
  107           An nouncePati ent instan ce = new A nnouncePat ient();
  108           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  109           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  110  
  111           in stance.set DataManage r(dataMana ger);
  112  
  113           co ntext.chec king(new E xpectation s() {
  114           {
  115                List pat ients = ne w ArrayLis t();
  116                
  117                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  118                will(ret urnValue(d ataQuery)) ;
  119                oneOf(da taQuery).s etParamete r("icn", p atientId);
  120                oneOf(da taQuery).g etResults( );
  121                will(ret urnValue(p atients));
  122           }} );
  123           
  124           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  125           ex pResult.se tReturn(0) ;
  126           
  127           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  128           as sertEquals (expResult .getReturn (), result .getReturn ());
  129       }
  130       
  131       @Test
  132       public  void test AnnouncePa tientNotEn oughInfo()
  133       {
  134           Sy stem.out.p rintln("te stAnnounce PatientNot EnoughInfo ");
  135           
  136           fi nal String  patientId  = "123456 789V123456 ";
  137           An nouncePati entType bo dy = new A nnouncePat ientType() ;
  138           bo dy.setPati entId(pati entId);
  139           
  140           An nouncePati ent instan ce = new A nnouncePat ient();
  141           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  142           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  143           
  144           in stance.set DataManage r(dataMana ger);
  145           
  146           co ntext.chec king(new E xpectation s() {
  147           {
  148                Map pati ent = new  HashMap();
  149                List pat ients = ne w ArrayLis t<Map>();
  150                patients .add(patie nt);
  151                
  152                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  153                will(ret urnValue(d ataQuery)) ;
  154                oneOf(da taQuery).s etParamete r("icn", p atientId);
  155                oneOf(da taQuery).g etResults( );
  156                will(ret urnValue(p atients));
  157           }} );
  158           
  159           
  160           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  161           ex pResult.se tReturn(0) ;
  162           
  163           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  164           as sertEquals (expResult .getReturn (), result .getReturn ());
  165       }
  166       
  167       @Test
  168       public  void test AnnouncePa tient()
  169       {
  170           Sy stem.out.p rintln("te stAnnounce Patient");
  171           
  172           fi nal String  patientId  = "123456 7890V12345 6";
  173           
  174           fi nal Map de mographics  = new Has hMap() {{
  175                put("nam eGiven", n ew ArrayLi st() {{
  176                    add( "First");
  177                    add( "Middle");
  178                }});
  179                put("nam ePrefix",  "Prefix");
  180                put("nam eSuffix",  "Suffix");
  181                put("nam eFamily",  "Family");
  182                put("gen derCode",  "gender");
  183                put("bir thDate", " 20121022") ;
  184                put("SSN ", "666668 888");
  185                put("MRN ", "123456 7890V12345 6");
  186           }} ;
  187  
  188           fi nal Map de mographics Ext = new  HashMap()  {{
  189                put("hom eAddressSt reet", new  ArrayList () {{
  190                    add( "1234 Test  Lane");
  191                    add( "Apt 37");
  192                }});
  193                put("hom eAddressCi ty", "Test  City");
  194                put("hom eAddressSt ate", "LA" );
  195                put("hom eAddressPo stal", "70 124");
  196                put("pho neHome", " tel:+1-333 -777-8888" );
  197                put("mar italStatus Cod", "S") ;
  198                put("mul tipleBirth Code", "N" );
  199           }} ;
  200  
  201           fi nal Map pa tient = ne w HashMap( ) {{
  202                put("dem ographics" , demograp hics);
  203                put("dem ographicsE xt", demog raphicsExt );
  204                put("pat ientPrefer redFacilit yNumber",  "TEST");
  205                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  206           }} ;
  207  
  208           fi nal List p atients =  new ArrayL ist() {{
  209                add(pati ent);
  210           }} ;
  211  
  212           fi nal Announ cePatientT ype body =  new Annou ncePatient Type();
  213           bo dy.setPati entId(pati entId);
  214           Us erInfoType  userInfo  = new User InfoType() ;
  215           us erInfo.set FullName(" Test User" );
  216           us erInfo.set UserId("vh aisbtest") ;
  217           us erInfo.set Authentica tionMethod ("password ");
  218           us erInfo.set Role("test Role");
  219           bo dy.setUser Info(userI nfo);
  220  
  221           fi nal Facili ty facilit y = new Fa cility();
  222           fa cility.set FacilityNu mber("TEST ");
  223           fa cility.set FacilityNa me("Test F acility");
  224           fa cility.set HomeCommun ityId("1.2 .3.4.5");
  225           fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ;
  226           
  227           fi nal Audit  expAudit =  new Audit ();
  228           ex pAudit.set Action("An nounce");
  229           ex pAudit.set Details(
  230                "ssn=" +  demograph ics.get("S SN")
  231                + ", las tName=" +  demographi cs.get("na meFamily")
  232                + ", mid dleName="  + ((List)d emographic s.get("nam eGiven")). get(1)
  233                + ", giv enName=" +  ((List)de mographics .get("name Given")).g et(0)
  234                + ", pre fix=" + de mographics .get("name Prefix")
  235                + ", suf fix=" + de mographics .get("name Suffix")
  236                + ", dob =" + demog raphics.ge t("birthDa te")
  237                + ", add ress[0]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0)
  238                + ", add ress[1]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1)
  239                + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty")
  240                + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate")
  241                + ", zip =" + demog raphicsExt .get("home AddressPos tal")
  242                + ", pho ne=" + dem ographicsE xt.get("ph oneHome")
  243                + ", gen der=" + de mographics .get("gend erCode")
  244                + ", mul tiBirth="  + demograp hicsExt.ge t("multipl eBirthCode ")
  245                + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode")
  246                + ", pat ientId=" +  demograph ics.get("M RN")
  247                + ", hom eCommunity Id=1.2.3.4 .5"
  248           );
  249           ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5");
  250           ex pAudit.set PatientFac ilityName( "Test Faci lity");
  251           ex pAudit.set PatientFac ilityNumbe r("TEST");
  252           ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ;
  253           ex pAudit.set PatientId( (String)de mographics .get("MRN" ));
  254           ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly"));
  255           ex pAudit.set PatientSSN ((String)d emographic s.get("SSN "));
  256           ex pAudit.set PurposeFor Use("TREAT MENT");
  257           ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e());
  258           ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ());
  259           ex pAudit.set UserId(bod y.getUserI nfo().getU serId() +  ", CN=" +  body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() );
  260           ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( ));
  261           ex pAudit.set UserRole(" 224608005" );
  262  
  263           fi nal List<M ap> roles  = new Arra yList<Map> ();
  264           Ma p role = n ew HashMap ();
  265           ro le.put("na me", "ROLE ");
  266           ro les.add(ro le);
  267  
  268           fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType  response =  new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType ();
  269           re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType());
  270           
  271           An nouncePati ent instan ce = new A nnouncePat ient();
  272           
  273           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  274           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  275           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  276           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  277           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  278           fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery =  context.mo ck(EntityP atientDisc overyPortT ype.class) ;
  279           
  280           in stance.set DataManage r(dataMana ger);
  281           in stance.set PropertyLo okup(prope rtyLookup) ;
  282           in stance.set AuditManag er(auditMa nager);
  283           in stance.set FacilityMa nager(faci lityManage r);
  284           in stance.set EntityPati entDiscove ry((Entity PatientDis coveryPort TypeLocal)  entityPat ientDiscov ery);
  285           
  286           co ntext.chec king(new E xpectation s() {
  287           {
  288                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  289                will(ret urnValue(d ataQuery)) ;
  290                oneOf(da taQuery).s etParamete r("icn", p atientId);
  291                oneOf(da taQuery).g etResults( );
  292                will(ret urnValue(p atients));
  293                
  294                oneOf(da taManager) .getQuery( "STS.looku pSNOMED");
  295                will(ret urnValue(d ataQuery)) ;
  296                oneOf(da taQuery).s etParamete r("code",  "224608005 ");
  297                oneOf(da taQuery).g etResults( );
  298                will(ret urnValue(r oles));
  299                
  300                oneOf(au ditManager ).storeAud it(with(eq ual(expAud it)));
  301                
  302                oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class)));
  303                will(ret urnValue(r esponse));
  304  
  305                allowing (propertyL ookup).get Property(w ith(any(St ring.class )));
  306                will(ret urnValue(" property") );
  307                
  308                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  309                will(ret urnValue(f acility));
  310           }} );
  311           
  312           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  313           ex pResult.se tReturn(1) ;
  314           
  315           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  316           as sertEquals (expResult .getReturn (), result .getReturn ());
  317       }
  318       
  319       @Test
  320       public  void test AnnouncePa tientNoMid dleName()
  321       {
  322           Sy stem.out.p rintln("te stAnnounce PatientNoM iddleName" );
  323           
  324           fi nal String  patientId  = "123456 7890V12345 6";
  325           
  326           fi nal Map de mographics  = new Has hMap() {{
  327                put("nam eGiven", n ew ArrayLi st() {{
  328                    add( "First");
  329                }});
  330                put("nam ePrefix",  "Prefix");
  331                put("nam eSuffix",  "Suffix");
  332                put("nam eFamily",  "Family");
  333                put("gen derCode",  "gender");
  334                put("bir thDate", " 20121022") ;
  335                put("SSN ", "666668 888");
  336                put("MRN ", "123456 7890V12345 6");
  337           }} ;
  338  
  339           fi nal Map de mographics Ext = new  HashMap()  {{
  340                put("hom eAddressSt reet", new  ArrayList () {{
  341                    add( "1234 Test  Lane");
  342                    add( "Apt 37");
  343                }});
  344                put("hom eAddressCi ty", "Test  City");
  345                put("hom eAddressSt ate", "LA" );
  346                put("hom eAddressPo stal", "70 124");
  347                put("pho neHome", " tel:+1-333 -777-8888" );
  348                put("mar italStatus Cod", "S") ;
  349                put("mul tipleBirth Code", "N" );
  350           }} ;
  351  
  352           fi nal Map pa tient = ne w HashMap( ) {{
  353                put("dem ographics" , demograp hics);
  354                put("dem ographicsE xt", demog raphicsExt );
  355                put("pat ientPrefer redFacilit yNumber",  "TEST");
  356                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  357           }} ;
  358  
  359           fi nal List p atients =  new ArrayL ist() {{
  360                add(pati ent);
  361           }} ;
  362  
  363           fi nal Announ cePatientT ype body =  new Annou ncePatient Type();
  364           bo dy.setPati entId(pati entId);
  365           Us erInfoType  userInfo  = new User InfoType() ;
  366           us erInfo.set FullName(" Test User" );
  367           us erInfo.set UserId("vh aisbtest") ;
  368           us erInfo.set Authentica tionMethod ("password ");
  369           us erInfo.set Role("test Role");
  370           bo dy.setUser Info(userI nfo);
  371  
  372           fi nal Facili ty facilit y = new Fa cility();
  373           fa cility.set FacilityNu mber("TEST ");
  374           fa cility.set FacilityNa me("Test F acility");
  375           fa cility.set HomeCommun ityId("1.2 .3.4.5");
  376           fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ;
  377           
  378           fi nal Audit  expAudit =  new Audit ();
  379           ex pAudit.set Action("An nounce");
  380           ex pAudit.set Details(
  381                "ssn=" +  demograph ics.get("S SN")
  382                + ", las tName=" +  demographi cs.get("na meFamily")
  383                + ", mid dleName="
  384                + ", giv enName=" +  ((List)de mographics .get("name Given")).g et(0)
  385                + ", pre fix=" + de mographics .get("name Prefix")
  386                + ", suf fix=" + de mographics .get("name Suffix")
  387                + ", dob =" + demog raphics.ge t("birthDa te")
  388                + ", add ress[0]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0)
  389                + ", add ress[1]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1)
  390                + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty")
  391                + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate")
  392                + ", zip =" + demog raphicsExt .get("home AddressPos tal")
  393                + ", pho ne=" + dem ographicsE xt.get("ph oneHome")
  394                + ", gen der=" + de mographics .get("gend erCode")
  395                + ", mul tiBirth="  + demograp hicsExt.ge t("multipl eBirthCode ")
  396                + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode")
  397                + ", pat ientId=" +  demograph ics.get("M RN")
  398                + ", hom eCommunity Id=1.2.3.4 .5"
  399           );
  400           ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5");
  401           ex pAudit.set PatientFac ilityName( "Test Faci lity");
  402           ex pAudit.set PatientFac ilityNumbe r("TEST");
  403           ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ;
  404           ex pAudit.set PatientId( (String)de mographics .get("MRN" ));
  405           ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly"));
  406           ex pAudit.set PatientSSN ((String)d emographic s.get("SSN "));
  407           ex pAudit.set PurposeFor Use("TREAT MENT");
  408           ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e());
  409           ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ());
  410           ex pAudit.set UserId(bod y.getUserI nfo().getU serId() +  ", CN=" +  body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() );
  411           ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( ));
  412           ex pAudit.set UserRole(" 224608005" );
  413  
  414           fi nal List<M ap> roles  = new Arra yList<Map> ();
  415           Ma p role = n ew HashMap ();
  416           ro le.put("na me", "ROLE ");
  417           ro les.add(ro le);
  418  
  419           fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType  response =  new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType ();
  420           re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType());
  421           
  422           An nouncePati ent instan ce = new A nnouncePat ient();
  423           
  424           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  425           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  426           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  427           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  428           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  429           fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery =  context.mo ck(EntityP atientDisc overyPortT ype.class) ;
  430           
  431           in stance.set DataManage r(dataMana ger);
  432           in stance.set PropertyLo okup(prope rtyLookup) ;
  433           in stance.set AuditManag er(auditMa nager);
  434           in stance.set FacilityMa nager(faci lityManage r);
  435           in stance.set EntityPati entDiscove ry((Entity PatientDis coveryPort TypeLocal)  entityPat ientDiscov ery);
  436           
  437           co ntext.chec king(new E xpectation s() {
  438           {
  439                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  440                will(ret urnValue(d ataQuery)) ;
  441                oneOf(da taQuery).s etParamete r("icn", p atientId);
  442                oneOf(da taQuery).g etResults( );
  443                will(ret urnValue(p atients));
  444                
  445                oneOf(da taManager) .getQuery( "STS.looku pSNOMED");
  446                will(ret urnValue(d ataQuery)) ;
  447                oneOf(da taQuery).s etParamete r("code",  "224608005 ");
  448                oneOf(da taQuery).g etResults( );
  449                will(ret urnValue(r oles));
  450                
  451                oneOf(au ditManager ).storeAud it(with(eq ual(expAud it)));
  452                
  453                oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class)));
  454                will(ret urnValue(r esponse));
  455  
  456                allowing (propertyL ookup).get Property(w ith(any(St ring.class )));
  457                will(ret urnValue(" property") );
  458                
  459                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  460                will(ret urnValue(f acility));
  461           }} );
  462           
  463           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  464           ex pResult.se tReturn(1) ;
  465           
  466           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  467           as sertEquals (expResult .getReturn (), result .getReturn ());
  468       }
  469       
  470       @Test
  471       public  void test AnnouncePa tientTarge ted()
  472       {
  473           Sy stem.out.p rintln("te stAnnounce PatientTar geted");
  474           
  475           fi nal String  patientId  = "123456 7890V12345 6";
  476           
  477           fi nal Map de mographics  = new Has hMap() {{
  478                put("nam eGiven", n ew ArrayLi st() {{
  479                    add( "First");
  480                    add( "Middle");
  481                }});
  482                put("nam ePrefix",  "Prefix");
  483                put("nam eSuffix",  "Suffix");
  484                put("nam eFamily",  "Family");
  485                put("gen derCode",  "gender");
  486                put("bir thDate", " 20121022") ;
  487                put("SSN ", "666668 888");
  488                put("MRN ", "123456 7890V12345 6");
  489           }} ;
  490  
  491           fi nal Map de mographics Ext = new  HashMap()  {{
  492                put("hom eAddressSt reet", new  ArrayList () {{
  493                    add( "1234 Test  Lane");
  494                    add( "Apt 37");
  495                }});
  496                put("hom eAddressCi ty", "Test  City");
  497                put("hom eAddressSt ate", "LA" );
  498                put("hom eAddressPo stal", "70 124");
  499                put("pho neHome", " tel:+1-333 -777-8888" );
  500                put("mar italStatus Cod", "S") ;
  501                put("mul tipleBirth Code", "N" );
  502           }} ;
  503  
  504           fi nal Map pa tient = ne w HashMap( ) {{
  505                put("dem ographics" , demograp hics);
  506                put("dem ographicsE xt", demog raphicsExt );
  507                put("pat ientPrefer redFacilit yNumber",  "TEST");
  508                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  509           }} ;
  510  
  511           fi nal List p atients =  new ArrayL ist() {{
  512                add(pati ent);
  513           }} ;
  514  
  515           fi nal Announ cePatientT ype body =  new Annou ncePatient Type();
  516           bo dy.setPati entId(pati entId);
  517           Us erInfoType  userInfo  = new User InfoType() ;
  518           us erInfo.set FullName(" Test User" );
  519           us erInfo.set UserId("vh aisbtest") ;
  520           us erInfo.set Authentica tionMethod ("password ");
  521           us erInfo.set Role("test Role");
  522           bo dy.setUser Info(userI nfo);
  523           An nouncePati entType.Fa cilities f acilities  = new Anno uncePatien tType.Faci lities();
  524           bo dy.setFaci lities(fac ilities);
  525           fi nal String  testFacil ity = "200 TEST";
  526           fa cilities.g etFacility ().add(tes tFacility) ;
  527           
  528           fi nal Facili ty facilit y = new Fa cility();
  529           fa cility.set FacilityNu mber("TEST ");
  530           fa cility.set FacilityNa me("Test F acility");
  531           fa cility.set HomeCommun ityId("1.2 .3.4.5");
  532           fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ;
  533           
  534           fi nal Audit  expAudit =  new Audit ();
  535           ex pAudit.set Action("An nounce");
  536           ex pAudit.set Details(
  537                "ssn=" +  demograph ics.get("S SN")
  538                + ", las tName=" +  demographi cs.get("na meFamily")
  539                + ", mid dleName="  + ((List)d emographic s.get("nam eGiven")). get(1)
  540                + ", giv enName=" +  ((List)de mographics .get("name Given")).g et(0)
  541                + ", pre fix=" + de mographics .get("name Prefix")
  542                + ", suf fix=" + de mographics .get("name Suffix")
  543                + ", dob =" + demog raphics.ge t("birthDa te")
  544                + ", add ress[0]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0)
  545                + ", add ress[1]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1)
  546                + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty")
  547                + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate")
  548                + ", zip =" + demog raphicsExt .get("home AddressPos tal")
  549                + ", pho ne=" + dem ographicsE xt.get("ph oneHome")
  550                + ", gen der=" + de mographics .get("gend erCode")
  551                + ", mul tiBirth="  + demograp hicsExt.ge t("multipl eBirthCode ")
  552                + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode")
  553                + ", pat ientId=" +  demograph ics.get("M RN")
  554                + ", hom eCommunity Id=1.2.3.4 .5"
  555           );
  556           ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5");
  557           ex pAudit.set PatientFac ilityName( "Test Faci lity");
  558           ex pAudit.set PatientFac ilityNumbe r("TEST");
  559           ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ;
  560           ex pAudit.set PatientId( (String)de mographics .get("MRN" ));
  561           ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly"));
  562           ex pAudit.set PatientSSN ((String)d emographic s.get("SSN "));
  563           ex pAudit.set PurposeFor Use("TREAT MENT");
  564           ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e());
  565           ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ());
  566           ex pAudit.set UserId(bod y.getUserI nfo().getU serId() +  ", CN=" +  body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() );
  567           ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( ));
  568           ex pAudit.set UserRole(" 224608005" );
  569  
  570           fi nal List<M ap> roles  = new Arra yList<Map> ();
  571           Ma p role = n ew HashMap ();
  572           ro le.put("na me", "ROLE ");
  573           ro les.add(ro le);
  574  
  575           fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType  response =  new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType ();
  576           re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType());
  577           
  578           An nouncePati ent instan ce = new A nnouncePat ient();
  579           
  580           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  581           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  582           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  583           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  584           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  585           fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery =  context.mo ck(EntityP atientDisc overyPortT ype.class) ;
  586           
  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           in stance.set FacilityMa nager(faci lityManage r);
  591           in stance.set EntityPati entDiscove ry((Entity PatientDis coveryPort TypeLocal)  entityPat ientDiscov ery);
  592           
  593           co ntext.chec king(new E xpectation s() {
  594           {
  595                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  596                will(ret urnValue(d ataQuery)) ;
  597                oneOf(da taQuery).s etParamete r("icn", p atientId);
  598                oneOf(da taQuery).g etResults( );
  599                will(ret urnValue(p atients));
  600                
  601                oneOf(da taManager) .getQuery( "STS.looku pSNOMED");
  602                will(ret urnValue(d ataQuery)) ;
  603                oneOf(da taQuery).s etParamete r("code",  "224608005 ");
  604                oneOf(da taQuery).g etResults( );
  605                will(ret urnValue(r oles));
  606                
  607                oneOf(au ditManager ).storeAud it(with(eq ual(expAud it)));
  608                
  609                oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class)));
  610                will(ret urnValue(r esponse));
  611  
  612                allowing (propertyL ookup).get Property(w ith(any(St ring.class )));
  613                will(ret urnValue(" property") );
  614                
  615                oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er(testFac ility);
  616                will(ret urnValue(f acility));
  617                
  618                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  619                will(ret urnValue(f acility));
  620           }} );
  621           
  622           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  623           ex pResult.se tReturn(1) ;
  624           
  625           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  626           as sertEquals (expResult .getReturn (), result .getReturn ());
  627       }
  628       
  629       @Test
  630       public  void test AnnouncePa tientTarge tedInvalid FacilityNu mber()
  631       {
  632           Sy stem.out.p rintln("te stAnnounce PatientTar getedInval idFacility Number");
  633           
  634           fi nal String  patientId  = "123456 7890V12345 6";
  635           
  636           fi nal Map de mographics  = new Has hMap() {{
  637                put("nam eGiven", n ew ArrayLi st() {{
  638                    add( "First");
  639                    add( "Middle");
  640                }});
  641                put("nam ePrefix",  "Prefix");
  642                put("nam eSuffix",  "Suffix");
  643                put("nam eFamily",  "Family");
  644                put("gen derCode",  "gender");
  645                put("bir thDate", " 20121022") ;
  646                put("SSN ", "666668 888");
  647                put("MRN ", "123456 7890V12345 6");
  648           }} ;
  649  
  650           fi nal Map de mographics Ext = new  HashMap()  {{
  651                put("hom eAddressSt reet", new  ArrayList () {{
  652                    add( "1234 Test  Lane");
  653                    add( "Apt 37");
  654                }});
  655                put("hom eAddressCi ty", "Test  City");
  656                put("hom eAddressSt ate", "LA" );
  657                put("hom eAddressPo stal", "70 124");
  658                put("pho neHome", " tel:+1-333 -777-8888" );
  659                put("mar italStatus Cod", "S") ;
  660                put("mul tipleBirth Code", "N" );
  661           }} ;
  662  
  663           fi nal Map pa tient = ne w HashMap( ) {{
  664                put("dem ographics" , demograp hics);
  665                put("dem ographicsE xt", demog raphicsExt );
  666                put("pat ientPrefer redFacilit yNumber",  "TEST");
  667                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  668           }} ;
  669  
  670           fi nal List p atients =  new ArrayL ist() {{
  671                add(pati ent);
  672           }} ;
  673  
  674           fi nal Announ cePatientT ype body =  new Annou ncePatient Type();
  675           bo dy.setPati entId(pati entId);
  676           Us erInfoType  userInfo  = new User InfoType() ;
  677           us erInfo.set FullName(" Test User" );
  678           us erInfo.set UserId("vh aisbtest") ;
  679           us erInfo.set Authentica tionMethod ("password ");
  680           us erInfo.set Role("test Role");
  681           bo dy.setUser Info(userI nfo);
  682           An nouncePati entType.Fa cilities f acilities  = new Anno uncePatien tType.Faci lities();
  683           bo dy.setFaci lities(fac ilities);
  684           fi nal String  testFacil ity = "200 TEST";
  685           fa cilities.g etFacility ().add(tes tFacility) ;
  686           
  687           fi nal Facili ty facilit y = new Fa cility();
  688           fa cility.set FacilityNu mber("TEST ");
  689           fa cility.set FacilityNa me("Test F acility");
  690           fa cility.set HomeCommun ityId("1.2 .3.4.5");
  691           fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ;
  692           
  693           fi nal Audit  expAudit =  new Audit ();
  694           ex pAudit.set Action("An nounce");
  695           ex pAudit.set Details(
  696                "ssn=" +  demograph ics.get("S SN")
  697                + ", las tName=" +  demographi cs.get("na meFamily")
  698                + ", mid dleName="  + ((List)d emographic s.get("nam eGiven")). get(1)
  699                + ", giv enName=" +  ((List)de mographics .get("name Given")).g et(0)
  700                + ", pre fix=" + de mographics .get("name Prefix")
  701                + ", suf fix=" + de mographics .get("name Suffix")
  702                + ", dob =" + demog raphics.ge t("birthDa te")
  703                + ", add ress[0]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0)
  704                + ", add ress[1]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1)
  705                + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty")
  706                + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate")
  707                + ", zip =" + demog raphicsExt .get("home AddressPos tal")
  708                + ", pho ne=" + dem ographicsE xt.get("ph oneHome")
  709                + ", gen der=" + de mographics .get("gend erCode")
  710                + ", mul tiBirth="  + demograp hicsExt.ge t("multipl eBirthCode ")
  711                + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode")
  712                + ", pat ientId=" +  demograph ics.get("M RN")
  713                + ", hom eCommunity Id=1.2.3.4 .5"
  714           );
  715           ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5");
  716           ex pAudit.set PatientFac ilityName( "Test Faci lity");
  717           ex pAudit.set PatientFac ilityNumbe r("TEST");
  718           ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ;
  719           ex pAudit.set PatientId( (String)de mographics .get("MRN" ));
  720           ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly"));
  721           ex pAudit.set PatientSSN ((String)d emographic s.get("SSN "));
  722           ex pAudit.set PurposeFor Use("TREAT MENT");
  723           ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e());
  724           ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ());
  725           ex pAudit.set UserId(bod y.getUserI nfo().getU serId() +  ", CN=" +  body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() );
  726           ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( ));
  727           ex pAudit.set UserRole(" 224608005" );
  728  
  729           fi nal List<M ap> roles  = new Arra yList<Map> ();
  730           Ma p role = n ew HashMap ();
  731           ro le.put("na me", "ROLE ");
  732           ro les.add(ro le);
  733  
  734           fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType  response =  new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType ();
  735           re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType());
  736           
  737           An nouncePati ent instan ce = new A nnouncePat ient();
  738           
  739           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  740           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  741           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  742           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  743           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  744           fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery =  context.mo ck(EntityP atientDisc overyPortT ype.class) ;
  745           
  746           in stance.set DataManage r(dataMana ger);
  747           in stance.set PropertyLo okup(prope rtyLookup) ;
  748           in stance.set AuditManag er(auditMa nager);
  749           in stance.set FacilityMa nager(faci lityManage r);
  750           in stance.set EntityPati entDiscove ry((Entity PatientDis coveryPort TypeLocal)  entityPat ientDiscov ery);
  751           
  752           co ntext.chec king(new E xpectation s() {
  753           {
  754                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  755                will(ret urnValue(d ataQuery)) ;
  756                oneOf(da taQuery).s etParamete r("icn", p atientId);
  757                oneOf(da taQuery).g etResults( );
  758                will(ret urnValue(p atients));
  759                
  760                oneOf(da taManager) .getQuery( "STS.looku pSNOMED");
  761                will(ret urnValue(d ataQuery)) ;
  762                oneOf(da taQuery).s etParamete r("code",  "224608005 ");
  763                oneOf(da taQuery).g etResults( );
  764                will(ret urnValue(r oles));
  765                
  766                oneOf(au ditManager ).storeAud it(with(eq ual(expAud it)));
  767                
  768                never(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class)));
  769  
  770                allowing (propertyL ookup).get Property(w ith(any(St ring.class )));
  771                will(ret urnValue(" property") );
  772                
  773                oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er(testFac ility);
  774                will(ret urnValue(n ull));
  775                
  776                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  777                will(ret urnValue(f acility));
  778           }} );
  779           
  780           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  781           ex pResult.se tReturn(0) ;
  782           
  783           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  784           as sertEquals (expResult .getReturn (), result .getReturn ());
  785       }
  786       
  787       @Test
  788       public  void test AnnouncePa tientTarge tedEntityP DThrowsExc eption()
  789       {
  790           Sy stem.out.p rintln("te stAnnounce PatientTar getedEntit yPDThrowsE xception") ;
  791           
  792           fi nal String  patientId  = "123456 7890V12345 6";
  793           
  794           fi nal Map de mographics  = new Has hMap() {{
  795                put("nam eGiven", n ew ArrayLi st() {{
  796                    add( "First");
  797                    add( "Middle");
  798                }});
  799                put("nam ePrefix",  "Prefix");
  800                put("nam eSuffix",  "Suffix");
  801                put("nam eFamily",  "Family");
  802                put("gen derCode",  "gender");
  803                put("bir thDate", " 20121022") ;
  804                put("SSN ", "666668 888");
  805                put("MRN ", "123456 7890V12345 6");
  806           }} ;
  807  
  808           fi nal Map de mographics Ext = new  HashMap()  {{
  809                put("hom eAddressSt reet", new  ArrayList () {{
  810                    add( "1234 Test  Lane");
  811                    add( "Apt 37");
  812                }});
  813                put("hom eAddressCi ty", "Test  City");
  814                put("hom eAddressSt ate", "LA" );
  815                put("hom eAddressPo stal", "70 124");
  816                put("pho neHome", " tel:+1-333 -777-8888" );
  817                put("mar italStatus Cod", "S") ;
  818                put("mul tipleBirth Code", "N" );
  819           }} ;
  820  
  821           fi nal Map pa tient = ne w HashMap( ) {{
  822                put("dem ographics" , demograp hics);
  823                put("dem ographicsE xt", demog raphicsExt );
  824                put("pat ientPrefer redFacilit yNumber",  "TEST");
  825                put("pat ientPrefer redFacilit yName", "T est Facili ty");
  826           }} ;
  827  
  828           fi nal List p atients =  new ArrayL ist() {{
  829                add(pati ent);
  830           }} ;
  831  
  832           fi nal Announ cePatientT ype body =  new Annou ncePatient Type();
  833           bo dy.setPati entId(pati entId);
  834           Us erInfoType  userInfo  = new User InfoType() ;
  835           us erInfo.set FullName(" Test User" );
  836           us erInfo.set UserId("vh aisbtest") ;
  837           us erInfo.set Authentica tionMethod ("password ");
  838           us erInfo.set Role("test Role");
  839           bo dy.setUser Info(userI nfo);
  840           An nouncePati entType.Fa cilities f acilities  = new Anno uncePatien tType.Faci lities();
  841           bo dy.setFaci lities(fac ilities);
  842           fi nal String  testFacil ity = "200 TEST";
  843           fa cilities.g etFacility ().add(tes tFacility) ;
  844           
  845           fi nal Facili ty facilit y = new Fa cility();
  846           fa cility.set FacilityNu mber("TEST ");
  847           fa cility.set FacilityNa me("Test F acility");
  848           fa cility.set HomeCommun ityId("1.2 .3.4.5");
  849           fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ;
  850           
  851           fi nal Audit  expAudit =  new Audit ();
  852           ex pAudit.set Action("An nounce");
  853           ex pAudit.set Details(
  854                "ssn=" +  demograph ics.get("S SN")
  855                + ", las tName=" +  demographi cs.get("na meFamily")
  856                + ", mid dleName="  + ((List)d emographic s.get("nam eGiven")). get(1)
  857                + ", giv enName=" +  ((List)de mographics .get("name Given")).g et(0)
  858                + ", pre fix=" + de mographics .get("name Prefix")
  859                + ", suf fix=" + de mographics .get("name Suffix")
  860                + ", dob =" + demog raphics.ge t("birthDa te")
  861                + ", add ress[0]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0)
  862                + ", add ress[1]="  + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1)
  863                + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty")
  864                + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate")
  865                + ", zip =" + demog raphicsExt .get("home AddressPos tal")
  866                + ", pho ne=" + dem ographicsE xt.get("ph oneHome")
  867                + ", gen der=" + de mographics .get("gend erCode")
  868                + ", mul tiBirth="  + demograp hicsExt.ge t("multipl eBirthCode ")
  869                + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode")
  870                + ", pat ientId=" +  demograph ics.get("M RN")
  871                + ", hom eCommunity Id=1.2.3.4 .5"
  872           );
  873           ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5");
  874           ex pAudit.set PatientFac ilityName( "Test Faci lity");
  875           ex pAudit.set PatientFac ilityNumbe r("TEST");
  876           ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ;
  877           ex pAudit.set PatientId( (String)de mographics .get("MRN" ));
  878           ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly"));
  879           ex pAudit.set PatientSSN ((String)d emographic s.get("SSN "));
  880           ex pAudit.set PurposeFor Use("TREAT MENT");
  881           ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e());
  882           ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ());
  883           ex pAudit.set UserId(bod y.getUserI nfo().getU serId() +  ", CN=" +  body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() );
  884           ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( ));
  885           ex pAudit.set UserRole(" 224608005" );
  886  
  887           fi nal List<M ap> roles  = new Arra yList<Map> ();
  888           Ma p role = n ew HashMap ();
  889           ro le.put("na me", "ROLE ");
  890           ro les.add(ro le);
  891  
  892           fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType  response =  new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType ();
  893           re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType());
  894           
  895           An nouncePati ent instan ce = new A nnouncePat ient();
  896           
  897           fi nal DataMa nager data Manager =  context.mo ck(DataMan ager.class );
  898           fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass);
  899           fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ;
  900           fi nal AuditM anager aud itManager  = context. mock(Audit Manager.cl ass);
  901           fi nal Facili tyManager  facilityMa nager = co ntext.mock (FacilityM anager.cla ss);
  902           fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery =  context.mo ck(EntityP atientDisc overyPortT ype.class) ;
  903           
  904           in stance.set DataManage r(dataMana ger);
  905           in stance.set PropertyLo okup(prope rtyLookup) ;
  906           in stance.set AuditManag er(auditMa nager);
  907           in stance.set FacilityMa nager(faci lityManage r);
  908           in stance.set EntityPati entDiscove ry((Entity PatientDis coveryPort TypeLocal)  entityPat ientDiscov ery);
  909           
  910           co ntext.chec king(new E xpectation s() {
  911           {
  912                oneOf(da taManager) .getQuery( "Composite .findDemog raphics");
  913                will(ret urnValue(d ataQuery)) ;
  914                oneOf(da taQuery).s etParamete r("icn", p atientId);
  915                oneOf(da taQuery).g etResults( );
  916                will(ret urnValue(p atients));
  917                
  918                oneOf(da taManager) .getQuery( "STS.looku pSNOMED");
  919                will(ret urnValue(d ataQuery)) ;
  920                oneOf(da taQuery).s etParamete r("code",  "224608005 ");
  921                oneOf(da taQuery).g etResults( );
  922                will(ret urnValue(r oles));
  923                
  924                oneOf(au ditManager ).storeAud it(with(eq ual(expAud it)));
  925                
  926                oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class)));
  927                will(thr owExceptio n(new Runt imeExcepti on()));
  928                
  929                allowing (propertyL ookup).get Property(w ith(any(St ring.class )));
  930                will(ret urnValue(" property") );
  931                
  932                oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er(testFac ility);
  933                will(ret urnValue(f acility));
  934                
  935                allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  936                will(ret urnValue(f acility));
  937           }} );
  938           
  939           An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( );
  940           ex pResult.se tReturn(-1 );
  941           
  942           An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body);
  943           as sertEquals (expResult .getReturn (), result .getReturn ());
  944       }
  945   }