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

52.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\adaptergateway\patientdiscovery AdapterGatewayPatientDiscoveryTest.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\adaptergateway\patientdiscovery AdapterGatewayPatientDiscoveryTest.java Mon Apr 3 14:23:39 2017 UTC

52.2 Comparison summary

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

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

52.4 Active regular expressions

No regular expressions were active.

52.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 ientdiscov ery;
  6  
  7   import sta tic org.ju nit.Assert .assertEqu als;
  8   import sta tic org.ju nit.Assert .assertTru e;
  9   import sta tic org.ju nit.Assert .fail;
  10   import gov .hhs.fha.n hinc.adapt erpolicyen gine.Adapt erPolicyEn ginePortTy pe;
  11   import gov .hhs.fha.n hinc.commo n.nhinccom mon.Assert ionType;
  12   import gov .hhs.fha.n hinc.commo n.nhinccom mon.HomeCo mmunityTyp e;
  13   import gov .hhs.fha.n hinc.commo n.nhinccom mon.NhinTa rgetCommun itiesType;
  14   import gov .hhs.fha.n hinc.commo n.nhinccom mon.NhinTa rgetCommun ityType;
  15   import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .CheckPoli cyRequestT ype;
  16   import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .CheckPoli cyResponse Type;
  17   import gov .hhs.fha.n hinc.mpi.a dapter.com ponent.hl7 parsers.HL 7DbParser2 01305;
  18   import gov .hhs.fha.n hinc.patie ntdb.model .Patient;
  19   import gov .hhs.fha.n hinc.trans form.subdi sc.HL7Cons tants;
  20   import gov .hhs.fha.n hinc.trans form.subdi sc.HL7Data TransformH elper;
  21   import gov .hhs.fha.n hinc.trans form.subdi sc.HL7PRPA 201305Tran sforms;
  22   import gov .hhs.fha.n hinc.trans form.subdi sc.HL7Pati entTransfo rms;
  23   import gov .va.med.nh in.adapter .audit.req uests.Requ estAudit;
  24   import gov .va.med.nh in.adapter .audit.req uests.Requ estAuditIm pl;
  25   import gov .va.med.nh in.adapter .facilitym anager.Fac ility;
  26   import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag er;
  27   import gov .va.med.nh in.adapter .facilitym anager.Ope rationOnOf f;
  28   import gov .va.med.nh in.adapter .mock.acti ons.RunTas kAction;
  29   import gov .va.med.nh in.adapter .mpi.hl7pa rsers.HL7D bParser201 306;
  30   import gov .va.med.nh in.adapter .mvi.Adapt erMviPortT ypeLocal;
  31   import gov .va.med.nh in.adapter .patientco rrelation. PatientCor relationPo rtTypeLoca l;
  32   import gov .va.med.nh in.adapter .utils.Nul lChecker;
  33  
  34   import jav a.text.Sim pleDateFor mat;
  35   import jav a.util.Arr ayList;
  36   import jav a.util.Arr ays;
  37   import jav a.util.Dat e;
  38   import jav a.util.Lis t;
  39   import jav a.util.Tim eZone;
  40   import jav a.util.con current.Ex ecutorServ ice;
  41  
  42   import jav ax.xml.bin d.JAXBElem ent;
  43  
  44   import oas is.names.t c.xacml._2 _0.context .schema.os .DecisionT ype;
  45   import oas is.names.t c.xacml._2 _0.context .schema.os .ResponseT ype;
  46   import oas is.names.t c.xacml._2 _0.context .schema.os .ResultTyp e;
  47  
  48   import org .hl7.v3.AD Explicit;
  49   import org .hl7.v3.Ac tClassCont rolAct;
  50   import org .hl7.v3.Ad dPatientCo rrelationR equestType ;
  51   import org .hl7.v3.Ad xpExplicit City;
  52   import org .hl7.v3.Ad xpExplicit PostalCode ;
  53   import org .hl7.v3.Ad xpExplicit State;
  54   import org .hl7.v3.Ad xpExplicit StreetAddr essLine;
  55   import org .hl7.v3.BL ;
  56   import org .hl7.v3.CE ;
  57   import org .hl7.v3.CS ;
  58   import org .hl7.v3.En ExplicitFa mily;
  59   import org .hl7.v3.En ExplicitGi ven;
  60   import org .hl7.v3.En ExplicitPr efix;
  61   import org .hl7.v3.En ExplicitSu ffix;
  62   import org .hl7.v3.II ;
  63   import org .hl7.v3.PN Explicit;
  64   import org .hl7.v3.PR PAIN201305 UV02;
  65   import org .hl7.v3.PR PAIN201306 UV02;
  66   import org .hl7.v3.PR PAMT201301 UV02Patien t;
  67   import org .hl7.v3.PR PAMT201301 UV02Person ;
  68   import org .hl7.v3.PR PAMT201306 UV02Living SubjectId;
  69   import org .hl7.v3.PR PAMT201306 UV02Parame terList;
  70   import org .hl7.v3.Re spondingGa tewayPRPAI N201305UV0 2RequestTy pe;
  71   import org .hl7.v3.Re spondingGa tewayPRPAI N201306UV0 2ResponseT ype;
  72   import org .hl7.v3.ST ;
  73   import org .hl7.v3.TE LExplicit;
  74   import org .hl7.v3.TS Explicit;
  75   import org .jmock.Exp ectations;
  76   import org .jmock.Moc kery;
  77   import org .jmock.int egration.j unit4.JMoc k;
  78   import org .jmock.int egration.j unit4.JUni t4Mockery;
  79   import org .junit.Bef ore;
  80   import org .junit.Tes t;
  81   import org .junit.run ner.RunWit h;
  82   import org .uddi.api_ v3.Busines sDetail;
  83   import org .uddi.api_ v3.Busines sEntity;
  84   import org .uddi.api_ v3.Identif ierBag;
  85   import org .uddi.api_ v3.KeyedRe ference;
  86  
  87   /**
  88    * 
  89    * @author   DN S      VAZQUD
  90    */
  91   @RunWith(J Mock.class )
  92   public cla ss Adapter GatewayPat ientDiscov eryTest
  93   {
  94           st atic final  private S tring TEST _RECEIVING _HCID = "1 .1";
  95           st atic final  private S tring TEST _SENDING_H CID = "2.2 ";
  96           st atic final  private S tring TEST _RECEIVING _AA = "1.1 ";
  97           st atic final  private S tring TEST _SENDING_A A = "2.2";
  98           st atic final  private S tring TEST _AA_NAME =  "Test AA  Name";
  99  
  100           pr ivate fina l Mockery  context =  new JUnit4 Mockery();
  101  
  102           pr ivate Adap terGateway PatientDis covery ins tance;
  103  
  104           @B efore
  105           pu blic void  setUp()
  106           {
  107                    this .instance  = new Adap terGateway PatientDis covery();
  108           }
  109  
  110           /* *
  111            *  Test of r espondingG atewayPRPA IN201305UV 02 method,  of class
  112            *  AdapterGa tewayPatie ntDiscover y.
  113            * /
  114           @T est
  115           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Nul lRequest()
  116           {
  117                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02N ullRequest ");
  118  
  119                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  null;
  120                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  121  
  122                    try
  123                    {
  124                             instan ce.respond ingGateway PRPAIN2013 05UV02(req uest);
  125                             fail(" This shoul dn't happe n!");
  126                    }
  127                    catc h(Throwabl e t)
  128                    {
  129                             assert True(true) ;
  130                    }
  131           }
  132  
  133           @T est
  134           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02()
  135           {
  136                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02" );
  137  
  138                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  139                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null, nu ll, "20120 724", "New  Orleans",  "LA", Arr ays.asList (new Strin g[] { "123 4 Test Lan e" }), "70 143", "tel :+1-504-52 9-6111", " M", "no",  "M", "1234 567890V123 456", TEST _SENDING_H CID, TEST_ SENDING_AA , "6660033 33");
  140                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  141                    
  142                    //Ad ded by JMC
  143                    Asse rtionType  at = new A ssertionTy pe();
  144                    Home CommunityT ype hc = n ew HomeCom munityType ();
  145                    hc.s etHomeComm unityId(TE ST_SENDING _HCID);
  146                    at.s etHomeComm unity(hc);
  147                    requ est.setAss ertion(at) ;
  148                    //En d
  149  
  150                    Pati ent patien t = HL7DbP arser20130 5.extractM piPatientF romMessage (prpain201 305UV02);
  151                    List <Patient>  patients =  new Array List<Patie nt>();
  152                    pati ents.add(p atient);
  153                    fina l PRPAIN20 1306UV02 r esponseFro mPartner =  HL7DbPars er201306.B uildMessag eFromMpiPa tients(pat ients, prp ain201305U V02, TEST_ RECEIVING_ HCID, TEST _RECEIVING _AA);
  154  
  155                    PRPA IN201305UV 02 prpain2 01305UV02F romExterna l = create PRPAIN2013 05("Patien t", Arrays .asList(ne w String[]  { "Test"  }), null,  null, "201 20724", "N ew Orleans ", "LA", A rrays.asLi st(new Str ing[] { "1 234 Test L ane" }), " 70143", "t el:+1-504- 529-6111",  "M", "no" , "M", "12 34567890V1 23456", TE ST_RECEIVI NG_HCID, T EST_RECEIV ING_AA, "6 66003333") ;
  156  
  157                    fina l PRPAIN20 1306UV02 r esponseFro mMPI = HL7 DbParser20 1306.Build MessageFro mMpiPatien ts(patient s, prpain2 01305UV02F romExterna l, TEST_SE NDING_HCID , TEST_SEN DING_AA);
  158  
  159                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  160                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  161                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  162                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  163                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  164                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  165                    fina l RequestA udit reque stAudit =  context.mo ck(Request Audit.clas s);
  166                    
  167                    inst ance.setAd apterMvi(a dapterMpi) ;
  168                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  169                    inst ance.setEx ecutorServ ice(execut orService) ;
  170                    inst ance.setFa cilityMana ger(facili tyManager) ;
  171                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  172                    inst ance.setRe questAudit (requestAu dit);
  173  
  174                    cont ext.checki ng(new Exp ectations( )
  175                    {
  176                             {
  177                                      Business Detail bd  = new Busi nessDetail ();
  178                                      Business Entity be  = new Busi nessEntity ();
  179                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  180                                      keyedRef .setKeyNam e("");
  181                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  182                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  183                                      Identifi erBag iBag  = new Ide ntifierBag ();
  184                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  185                                      be.setId entifierBa g(iBag);
  186                                      bd.getBu sinessEnti ty().add(b e);
  187  
  188                                      Facility  facility  = new Faci lity();
  189                                      facility .setFacili tyNumber(" VA");
  190                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  191  
  192                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  193                                      Response Type respo nse = new  ResponseTy pe();
  194                                      checkPol icyRespons e.setRespo nse(respon se);
  195                                      ResultTy pe result  = new Resu ltType();
  196                                      response .getResult ().add(res ult);
  197                                      result.s etDecision (DecisionT ype.PERMIT );
  198  
  199                                      //I thin k this was  removed
  200                                      //Adapte rGatewayPa tientDisco very has a n unused i mport for  BusinessDe tail
  201                                      //They l ikely remo ved the re ference in  the test  class
  202                                      //so tha t it would  compile,  but didn't  update th e test
  203                                      //will(r eturnValue (bd));
  204                                      
  205                                      oneOf(fa cilityMana ger).isPar tnerAllowe d(TEST_SEN DING_HCID,  Operation OnOff.ONBO ARD);
  206                                      will(ret urnValue(t rue));
  207                                      
  208                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  209                                      will(ret urnValue(f acility));
  210                                      
  211                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  212                                      will(ret urnValue(c heckPolicy Response)) ;
  213                                      
  214                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  215                                      will(Run TaskAction .runTask() );
  216                                      
  217                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ), with(an y(Assertio nType.clas s)), with( any(String .class)));
  218                                      will(ret urnValue(r esponseFro mPartner)) ;
  219                                      
  220                                      oneOf(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  221                                      will(ret urnValue(r esponseFro mMPI));
  222                                      
  223                                      oneOf(ad apterPatie ntCorrelat ion).addPa tientCorre lation(wit h(any(AddP atientCorr elationReq uestType.c lass)));
  224                             }
  225                    });
  226  
  227                    Resp ondingGate wayPRPAIN2 01306UV02R esponseTyp e result =  instance. responding GatewayPRP AIN201305U V02(reques t);
  228                    asse rtEquals(1 , result.g etCommunit yResponse( ).size());
  229                    asse rtTrue(res ult.getCom munityResp onse().get (0) != nul l && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2() != nul l && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2().getCon trolActPro cess() !=  null && Nu llChecker. isNotNullO rEmpty(res ult.getCom munityResp onse().get (0).getPRP AIN201306U V02().getC ontrolActP rocess().g etSubject( )));
  230           }
  231  
  232           /*
  233           @T est
  234           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Tar geted() {
  235                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02T argeted");
  236  
  237                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  238                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  239                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  240                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  241                                      "6660033 33");
  242                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  243  
  244                    Nhin TargetComm unitiesTyp e nhinTarg etCommunit ies = new  NhinTarget Communitie sType();
  245                    requ est.setNhi nTargetCom munities(n hinTargetC ommunities );
  246                    Nhin TargetComm unityType  nhinTarget Community  = new Nhin TargetComm unityType( );
  247                    nhin TargetComm unities.ge tNhinTarge tCommunity ().add(nhi nTargetCom munity);
  248                    Home CommunityT ype homeCo mmunity =  new HomeCo mmunityTyp e();
  249                    nhin TargetComm unity.setH omeCommuni ty(homeCom munity);
  250                    home Community. setHomeCom munityId(T EST_RECEIV ING_HCID);
  251  
  252                    Pati ent patien t = HL7DbP arser20130 5.extractM piPatientF romMessage (prpain201 305UV02);
  253                    List <Patient>  patients =  new Array List<Patie nt>();
  254                    pati ents.add(p atient);
  255                    fina l PRPAIN20 1306UV02 r esponseFro mPartner =  HL7DbPars er201306.B uildMessag eFromMpiPa tients(pat ients,
  256                                      prpain20 1305UV02,  TEST_RECEI VING_HCID,  TEST_RECE IVING_AA);
  257  
  258                    PRPA IN201305UV 02 prpain2 01305UV02F romExterna l = create PRPAIN2013 05("Patien t",
  259                                      Arrays.a sList(new  String[] {  "Test" }) , null, nu ll, "20120 724", "New  Orleans",  "LA",
  260                                      Arrays.a sList(new  String[] {  "1234 Tes t Lane" }) , "70143",  "tel:+1-5 04-529-611 1", "M", " no", "M",
  261                                      "1234567 890V123456 ", TEST_RE CEIVING_HC ID, TEST_R ECEIVING_A A, "666003 333");
  262  
  263                    fina l PRPAIN20 1306UV02 r esponseFro mMPI = HL7 DbParser20 1306.Build MessageFro mMpiPatien ts(patient s,
  264                                      prpain20 1305UV02Fr omExternal , TEST_SEN DING_HCID,  TEST_SEND ING_AA);
  265  
  266                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  267  
  268                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  269                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  270                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  271                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  272                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  273                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  274  
  275                    inst ance.setAd apterMvi(a dapterMpi) ;
  276                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  277                    inst ance.setEx ecutorServ ice(execut orService) ;
  278                    inst ance.setFa cilityMana ger(facili tyManager) ;
  279                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  280  
  281                    cont ext.checki ng(new Exp ectations( ) {
  282                             {
  283                                      Business Detail bd  = new Busi nessDetail ();
  284                                      Business Entity be  = new Busi nessEntity ();
  285                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  286                                      keyedRef .setKeyNam e("");
  287                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  288                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  289                                      Identifi erBag iBag  = new Ide ntifierBag ();
  290                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  291                                      be.setId entifierBa g(iBag);
  292                                      bd.getBu sinessEnti ty().add(b e);
  293  
  294                                      Facility  facility  = new Faci lity();
  295                                      facility .setFacili tyNumber(" VA");
  296                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  297  
  298                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  299                                      Response Type respo nse = new  ResponseTy pe();
  300                                      checkPol icyRespons e.setRespo nse(respon se);
  301                                      ResultTy pe result  = new Resu ltType();
  302                                      response .getResult ().add(res ult);
  303                                      result.s etDecision (DecisionT ype.PERMIT );
  304  
  305                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  306                                      will(ret urnValue(f acility));
  307                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  308                                      will(ret urnValue(c heckPolicy Response)) ;
  309                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  310                                      will(Run TaskAction .runTask() );
  311                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  312                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  313                                      will(ret urnValue(r esponseFro mPartner)) ;
  314                                      oneOf(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  315                                      will(ret urnValue(r esponseFro mMPI));
  316                                      oneOf(ad apterPatie ntCorrelat ion).addPa tientCorre lation(
  317                                                       wi th(any(Add PatientCor relationRe questType. class)));
  318                             }
  319                    });
  320  
  321                    Resp ondingGate wayPRPAIN2 01306UV02R esponseTyp e result =  instance. responding GatewayPRP AIN201305U V02(reques t);
  322                    asse rtEquals(1 , result.g etCommunit yResponse( ).size());
  323                    asse rtTrue(res ult.getCom munityResp onse().get (0) != nul l
  324                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2() != nul l
  325                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2().getCon trolActPro cess() !=  null
  326                                      && NullC hecker.isN otNullOrEm pty(result .getCommun ityRespons e().get(0) .getPRPAIN 201306UV02 ()
  327                                                       .g etControlA ctProcess( ).getSubje ct()));
  328           }
  329  
  330           @T est
  331           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02NoM atchFromPa rtner() {
  332                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02N oMatchFrom Partner");
  333  
  334                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  335                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  336                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  337                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  338                                      "6660033 33");
  339                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  340  
  341                    fina l PRPAIN20 1306UV02 r esponseFro mPartner =  HL7DbPars er201306.B uildMessag eFromMpiPa tients(nul l,
  342                                      prpain20 1305UV02,  TEST_RECEI VING_HCID,  TEST_RECE IVING_AA);
  343  
  344                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  345  
  346                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  347                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  348                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  349                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  350                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  351                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  352  
  353                    inst ance.setAd apterMvi(a dapterMpi) ;
  354                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  355                    inst ance.setEx ecutorServ ice(execut orService) ;
  356                    inst ance.setFa cilityMana ger(facili tyManager) ;
  357                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  358  
  359                    cont ext.checki ng(new Exp ectations( ) {
  360                             {
  361                                      Business Detail bd  = new Busi nessDetail ();
  362                                      Business Entity be  = new Busi nessEntity ();
  363                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  364                                      keyedRef .setKeyNam e("");
  365                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  366                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  367                                      Identifi erBag iBag  = new Ide ntifierBag ();
  368                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  369                                      be.setId entifierBa g(iBag);
  370                                      bd.getBu sinessEnti ty().add(b e);
  371  
  372                                      Facility  facility  = new Faci lity();
  373                                      facility .setFacili tyNumber(" VA");
  374                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  375  
  376                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  377                                      Response Type respo nse = new  ResponseTy pe();
  378                                      checkPol icyRespons e.setRespo nse(respon se);
  379                                      ResultTy pe result  = new Resu ltType();
  380                                      response .getResult ().add(res ult);
  381                                      result.s etDecision (DecisionT ype.PERMIT );
  382  
  383                                      will(ret urnValue(b d));
  384                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  385                                      will(ret urnValue(f acility));
  386                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  387                                      will(ret urnValue(c heckPolicy Response)) ;
  388                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  389                                      will(Run TaskAction .runTask() );
  390                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  391                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  392                                      will(ret urnValue(r esponseFro mPartner)) ;
  393                                      never(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  394                                      never(ad apterPatie ntCorrelat ion).addPa tientCorre lation(
  395                                                       wi th(any(Add PatientCor relationRe questType. class)));
  396                             }
  397                    });
  398  
  399                    Resp ondingGate wayPRPAIN2 01306UV02R esponseTyp e result =  instance. responding GatewayPRP AIN201305U V02(reques t);
  400                    asse rtEquals(1 , result.g etCommunit yResponse( ).size());
  401                    asse rtTrue(res ult.getCom munityResp onse().get (0) != nul l
  402                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2() != nul l
  403                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2().getCon trolActPro cess() !=  null
  404                                      && NullC hecker.isN ullOrEmpty (result.ge tCommunity Response() .get(0).ge tPRPAIN201 306UV02()
  405                                                       .g etControlA ctProcess( ).getSubje ct()));
  406           }
  407  
  408           @T est
  409           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Mat chFromPart nerNoMatch FromVerify () {
  410                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02M atchFromPa tnerNoMatc hFromVerif y");
  411  
  412                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  413                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  414                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  415                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  416                                      "6660033 33");
  417                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  418  
  419                    Pati ent patien t = HL7DbP arser20130 5.extractM piPatientF romMessage (prpain201 305UV02);
  420                    List <Patient>  patients =  new Array List<Patie nt>();
  421                    pati ents.add(p atient);
  422                    fina l PRPAIN20 1306UV02 r esponseFro mPartner =  HL7DbPars er201306.B uildMessag eFromMpiPa tients(pat ients,
  423                                      prpain20 1305UV02,  TEST_RECEI VING_HCID,  TEST_RECE IVING_AA);
  424  
  425                    PRPA IN201305UV 02 prpain2 01305UV02F romExterna l = create PRPAIN2013 05("Patien t",
  426                                      Arrays.a sList(new  String[] {  "Test" }) , null, nu ll, "20120 724", "New  Orleans",  "LA",
  427                                      Arrays.a sList(new  String[] {  "1234 Tes t Lane" }) , "70143",  "tel:+1-5 04-529-611 1", "M", " no", "M",
  428                                      "1234567 890V123456 ", TEST_RE CEIVING_HC ID, TEST_R ECEIVING_A A, "666003 333");
  429  
  430                    fina l PRPAIN20 1306UV02 r esponseFro mMPI = HL7 DbParser20 1306.Build MessageFro mMpiPatien ts(null,
  431                                      prpain20 1305UV02Fr omExternal , TEST_SEN DING_HCID,  TEST_SEND ING_AA);
  432  
  433                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  434  
  435                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  436                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  437                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  438                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  439                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  440                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  441  
  442                    inst ance.setAd apterMvi(a dapterMpi) ;
  443                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  444                    inst ance.setEx ecutorServ ice(execut orService) ;
  445                    inst ance.setFa cilityMana ger(facili tyManager) ;
  446                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  447  
  448                    cont ext.checki ng(new Exp ectations( ) {
  449                             {
  450                                      Business Detail bd  = new Busi nessDetail ();
  451                                      Business Entity be  = new Busi nessEntity ();
  452                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  453                                      keyedRef .setKeyNam e("");
  454                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  455                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  456                                      Identifi erBag iBag  = new Ide ntifierBag ();
  457                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  458                                      be.setId entifierBa g(iBag);
  459                                      bd.getBu sinessEnti ty().add(b e);
  460  
  461                                      Facility  facility  = new Faci lity();
  462                                      facility .setFacili tyNumber(" VA");
  463                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  464  
  465                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  466                                      Response Type respo nse = new  ResponseTy pe();
  467                                      checkPol icyRespons e.setRespo nse(respon se);
  468                                      ResultTy pe result  = new Resu ltType();
  469                                      response .getResult ().add(res ult);
  470                                      result.s etDecision (DecisionT ype.PERMIT );
  471  
  472                                      will(ret urnValue(b d));
  473                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  474                                      will(ret urnValue(f acility));
  475                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  476                                      will(ret urnValue(c heckPolicy Response)) ;
  477                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  478                                      will(Run TaskAction .runTask() );
  479                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  480                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  481                                      will(ret urnValue(r esponseFro mPartner)) ;
  482                                      oneOf(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  483                                      will(ret urnValue(r esponseFro mMPI));
  484                                      never(ad apterPatie ntCorrelat ion).addPa tientCorre lation(
  485                                                       wi th(any(Add PatientCor relationRe questType. class)));
  486                             }
  487                    });
  488  
  489                    Resp ondingGate wayPRPAIN2 01306UV02R esponseTyp e result =  instance. responding GatewayPRP AIN201305U V02(reques t);
  490                    asse rtEquals(1 , result.g etCommunit yResponse( ).size());
  491                    asse rtTrue(res ult.getCom munityResp onse().get (0) != nul l
  492                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2() != nul l
  493                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2().getCon trolActPro cess() !=  null
  494                                      && NullC hecker.isN ullOrEmpty (result.ge tCommunity Response() .get(0).ge tPRPAIN201 306UV02()
  495                                                       .g etControlA ctProcess( ).getSubje ct()));
  496           }
  497  
  498           @T est
  499           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Che ckPolicyDe ny() {
  500                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02C heckPolicy Deny");
  501  
  502                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  503                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  504                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  505                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  506                                      "6660033 33");
  507                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  508  
  509                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  510  
  511                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  512                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  513                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  514                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  515                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  516                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  517  
  518                    inst ance.setAd apterMvi(a dapterMpi) ;
  519                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  520                    inst ance.setEx ecutorServ ice(execut orService) ;
  521                    inst ance.setFa cilityMana ger(facili tyManager) ;
  522                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  523  
  524                    cont ext.checki ng(new Exp ectations( ) {
  525                             {
  526                                      Business Detail bd  = new Busi nessDetail ();
  527                                      Business Entity be  = new Busi nessEntity ();
  528                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  529                                      keyedRef .setKeyNam e("");
  530                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  531                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  532                                      Identifi erBag iBag  = new Ide ntifierBag ();
  533                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  534                                      be.setId entifierBa g(iBag);
  535                                      bd.getBu sinessEnti ty().add(b e);
  536  
  537                                      Facility  facility  = new Faci lity();
  538                                      facility .setFacili tyNumber(" VA");
  539                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  540  
  541                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  542                                      Response Type respo nse = new  ResponseTy pe();
  543                                      checkPol icyRespons e.setRespo nse(respon se);
  544                                      ResultTy pe result  = new Resu ltType();
  545                                      response .getResult ().add(res ult);
  546                                      result.s etDecision (DecisionT ype.DENY);
  547  
  548                                      will(ret urnValue(b d));
  549                                      oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er("VA");
  550                                      will(ret urnValue(f acility));
  551                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  552                                      will(ret urnValue(c heckPolicy Response)) ;
  553                                      never(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  554                                      never(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  555                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  556                             }
  557                    });
  558  
  559                    Resp ondingGate wayPRPAIN2 01306UV02R esponseTyp e result =  instance. responding GatewayPRP AIN201305U V02(reques t);
  560                    asse rtEquals(1 , result.g etCommunit yResponse( ).size());
  561                    asse rtTrue(res ult.getCom munityResp onse().get (0) != nul l
  562                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2() != nul l
  563                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2().getCon trolActPro cess() !=  null
  564                                      && NullC hecker.isN ullOrEmpty (result.ge tCommunity Response() .get(0).ge tPRPAIN201 306UV02()
  565                                                       .g etControlA ctProcess( ).getSubje ct()));
  566           }
  567  
  568           @T est
  569           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02NHI NSenderErr or() {
  570                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02N HINSenderE rror");
  571  
  572                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  573                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  574                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  575                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  576                                      "6660033 33");
  577                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  578  
  579                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  580  
  581                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  582                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  583                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  584                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  585                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  586                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  587  
  588                    inst ance.setAd apterMvi(a dapterMpi) ;
  589                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  590                    inst ance.setEx ecutorServ ice(execut orService) ;
  591                    inst ance.setFa cilityMana ger(facili tyManager) ;
  592                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  593  
  594                    cont ext.checki ng(new Exp ectations( ) {
  595                             {
  596                                      Business Detail bd  = new Busi nessDetail ();
  597                                      Business Entity be  = new Busi nessEntity ();
  598                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  599                                      keyedRef .setKeyNam e("");
  600                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  601                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  602                                      Identifi erBag iBag  = new Ide ntifierBag ();
  603                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  604                                      be.setId entifierBa g(iBag);
  605                                      bd.getBu sinessEnti ty().add(b e);
  606  
  607                                      Facility  facility  = new Faci lity();
  608                                      facility .setFacili tyNumber(" VA");
  609                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  610  
  611                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  612                                      Response Type respo nse = new  ResponseTy pe();
  613                                      checkPol icyRespons e.setRespo nse(respon se);
  614                                      ResultTy pe result  = new Resu ltType();
  615                                      response .getResult ().add(res ult);
  616                                      result.s etDecision (DecisionT ype.PERMIT );
  617  
  618                                      will(ret urnValue(b d));
  619                                      oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er("VA");
  620                                      will(ret urnValue(f acility));
  621                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  622                                      will(ret urnValue(c heckPolicy Response)) ;
  623                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  624                                      will(Run TaskAction .runTask() );
  625                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  626                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  627                                      will(thr owExceptio n(new Runt imeExcepti on()));
  628                             }
  629                    });
  630  
  631                    Resp ondingGate wayPRPAIN2 01306UV02R esponseTyp e result =  instance. responding GatewayPRP AIN201305U V02(reques t);
  632                    asse rtEquals(1 , result.g etCommunit yResponse( ).size());
  633                    asse rtTrue(res ult.getCom munityResp onse().get (0) != nul l
  634                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2() != nul l
  635                                      && resul t.getCommu nityRespon se().get(0 ).getPRPAI N201306UV0 2().getCon trolActPro cess() !=  null
  636                                      && NullC hecker.isN ullOrEmpty (result.ge tCommunity Response() .get(0).ge tPRPAIN201 306UV02()
  637                                                       .g etControlA ctProcess( ).getSubje ct()));
  638           }
  639  
  640           @T est
  641           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Che ckPolicyEx ception()  {
  642                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02C heckPolicy Exception" );
  643  
  644                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  645                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  646                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  647                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  648                                      "6660033 33");
  649                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  650  
  651                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  652  
  653                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  654                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  655                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  656                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  657                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  658                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  659  
  660                    inst ance.setAd apterMvi(a dapterMpi) ;
  661                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  662                    inst ance.setEx ecutorServ ice(execut orService) ;
  663                    inst ance.setFa cilityMana ger(facili tyManager) ;
  664                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  665  
  666                    cont ext.checki ng(new Exp ectations( ) {
  667                             {
  668                                      Business Detail bd  = new Busi nessDetail ();
  669                                      Business Entity be  = new Busi nessEntity ();
  670                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  671                                      keyedRef .setKeyNam e("");
  672                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  673                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  674                                      Identifi erBag iBag  = new Ide ntifierBag ();
  675                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  676                                      be.setId entifierBa g(iBag);
  677                                      bd.getBu sinessEnti ty().add(b e);
  678  
  679                                      Facility  facility  = new Faci lity();
  680                                      facility .setFacili tyNumber(" VA");
  681                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  682  
  683                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  684                                      Response Type respo nse = new  ResponseTy pe();
  685                                      checkPol icyRespons e.setRespo nse(respon se);
  686                                      ResultTy pe result  = new Resu ltType();
  687                                      response .getResult ().add(res ult);
  688                                      result.s etDecision (DecisionT ype.PERMIT );
  689  
  690                                      will(ret urnValue(b d));
  691                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  692                                      will(ret urnValue(f acility));
  693                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  694                                      will(thr owExceptio n(new Runt imeExcepti on()));
  695                                      never(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  696                                      never(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  697                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  698                                      never(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  699                                      never(ad apterPatie ntCorrelat ion).addPa tientCorre lation(
  700                                                       wi th(any(Add PatientCor relationRe questType. class)));
  701                             }
  702                    });
  703  
  704                    try  {
  705                             Respon dingGatewa yPRPAIN201 306UV02Res ponseType  result = i nstance.re spondingGa tewayPRPAI N201305UV0 2(request) ;
  706                             fail(" This shoul dn't happe n!");
  707                    } ca tch (Throw able t) {
  708                             assert True(true) ;
  709                    }
  710           }
  711  
  712           @T est
  713           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Ada pterMpiExc eption() {
  714                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02A dapterMpiE xception") ;
  715  
  716                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  717                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  718                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  719                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  720                                      "6660033 33");
  721                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  722  
  723                    Pati ent patien t = HL7DbP arser20130 5.extractM piPatientF romMessage (prpain201 305UV02);
  724                    List <Patient>  patients =  new Array List<Patie nt>();
  725                    pati ents.add(p atient);
  726                    fina l PRPAIN20 1306UV02 r esponseFro mPartner =  HL7DbPars er201306.B uildMessag eFromMpiPa tients(pat ients,
  727                                      prpain20 1305UV02,  TEST_RECEI VING_HCID,  TEST_RECE IVING_AA);
  728  
  729                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  730  
  731                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  732                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  733                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  734                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  735                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  736                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  737  
  738                    inst ance.setAd apterMvi(a dapterMpi) ;
  739                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  740                    inst ance.setEx ecutorServ ice(execut orService) ;
  741                    inst ance.setFa cilityMana ger(facili tyManager) ;
  742                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  743  
  744                    cont ext.checki ng(new Exp ectations( ) {
  745                             {
  746                                      Business Detail bd  = new Busi nessDetail ();
  747                                      Business Entity be  = new Busi nessEntity ();
  748                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  749                                      keyedRef .setKeyNam e("");
  750                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  751                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  752                                      Identifi erBag iBag  = new Ide ntifierBag ();
  753                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  754                                      be.setId entifierBa g(iBag);
  755                                      bd.getBu sinessEnti ty().add(b e);
  756                                      
  757                                      Facility  facility  = new Faci lity();
  758                                      facility .setFacili tyNumber(" VA");
  759                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  760  
  761                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  762                                      Response Type respo nse = new  ResponseTy pe();
  763                                      checkPol icyRespons e.setRespo nse(respon se);
  764                                      ResultTy pe result  = new Resu ltType();
  765                                      response .getResult ().add(res ult);
  766                                      result.s etDecision (DecisionT ype.PERMIT );
  767  
  768                                      will(ret urnValue(b d));
  769                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  770                                      will(ret urnValue(f acility));
  771                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  772                                      will(ret urnValue(c heckPolicy Response)) ;
  773                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  774                                      will(Run TaskAction .runTask() );
  775                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  776                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  777                                      will(ret urnValue(r esponseFro mPartner)) ;
  778                                      oneOf(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  779                                      will(thr owExceptio n(new Runt imeExcepti on()));
  780                                      never(ad apterPatie ntCorrelat ion).addPa tientCorre lation(
  781                                                       wi th(any(Add PatientCor relationRe questType. class)));
  782                             }
  783                    });
  784  
  785                    try  {
  786                             Respon dingGatewa yPRPAIN201 306UV02Res ponseType  result = i nstance.re spondingGa tewayPRPAI N201305UV0 2(request) ;
  787                             fail(" This shoul dn't happe n!");
  788                    } ca tch (Throw able t) {
  789                             assert True(true) ;
  790                    }
  791           }
  792  
  793           @T est
  794           pu blic void  testRespon dingGatewa yPRPAIN201 305UV02Pat ientCorrel ationExcep tion() {
  795                    Syst em.out.pri ntln("resp ondingGate wayPRPAIN2 01305UV02P atientCorr elationExc eption");
  796  
  797                    Resp ondingGate wayPRPAIN2 01305UV02R equestType  request =  new Respo ndingGatew ayPRPAIN20 1305UV02Re questType( );
  798                    PRPA IN201305UV 02 prpain2 01305UV02  = createPR PAIN201305 ("Patient" , Arrays.a sList(new  String[] {  "Test" }) , null,
  799                                      null, "2 0120724",  "New Orlea ns", "LA",  Arrays.as List(new S tring[] {  "1234 Test  Lane" }),  "70143",
  800                                      "tel:+1- 504-529-61 11", "M",  "no", "M",  "12345678 90V123456" , TEST_SEN DING_HCID,  TEST_SEND ING_AA,
  801                                      "6660033 33");
  802                    requ est.setPRP AIN201305U V02(prpain 201305UV02 );
  803  
  804                    Pati ent patien t = HL7DbP arser20130 5.extractM piPatientF romMessage (prpain201 305UV02);
  805                    List <Patient>  patients =  new Array List<Patie nt>();
  806                    pati ents.add(p atient);
  807                    fina l PRPAIN20 1306UV02 r esponseFro mPartner =  HL7DbPars er201306.B uildMessag eFromMpiPa tients(pat ients,
  808                                      prpain20 1305UV02,  TEST_RECEI VING_HCID,  TEST_RECE IVING_AA);
  809  
  810                    PRPA IN201305UV 02 prpain2 01305UV02F romExterna l = create PRPAIN2013 05("Patien t",
  811                                      Arrays.a sList(new  String[] {  "Test" }) , null, nu ll, "20120 724", "New  Orleans",  "LA",
  812                                      Arrays.a sList(new  String[] {  "1234 Tes t Lane" }) , "70143",  "tel:+1-5 04-529-611 1", "M", " no", "M",
  813                                      "1234567 890V123456 ", TEST_RE CEIVING_HC ID, TEST_R ECEIVING_A A, "666003 333");
  814  
  815                    fina l PRPAIN20 1306UV02 r esponseFro mMPI = HL7 DbParser20 1306.Build MessageFro mMpiPatien ts(patient s,
  816                                      prpain20 1305UV02Fr omExternal , TEST_SEN DING_HCID,  TEST_SEND ING_AA);
  817  
  818                    Adap terGateway PatientDis covery ins tance = ne w AdapterG atewayPati entDiscove ry();
  819  
  820                    fina l Executor Service ex ecutorServ ice = cont ext.mock(E xecutorSer vice.class );
  821                    fina l AdapterM viPortType Local adap terMpi = c ontext.moc k(AdapterM viPortType Local.clas s);
  822                    fina l PatientC orrelation PortTypeLo cal adapte rPatientCo rrelation  = context. mock(Patie ntCorrelat ionPortTyp eLocal.cla ss);
  823                    fina l AdapterP olicyEngin ePortType  adapterPol icyEngine  = context. mock(Adapt erPolicyEn ginePortTy pe.class);
  824                    fina l Facility Manager fa cilityMana ger = cont ext.mock(F acilityMan ager.class );
  825                    fina l NHINPati entDiscove rySender n hinPatient DiscoveryS ender = co ntext.mock (NHINPatie ntDiscover ySender.cl ass);
  826  
  827                    inst ance.setAd apterMvi(a dapterMpi) ;
  828                    inst ance.setAd apterPatie ntCorrelat ion(adapte rPatientCo rrelation) ;
  829                    inst ance.setEx ecutorServ ice(execut orService) ;
  830                    inst ance.setFa cilityMana ger(facili tyManager) ;
  831                    inst ance.setNh inPatientD iscoverySe nder(nhinP atientDisc overySende r);
  832  
  833                    cont ext.checki ng(new Exp ectations( ) {
  834                             {
  835                                      Business Detail bd  = new Busi nessDetail ();
  836                                      Business Entity be  = new Busi nessEntity ();
  837                                      KeyedRef erence key edRef = ne w KeyedRef erence();
  838                                      keyedRef .setKeyNam e("");
  839                                      keyedRef .setKeyVal ue(TEST_RE CEIVING_HC ID);
  840                                      keyedRef .setTModel Key("uddi: nhin:nhie: homecommun ityid");
  841                                      Identifi erBag iBag  = new Ide ntifierBag ();
  842                                      iBag.get KeyedRefer ence().add (keyedRef) ;
  843                                      be.setId entifierBa g(iBag);
  844                                      bd.getBu sinessEnti ty().add(b e);
  845  
  846                                      Facility  facility  = new Faci lity();
  847                                      facility .setFacili tyNumber(" VA");
  848                                      facility .setHomeCo mmunityId( TEST_SENDI NG_HCID);
  849  
  850                                      CheckPol icyRespons eType chec kPolicyRes ponse = ne w CheckPol icyRespons eType();
  851                                      Response Type respo nse = new  ResponseTy pe();
  852                                      checkPol icyRespons e.setRespo nse(respon se);
  853                                      ResultTy pe result  = new Resu ltType();
  854                                      response .getResult ().add(res ult);
  855                                      result.s etDecision (DecisionT ype.PERMIT );
  856  
  857                                      will(ret urnValue(b d));
  858                                      allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" );
  859                                      will(ret urnValue(f acility));
  860                                      oneOf(ad apterPolic yEngine).c heckPolicy (with(any( CheckPolic yRequestTy pe.class)) );
  861                                      will(ret urnValue(c heckPolicy Response)) ;
  862                                      oneOf(ex ecutorServ ice).execu te(with(an y(Runnable .class)));
  863                                      will(Run TaskAction .runTask() );
  864                                      oneOf(nh inPatientD iscoverySe nder).send Request(wi th(any(PRP AIN201305U V02.class) ),
  865                                                       wi th(any(Ass ertionType .class)),  with(any(S tring.clas s)));
  866                                      will(ret urnValue(r esponseFro mPartner)) ;
  867                                      oneOf(ad apterMpi). findCandid ates(with( any(Respon dingGatewa yPRPAIN201 305UV02Req uestType.c lass)));
  868                                      will(ret urnValue(r esponseFro mMPI));
  869                                      oneOf(ad apterPatie ntCorrelat ion).addPa tientCorre lation(
  870                                                       wi th(any(Add PatientCor relationRe questType. class)));
  871                                      will(thr owExceptio n(new Runt imeExcepti on()));
  872                             }
  873                    });
  874  
  875                    try  {
  876                             Respon dingGatewa yPRPAIN201 306UV02Res ponseType  result = i nstance.re spondingGa tewayPRPAI N201305UV0 2(request) ;
  877                             fail(" This shoul dn't happe n!");
  878                    } ca tch (Throw able t) {
  879                             assert True(true) ;
  880                    }
  881           }
  882   */
  883           pr ivate PRPA IN201305UV 02 createP RPAIN20130 5(String l astName, L ist<String > givenNam e, String  prefix, St ring suffi x, String  dob, Strin g city, St ring state , List<Str ing> addre ss, String  zip, Stri ng phone,  String gen der, Strin g multiBir th, String  maritalSt atus, Stri ng patient Id, String  homeCommu nityId, St ring assig ningAuthor ity, Strin g ssn)
  884           {
  885                    JAXB Element<PR PAMT201301 UV02Person > patientP erson = bu ildPRPAIN2 01301Patie ntPerson(l astName, g ivenName,  prefix, su ffix, dob,  city, sta te, addres s, zip, ph one, gende r, multiBi rth, marit alStatus);
  886  
  887                    II i i = new II ();
  888                    ii.s etRoot(ass igningAuth ority);
  889                    ii.s etExtensio n(patientI d);
  890                    Stri ng assigni ngAuthorit yName = TE ST_AA_NAME ;
  891                    if(! NullChecke r.isNullOr Empty(assi gningAutho rityName))
  892                    {
  893                             ii.set AssigningA uthorityNa me(assigni ngAuthorit yName);
  894                    }
  895  
  896                    PRPA MT201301UV 02Patient  patient =  HL7Patient Transforms .create201 301Patient (patientPe rson, ii);
  897  
  898                    PRPA IN201305UV 02 ret = H L7PRPA2013 05Transfor ms.createP RPA201305( patient, h omeCommuni tyId, "1.1 ", assigni ngAuthorit y);
  899  
  900                    // a dd ssn.
  901                    PRPA MT201306UV 02Paramete rList para mList = re t.getContr olActProce ss().getQu eryByParam eter().get Value().ge tParameter List();
  902                    PRPA MT201306UV 02LivingSu bjectId ss nId = new  PRPAMT2013 06UV02Livi ngSubjectI d();
  903                    ii =  new II();
  904                    ii.s etRoot("2. 16.840.1.1 13883.4.1" );
  905                    ii.s etExtensio n(ssn);
  906                    ssnI d.getValue ().add(ii) ;
  907                    ST t ext = new  ST();
  908                    ssnI d.setSeman ticsText(t ext);
  909                    para mList.getL ivingSubje ctId().add (ssnId);
  910  
  911                    // f ix the int eraction i d.
  912                    ret. setInterac tionId(HL7 DataTransf ormHelper. IIFactory( HL7Constan ts.INTERAC TION_ID_RO OT, "PRPA_ IN201305UV 02"));
  913  
  914                    // f ix the con trolActPro ccess/code .
  915                    ret. getControl ActProcess ().setCode (HL7DataTr ansformHel per.CDFact ory("PRPA_ TE201305UV 02", HL7Co nstants.IN TERACTION_ ID_ROOT));
  916  
  917                    // f ix the acc eptAckCode .
  918                    ret. setAcceptA ckCode(HL7 DataTransf ormHelper. CSFactory( "NE"));
  919  
  920                    // f ix the pro cessingMod eCode.
  921                    ret. setProcess ingModeCod e(HL7DataT ransformHe lper.CSFac tory("T")) ;
  922  
  923                    ret. getControl ActProcess ().setClas sCode(ActC lassContro lAct.CACT) ;
  924                    ret. getControl ActProcess ().getAuth orOrPerfor mer().get( 0).getAssi gnedDevice ().getValu e().setCla ssCode("AS SIGNED");
  925  
  926                    // f ix the cre ation time  of the me ssage.
  927                    TSEx plicit te  = new TSEx plicit();
  928                    Date  now = new  Date();
  929                    Simp leDateForm at formatt er = new S impleDateF ormat("yyy yMMddHHmms s");
  930                    form atter.setT imeZone(Ti meZone.get TimeZone(" UTC"));
  931                    te.s etValue(fo rmatter.fo rmat(now)) ;
  932                    ret. setCreatio nTime(te);
  933  
  934                    CS r esponseMod alityCode  = new CS() ;
  935                    resp onseModali tyCode.set Code("R");
  936                    ret. getControl ActProcess ().getQuer yByParamet er().getVa lue().setR esponseMod alityCode( responseMo dalityCode );
  937  
  938                    CS r esponsePri orityCode  = new CS() ;
  939                    resp onsePriori tyCode.set Code("I");
  940                    ret. getControl ActProcess ().getQuer yByParamet er().getVa lue().setR esponsePri orityCode( responsePr iorityCode );
  941  
  942                    retu rn ret;
  943           }
  944  
  945           pr ivate JAXB Element<PR PAMT201301 UV02Person > buildPRP AIN201301P atientPers on(String  lastName,  List<Strin g> givenNa me, String  prefix, S tring suff ix, String  dob, Stri ng city, S tring stat e, List<St ring> addr ess, Strin g zip, Str ing phone,  String ge nder, Stri ng multiBi rth, Strin g maritalS tatus)
  946           {
  947                    PRPA MT201301UV 02Person p atientPers on = new P RPAMT20130 1UV02Perso n();
  948  
  949                    // - ---------- ---------- ---------- ---------- ---------- ---------- -
  950                    // b uild name
  951                    org. hl7.v3.Obj ectFactory  factory =  new org.h l7.v3.Obje ctFactory( );
  952                    PNEx plicit nam e = (facto ry.createP NExplicit( ));
  953                    List  namelist  = name.get Content();
  954  
  955                    // L ast name
  956                    EnEx plicitFami ly familyN ame = new  EnExplicit Family();
  957                    fami lyName.set PartType(" FAM");
  958                    fami lyName.set Content(la stName);
  959                    name list.add(f actory.cre atePNExpli citFamily( familyName ));
  960  
  961                    // F irst name
  962                    if(N ullChecker .isNotNull OrEmpty(gi venName))
  963                    {
  964                             for(St ring n : g ivenName)
  965                             {
  966                                      if(!Null Checker.is NullOrEmpt y(n))
  967                                      {
  968                                               EnExplicit Given gn =  new EnExp licitGiven ();
  969                                               gn.setPart Type("GIV" );
  970                                               gn.setCont ent(n);
  971                                               namelist.a dd(factory .createPNE xplicitGiv en(gn));
  972  
  973                                      }
  974                             }
  975                    }
  976  
  977                    EnEx plicitPref ix pfx = n ew EnExpli citPrefix( );
  978                    pfx. setContent (prefix);
  979                    pfx. setPartTyp e("PFX");
  980                    name list.add(f actory.cre ateENExpli citPrefix( pfx));
  981  
  982                    EnEx plicitSuff ix sfx = n ew EnExpli citSuffix( );
  983                    sfx. setContent (suffix);
  984                    sfx. setPartTyp e("SFX");
  985                    name list.add(f actory.cre ateENExpli citSuffix( sfx));
  986  
  987                    pati entPerson. getName(). add(name);
  988                    // - ---------- ---------- ---------- ---------- ---------- ---------
  989  
  990                    // D ate of Bir th
  991                    TSEx plicit val ueTSExplic it = new T SExplicit( );
  992                    valu eTSExplici t.setValue (dob);
  993                    pati entPerson. setBirthTi me(valueTS Explicit);
  994  
  995                    // G ender
  996                    CE v alueCE = n ew CE();
  997                    valu eCE.setCod e(gender);
  998                    pati entPerson. setAdminis trativeGen derCode(va lueCE);
  999  
  1000                    // - ---------- ---------- ---------- ---------- ---------- ----------
  1001                    // b uild addre ss
  1002                    ADEx plicit add r = (facto ry.createA DExplicit( ));
  1003                    List  addrlist  = addr.get Content();
  1004  
  1005                    // a ddress
  1006                    Adxp ExplicitCi ty valueCi ty = new A dxpExplici tCity();
  1007                    valu eCity.setC ontent(cit y);
  1008                    addr list.add(f actory.cre ateADExpli citCity(va lueCity));
  1009  
  1010                    Adxp ExplicitSt ate valueS tate = new  AdxpExpli citState() ;
  1011                    valu eState.set Content(st ate);
  1012                    addr list.add(f actory.cre ateADExpli citState(v alueState) );
  1013  
  1014                    if(N ullChecker .isNotNull OrEmpty(ad dress))
  1015                    {
  1016                             for(St ring a : a ddress)
  1017                             {
  1018                                      if(!Null Checker.is NullOrEmpt y(a))
  1019                                      {
  1020                                               AdxpExplic itStreetAd dressLine  line = new  AdxpExpli citStreetA ddressLine ();
  1021                                               line.setCo ntent(a);
  1022                                               addrlist.a dd(factory .createADE xplicitStr eetAddress Line(line) );
  1023                                      }
  1024                             }
  1025                    }
  1026  
  1027                    Adxp ExplicitPo stalCode v alueZip =  new AdxpEx plicitPost alCode();
  1028                    valu eZip.setCo ntent(zip) ;
  1029                    addr list.add(f actory.cre ateADExpli citPostalC ode(valueZ ip));
  1030  
  1031                    pati entPerson. getAddr(). add(addr);
  1032                    // - ---------- ---------- ---------- ---------- ---------- ---------- -
  1033  
  1034                    // t elephone
  1035                    TELE xplicit va lueTELE =  new TELExp licit();
  1036                    valu eTELE.setV alue(phone );
  1037                    pati entPerson. getTelecom ().add(val ueTELE);
  1038  
  1039                    // m ulti birth
  1040                    BL v alueBL = n ew BL();
  1041                    if(m ultiBirth  == null ||  multiBirt h.length()  == 0 || m ultiBirth. startsWith ("NO") ||  multiBirth .startsWit h("no"))
  1042                    {
  1043                             valueB L.setValue (false);
  1044                    }
  1045                    else
  1046                    {
  1047                             valueB L.setValue (true);
  1048                    }
  1049                    pati entPerson. setMultipl eBirthInd( valueBL);  // BL valu e
  1050  
  1051                    // m arital sta tus
  1052                    CE m aritalStat usCode = n ew CE();
  1053                    mari talStatusC ode.setCod e(maritalS tatus);
  1054                    pati entPerson. setMarital StatusCode (maritalSt atusCode);
  1055  
  1056                    retu rn factory .createPRP AMT201301U V02Patient PatientPer son(patien tPerson);
  1057           }
  1058   }