3904. EPMO Open Source Coordination Office Redaction File Detail Report

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

3904.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:50:58 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-server\src\main\java\gov\va\nvap\server\service\permission\pdp PDPImplJava.java Fri Apr 21 20:03:28 2017 UTC

3904.2 Comparison summary

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

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

3904.4 Active regular expressions

No regular expressions were active.

3904.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  
        6   package go v.va.nvap. server.ser vice.permi ssion.pdp;
        7  
        8   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        9   import gov .va.nvap.s erver.serv ice.permis sion.commo n.PatientI dUtil;
        10   import gov .va.nvap.s erver.serv ice.permis sion.commo n.XACMLCon textConsta nts;
        11   import gov .va.nvap.s erver.serv ice.permis sion.commo n.XACMLCon textUtil;
        12   import gov .va.nvap.s erver.serv ice.permis sion.commo n.XACMLReq uestParser ;
        13   import gov .va.nvap.s ervice.per mission.pd p.PDPInter face;
        14  
        15   import jav a.util.Lis t;
        16   import jav a.util.Loc ale;
        17   import jav a.util.log ging.Level ;
        18   import jav a.util.log ging.Logge r;
        19   import jav a.util.reg ex.Pattern ;
        20  
        21   import oas is.names.t c.xacml._2 _0.context .schema.os .DecisionT ype;
        22   import oas is.names.t c.xacml._2 _0.context .schema.os .RequestTy pe;
        23   import oas is.names.t c.xacml._2 _0.context .schema.os .ResponseT ype;
        24   import oas is.names.t c.xacml._2 _0.context .schema.os .ResultTyp e;
        25  
        26   /**
        27    * 
        28    * @author  Anand Sas try
        29    */
        30   public cla ss PDPImpl Java imple ments PDPI nterface {
        31  
        32           pr ivate stat ic final L ogger logg er = Logge r.getLogge r(PDPImplJ ava.class
        33                             .getNa me());
        34  
        35           //  Values In jected by  Spring
        36           pr ivate Stri ng localHo meCommunit yId;// = " urn:oid:2. 16.840.1.1 13883.4.34 9";
        37           pr ivate Stri ng[] noOpt InRequired HomeCommun ities;// =
        38                                                                                                                     // {"u rn:oid:2.1 6.840.1.11 3883.3.42. 10001.1000 01.12"};
        39           pr ivate Stri ng[] patie ntPurposeF orUse;// =  {"TREATME NT","EMERG ENCY"};
        40           pr ivate bool ean valida tePatientI dFormat;
        41  
        42           /* *
        43            *  Check the  XACML att ributes of  the incom ing reques t to deter mine wheth er
        44            *  the opera tion is al lowable or  not.
        45            *  
        46            *  @param re questType
        47            *  @return
        48            * /
        49           @O verride
        50           pu blic Respo nseType ch eckPolicy( final Requ estType re questType)  {
        51                    this .info("che ckPolicy",  "SimplePD P Evaluati on Begins  ...");
        52  
        53                    bool ean author ized = fal se;
        54  
        55                    if ( XACMLReque stParser.i sOutbound( requestTyp e)) {
        56                             author ized = thi s.checkPol icyOutboun d(requestT ype);
        57                    } el se if (XAC MLRequestP arser.isIn bound(requ estType))  {
        58                             author ized = thi s.checkPol icyInbound (requestTy pe);
        59                    }
        60                    /*
        61                     * T his should  not make  it here in  this iter ation of V AP1.0 Bein g
        62                     * H andled By  the Contex t Handler.
        63                     * 
        64                     * 
        65                     * e lse if (XA CMLRequest Parser.isN HINOut(req uestType))  { authori zed =
        66                     * c heckPolicy NHINOut(re questType) ; }
        67                     */
        68                    else  {
        69                             author ized = fal se;
        70                    }
        71                    this .info("che ckPolicy",  "SimplePD P Evaluati on ended." );
        72                    fina l Response Type respo nse = this .generateR esponse(au thorized);
        73                    PDPI mplJava.lo gger.exiti ng(this.ge tClass().g etName(),  "checkPoli cy",
        74                                      response .getResult ().get(0). getDecisio n());
        75                    retu rn respons e;
        76           }
        77  
        78           pr ivate bool ean checkP olicyInbou nd(final R equestType  requestTy pe) {
        79                    fina l String r equestorsH omeCommuni tyId = thi s
        80                                      .getRequ estorsHome CommunityI d(requestT ype);
        81  
        82                    fina l String r equestorsP urposeForU se = this
        83                                      .getPurp oseOfUse(r equestType );
        84                    fina l String r equestedPa tientId =  this.getPa tientId(re questType) ;
        85                    fina l String r equestedAc tion = thi s.getActio n(requestT ype);
        86  
        87                    this .info("che ckPolicyIn bound",
        88                                      "Request Type.reque storsHomeC ommunityId =["
        89                                                       +  requestors HomeCommun ityId + "] ");
        90                    this .info("che ckPolicyIn bound", "R equestType .requestor sPurposeFo rUse=["
        91                                      + reques torsPurpos eForUse +  "]");
        92                    this .info("che ckPolicyOu tbound", " requestedA ction=[" +  requested Action
        93                                      + "]");
        94  
        95                    // I I remotePa tientId =  getRemoteP atientId(r equestType );
        96                    // I I remotePa tientId =
        97                    // e xtractValu eFromResou rce(reques tType.getR esource(). get(0),
        98                    // R ESOURCE_UN IQUE_PATIE NT_ID, II. class);
        99                    // r equested H CID id VA  or allowed  home comm unities
        100  
        101                    // c heckInboun dPolicy OR IGINAL RUL E SET
        102                    // H CID is non  null
        103                    // P OU is non  null
        104                    // P ID is in a  valid ICN  format
        105                    // H CID corres ponds to D VA's HCID  OR in the  list of al lowed HCID s
        106                    // P atient is  in the MPI
        107                    // r equested P OU matches  patient s pecified P OU
        108                    // E ither OptI n is not r equired or  patient h as opted i n
        109                    // I f Transact ion is PD,  no op. Bu t if it is  DQ/DR, co rrelations  are
        110                    // e valuated.
        111  
        112                    /*
        113                     * r eturn !Nul lChecker.i sNullOrEmp ty(request orsHomeCom munityId)  &&
        114                     * ! NullChecke r.isNullOr Empty(requ estorsPurp oseForUse)  &&
        115                     * i sValidPati entId(requ estedPatie ntId) &&
        116                     * ( requestors HomeCommun ityId.ends With(getLo calHomeCom munityId() ) ||
        117                     * ( valueEndsW ithInArray (requestor sHomeCommu nityId,
        118                     * g etAllowedH omeCommuni ties()) &&  (requeste dPatientId  =
        119                     * g etPatientF romMPI(req uestedPati entId)) !=  null &&
        120                     * v alueInArra y(requesto rsPurposeF orUse,
        121                     * g etPatientP urposeForU se(request edPatientI d)) &&
        122                     * ( isNoOptInR equiredCom munity(req uestorsHom eCommunity Id) ||
        123                     * i sPatientOp tedIn(requ estedPatie ntId)) &&
        124                     * ( !(requeste dAction.eq uals("Docu mentQueryI n") ||
        125                     * r equestedAc tion.equal s("Documen tRetrieveI n")) || (r emotePatie ntId !=
        126                     * n ull && isP atientCorr elatedToRe quester(re questedPat ientId,
        127                     * r equestorsH omeCommuni tyId, remo tePatientI d)))));
        128                     */
        129  
        130                    // - ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---//
        131                    // c heckInboun dPolicy VA P 1.0 RULE  - TODO -  Validate B usiness ru le
        132                    // H CID is non  null
        133                    // P OU is non  null
        134                    // P ID is in a  valid ICN  format
        135                    // H CID corres ponds to D VA's HCID
        136                    // O R
        137                    // H CID is in  the list o f allowed  HCIDs
        138                    // N OT DOING T HIS IN VAP  1.0 - Pat ient is in  the MPI
        139                    // r equested P OU matches  patient s pecified P OU
        140                    // E ither OptI n is not r equired or  patient h as opted i n
        141                    // N OT DOING T HIS IN VAP  1.0 - If  Transactio n is PD, n o op. But  if it is
        142                    // D Q/DR, corr elations a re evaluat ed.
        143                    retu rn !NullCh ecker.isNu llOrEmpty( requestors HomeCommun ityId)
        144                                      && !Null Checker.is NullOrEmpt y(requesto rsPurposeF orUse)
        145                                      && this. isValidPat ientId(req uestedPati entId)
        146                                      && (this .isHomeCom munityLoca l(requesto rsHomeComm unityId) | | (this
        147                                                       .i sHomeCommu nityAllowe dByPatient (
        148                                                                         reques torsHomeCo mmunityId,  requestTy pe)
        149                                                       &&  this.isRe questorsPO UAllowed(r equestorsP urposeForU se) && (th is
        150                                                       .i sNoOptInRe quiredComm unity(requ estorsHome CommunityI d) || this
        151                                                       .i sPatientOp tedIn(requ estType))) );
        152           }
        153  
        154           pr ivate bool ean checkP olicyOutbo und(final  RequestTyp e requestT ype) {
        155                    fina l String r esourceHom eCommunity Id = this
        156                                      .getReso urceHomeCo mmunityId( requestTyp e);
        157  
        158                    fina l String r equestorsP urposeForU se = this
        159                                      .getPurp oseOfUse(r equestType );
        160                    fina l String r equestedPa tientId =  this.getPa tientId(re questType) ;
        161                    fina l String r equestedAc tion = thi s.getActio n(requestT ype);
        162  
        163                    this .info("che ckPolicyOu tbound",
        164                                      "Request Type.resou rceHomeCom munityId=[ "
        165                                                       +  resourceHo meCommunit yId + "]") ;
        166                    this .info("che ckPolicyOu tbound",
        167                                      "Request Type.reque storsPurpo seForUse=[ "
        168                                                       +  requestors PurposeFor Use + "]") ;
        169                    this .info("che ckPolicyOu tbound", " requestedA ction=[" +  requested Action
        170                                      + "]");
        171  
        172                    // c heckOutbou ndPolicy O RIGINAL RU LE SET
        173                    // H CID is non  null
        174                    // P OU is non  null
        175                    // R equestor's  HCID corr esponds to  DVA for D ocQuery an d Doc Retr ieve.
        176                    // F or PD, req uestor's H CID should  be in all owed hcids
        177                    // I f action i s DocQuery /DocRetrie ve we are  done
        178                    // o r else if  action is  PD
        179                    // V alidate th at Patient  id has th e correct  format
        180                    // V alidate th at the pat ient is in  the MPI
        181                    // V alidate th at the req uested pou  matches p atient spe cific pou
        182                    // V alidate if  either op t-in is re quired or  if the pat ient has o pted in.
        183                    /*
        184                     * r eturn !Nul lChecker.i sNullOrEmp ty(request orsHomeCom munityId)  &&
        185                     * ! NullChecke r.isNullOr Empty(requ estorsPurp oseForUse)  &&
        186                     * ( resourceHo meCommunit yId.endsWi th(getLoca lHomeCommu nityId())  &&
        187                     * ! requestedA ction.equa ls("Patien tDiscovery Out") ||
        188                     * ( valueEndsW ithInArray (resourceH omeCommuni tyId,
        189                     * g etAllowedH omeCommuni ties()) &&
        190                     * ( requestedA ction.equa ls("Docume ntQueryOut ") ||
        191                     * r equestedAc tion.equal s("Documen tRetrieveO ut") ||
        192                     * ( isValidPat ientId(req uestedPati entId) &&  (requested PatientId  =
        193                     * g etPatientF romMPI(req uestedPati entId)) !=  null &&
        194                     * v alueInArra y(requesto rsPurposeF orUse,
        195                     * g etPatientP urposeForU se(request edPatientI d)) &&
        196                     * ( isNoOptInR equiredCom munity(res ourceHomeC ommunityId ) ||
        197                     * i sPatientOp tedIn(requ estedPatie ntId)))))) ;
        198                     */
        199  
        200                    // - ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---//
        201                    // c heckOutbou ndPolicy V AP 1.0 rul e
        202                    // V alidate Bu siness rul e
        203                    // H CID is non  null
        204                    // P OU is non  null
        205                    // R esource HC ID corresp onds to DV A for DocQ uery and D oc Retriev e. For
        206                    // P D, request or's HCID  should be  in allowed  hcids
        207                    // I f action i s DocQuery /DocRetrie ve we are  done
        208                    // o r else if  action is  PD
        209                    // V alidate th at Patient  id has th e correct  format
        210                    // N OT DOING T HIS IN VAP  1.0 - Val idate that  the patie nt is in t he MPI
        211                    // V alidate th at the req uested pou  matches p atient spe cific pou
        212                    // V alidate if  either op t-in is re quired or  if the pat ient has o pted in.
        213                    retu rn !NullCh ecker.isNu llOrEmpty( resourceHo meCommunit yId)
        214                                      && !Null Checker.is NullOrEmpt y(requesto rsPurposeF orUse)
        215                                      && ((thi s.isHomeCo mmunityLoc al(resourc eHomeCommu nityId) &&  !requeste dAction
        216                                                       .e quals(XACM LContextCo nstants.XA CML_REQUES T_PATIENT_ DISCOVERY_ OUT_ACTION _ID_VALUE) )
        217  
        218                                      || (requ estedActio n
        219                                                       .e quals(XACM LContextCo nstants.XA CML_REQUES T_DOC_RETR IEVE_OUT_A CTION_ID_V ALUE) || ( this
        220                                                       .i sHomeCommu nityAllowe dByPatient (
        221                                                                         resour ceHomeComm unityId, r equestType ) && (requ estedActio n
        222                                                       .e quals(XACM LContextCo nstants.XA CML_REQUES T_DOC_QUER Y_OUT_ACTI ON_ID_VALU E)
        223                                      // ||
        224                                      // reque stedAction .equals(XA CMLContext Constants. XACML_REQU EST_DOC_RE TRIEVE_OUT _ACTION_ID _VALUE)
        225                                      || (this .isValidPa tientId(re questedPat ientId)
        226                                                       &&  this.isRe questorsPO UAllowed(r equestorsP urposeForU se) && (th is
        227                                                       .i sNoOptInRe quiredComm unity(reso urceHomeCo mmunityId)  || this
        228                                                       .i sPatientOp tedIn(requ estType))) ))));
        229           }
        230  
        231           //  --------- ---------- ---------- ---------- ---------- ---------- ------
        232           //  Private
        233           //  --------- ---------- ---------- ---------- ---------- ---------- ------
        234           pr ivate Resp onseType g enerateRes ponse(fina l boolean  authorized ) {
        235                    fina l Response Type respo nse = new  ResponseTy pe();
        236                    fina l List<Res ultType> r esults = r esponse.ge tResult();
        237                    fina l ResultTy pe result  = new Resu ltType();
        238                    resu lt.setDeci sion(autho rized ? De cisionType .PERMIT :  DecisionTy pe.DENY);
        239                    resu lts.add(re sult);
        240                    retu rn respons e;
        241           }
        242  
        243           pr ivate Stri ng getActi on(final R equestType  requestTy pe) {
        244                    // r eturn XACM LRequestPa rser.getRe questedAct ion(reques tType);
        245                    retu rn XACMLRe questParse r.getResou rceService Type(reque stType);
        246           }
        247  
        248           //  Data retr ieval util
        249           pr ivate Stri ng[] getAl lowedVistA Facilities (final Req uestType r equestType ) {
        250                    /*
        251                     * V AP Tracks  allowed vi sta facili ties, but  does not p ass it in  the
        252                     * r equest. IN  the futur e the PDP  can track  this. For  now, we wi ll have
        253                     * t o move thi s check to  VAP.
        254                     * 
        255                     * S tring allo wedVistAFa cilities =
        256                     * p ropertyLoo kup.getPro perty("All owedVistAF acilities" ); return
        257                     * ! NullChecke r.isNullOr Empty(allo wedVistAFa cilities)  ?
        258                     * a llowedVist AFacilitie s.split(", ") : new S tring[]{};
        259                     */
        260                    // V AP 1.0 mec hanism, al beit tempo rary, I th ink !!!
        261                    fina l List<Str ing> allow edVISTAFac ilities =  XACMLConte xtUtil
        262                                      .getReso urceAttrib uteValues(
        263                                                       re questType,
        264                                                       XA CMLContext Constants. RESOURCE_A LLOWED_VIS TA_FACILIT IES_ATTR_I D);
        265                    retu rn allowed VISTAFacil ities.toAr ray(new St ring[allow edVISTAFac ilities
        266                                      .size()] );
        267           }
        268  
        269           /* *
        270            *  @return
        271            * /
        272           pu blic Strin g getLocal HomeCommun ityId() {
        273                    retu rn this.lo calHomeCom munityId.t rim();
        274           }
        275  
        276           /* *
        277            *  @return
        278            * /
        279           pu blic Strin g[] getNoO ptInRequir edHomeComm unities()  {
        280                    retu rn this.no OptInRequi redHomeCom munities;
        281                    // r eturn new  String[] { "2.16.840. 1.113883.3 .42.10001. 100001.12"  };
        282                    // / /DOD
        283           }
        284  
        285           pr ivate Stri ng[] getPa tientAllow edHomeComm unities(fi nal Reques tType requ est) {
        286                    fina l List<Str ing> patie ntAllowedO rgs = XACM LRequestPa rser
        287                                      .getPati entAllowed HomeCommun ities(requ est);
        288                    retu rn patient AllowedOrg s
        289                                      .toArray (new Strin g[patientA llowedOrgs .size()]);
        290           }
        291  
        292           pr ivate Stri ng getPati entId(fina l RequestT ype reques tType) {
        293                    retu rn XACMLRe questParse r.getReque stedResour ceId(reque stType);
        294           }
        295  
        296           /* *
        297            *  @return
        298            * /
        299           pu blic Strin g[] getPat ientPurpos eForUse()  {
        300                    retu rn this.pa tientPurpo seForUse;  // new Str ing[] {"TR EATMENT",
        301                                                                                                   //  "EMERGENC Y" };
        302           }
        303  
        304           pr ivate Stri ng getPurp oseOfUse(f inal Reque stType req uestType)  {
        305                    retu rn XACMLRe questParse r.getReque storPurpos eOfUse(req uestType);
        306           }
        307  
        308           pr ivate Stri ng getRequ estorsHome CommunityI d(final Re questType  requestTyp e) {
        309                    // r eturn XACM LRequestPa rser.getRe questorHom eCommunity Id(request Type);
        310                    retu rn XACMLRe questParse r.getSubje ctLocality (requestTy pe);
        311           }
        312  
        313           pr ivate Stri ng getReso urceHomeCo mmunityId( final Requ estType re questType)  {
        314                    // r eturn XACM LRequestPa rser.getRe sourceHome CommunityI d(requestT ype);
        315                    retu rn XACMLRe questParse r.getEnvir onmentLoca lity(reque stType);
        316           }
        317  
        318           //  Used only  for NHINO ut
        319           pr ivate Stri ng getVist AFacilityN ame(final  RequestTyp e requestT ype) {
        320                    retu rn XACMLRe questParse r.getReque storSubjec tId(reques tType);
        321           }
        322  
        323           pr ivate void  info(fina l String m ethodName,  final Str ing messag e) {
        324                    if ( PDPImplJav a.logger.i sLoggable( Level.INFO )) {
        325                             PDPImp lJava.logg er.logp(Le vel.INFO,  this.getCl ass().getN ame(),
        326                                               methodName , message) ;
        327                    }
        328           }
        329  
        330           pr ivate bool ean isHome CommunityA llowedByPa tient(
        331                             final  String hom eCommunity Id, final  RequestTyp e requestT ype) {
        332                    bool ean isAllo wed = fals e;
        333                    if ( !NullCheck er.isNullO rEmpty(hom eCommunity Id)) {
        334                             isAllo wed = this .valueInAr ray(homeCo mmunityId,
        335                                               this.getPa tientAllow edHomeComm unities(re questType) );
        336                    }
        337                    this .info(
        338                                      "isHomeC ommunityAl lowedByPat ient",
        339                                      "Is Requ estor/Reso urce HomeC ommunityId ["
        340                                                       +  homeCommun ityId
        341                                                       +  "], an all owed Commu nity, OR,  is patient  opted-out  ? Rule Ev aluation["
        342                                                       +  isAllowed  + "]");
        343                    retu rn isAllow ed;
        344           }
        345  
        346           pr ivate bool ean isHome CommunityL ocal(final  String ho meCommunit yId) {
        347                    bool ean isLoca lRequest =  false;
        348                    if ( !NullCheck er.isNullO rEmpty(hom eCommunity Id)) {
        349                             isLoca lRequest =  homeCommu nityId.equ als(this
        350                                               .getLocalH omeCommuni tyId());
        351                    }
        352                    this .info("isH omeCommuni tyLocal",
        353                                      "Compari ng Request or/Resourc e HomeComm unityId["
        354                                                       +  homeCommun ityId + "]  with Loca lHomeCommu nityId["
        355                                                       +  this.local HomeCommun ityId + "] . Rule Eva luation["
        356                                                       +  isLocalReq uest + "]" );
        357                    retu rn isLocal Request;
        358           }
        359  
        360           pr ivate bool ean isNoOp tInRequire dCommunity (final Str ing homeCo mmunityId)  {
        361                    bool ean noOptI nRequired  = true;
        362                    if ( !NullCheck er.isNullO rEmpty(hom eCommunity Id)) {
        363                             noOptI nRequired  = this.val ueEndsWith InArray(ho meCommunit yId,
        364                                               this.getNo OptInRequi redHomeCom munities() );
        365                    }
        366                    this .info("isN oOptInRequ iredCommun ity",
        367                                      "Is Requ estor/Reso urce HomeC ommunityId [" + homeC ommunityId
        368                                                       +  "]'s opt-i n required  ? [" + !n oOptInRequ ired + "]" );
        369                    retu rn noOptIn Required;
        370           }
        371  
        372           pr ivate bool ean isPati entOptedIn (final Req uestType r equest) {
        373                    fina l List<Str ing> optIn s = XACMLC ontextUtil
        374                                      .getReso urceAttrib uteValues( request,
        375                                                       XA CMLContext Constants. RESOURCE_O PTIN_ATTR_ ID);
        376                    bool ean isPati entOptedIn  = false;
        377                    if ( (optIns !=  null) &&  (optIns.si ze() > 0))  {
        378                             isPati entOptedIn  = XACMLCo ntextConst ants.RESOU RCE_OPTIN_ YES_VALUE
        379                                               .equals(op tIns.get(0 ));
        380                    }
        381                    this .info("isP atientOpte dIn", "Opt -In Status  [" + isPa tientOpted In
        382                                      + "]");
        383                    retu rn isPatie ntOptedIn;
        384           }
        385  
        386           pr ivate bool ean isRequ estorsPOUA llowed(fin al String  requestors PurposeOfU se) {
        387                    bool ean isAllo wedPOU = f alse;
        388                    if ( !NullCheck er.isNullO rEmpty(req uestorsPur poseOfUse) ) {
        389                             isAllo wedPOU = t his.valueI nArray(req uestorsPur poseOfUse,
        390                                               this.getPa tientPurpo seForUse() );
        391                    }
        392                    this .info("isR equestorsP OUAllowed" , "Request orsPOU["
        393                                      + reques torsPurpos eOfUse + " ] is allow ed [" + is AllowedPOU
        394                                      + "]");
        395                    retu rn isAllow edPOU;
        396           }
        397  
        398           pr ivate bool ean isVali dPatientId (String pa tientId) {
        399                    this .info("isV alidPatien tId", "Pat ientId ["  + patientI d + "]");
        400                    if ( NullChecke r.isNullOr Empty(pati entId)) {
        401                             return  false;
        402                    }
        403  
        404                    if ( !this.vali datePatien tIdFormat)  {
        405                             PDPImp lJava.logg er.warning ("PatientI d Format V alidation  Disabled") ;
        406                             return  true; //  Patient Va lidation i s off
        407                    }
        408  
        409                    fina l String I CN_PATTERN  = "^\\d{1 0}(V\\d{6} )?$";
        410                    bool ean ret =  false;
        411  
        412                    pati entId = Pa tientIdUti l.parsePat ientIdFrom HL7CXType( patientId) ;
        413  
        414                    if ( !NullCheck er.isNullO rEmpty(pat ientId)
        415                                      && Patte rn.matches (ICN_PATTE RN, patien tId)) {
        416                             ret =  true;
        417                    } el se {
        418                             PDPImp lJava.logg er.warning ("patientI d (" + pat ientId
        419                                               + ") is no t a valid  ICN.");
        420                    }
        421  
        422                    retu rn ret;
        423           }
        424  
        425           /* *
        426            *  @param lo calHomeCom munityId
        427            * /
        428           pu blic void  setLocalHo meCommunit yId(final  String loc alHomeComm unityId) {
        429                    this .localHome CommunityI d = localH omeCommuni tyId;
        430           }
        431  
        432           /*
        433            *  private O bject getR emotePatie ntId(final  RequestTy pe request Type) {
        434            *  List<Obje ct> objs =
        435            *  XACMLCont extUtil.ge tResourceA ttributeOb jects(requ estType,
        436            *  XACMLCont extConstan ts.XACML_R EQUEST_RES OURCE_SUBJ ECT_ID_ATT R_ID); if
        437            *  (objs ==  null || ob js.size()  == 0) { re turn null;  } return  objs.get(0 ); }
        438            * /
        439  
        440           /* *
        441            *  @param no OptInRequi redHomeCom munities
        442            * /
        443           pu blic void  setNoOptIn RequiredHo meCommunit ies(
        444                             final  String[] n oOptInRequ iredHomeCo mmunities)  {
        445                    this .noOptInRe quiredHome Communitie s = noOptI nRequiredH omeCommuni ties;
        446           }
        447  
        448           //  Logging u tility met hods. - Re factor and  relocate  or use AOP
        449  
        450           /* *
        451            *  @param pa tientPurpo seOfUse
        452            * /
        453           pu blic void  setPatient PurposeOfU se(final S tring[] pa tientPurpo seOfUse) {
        454                    this .patientPu rposeForUs e = patien tPurposeOf Use;
        455           }
        456  
        457           pr ivate bool ean valueE ndsWithInA rray(final  String va lue,
        458                             final  String[] a rray) {
        459                    bool ean ret =  false;
        460                    fina l String t oUpperValu e = value. toUpperCas e(Locale.E NGLISH).tr im();
        461  
        462                    for  (final Str ing s : ar ray) {
        463                             ret =  (s.trim(). equals("*" ) || toUpp erValue.en dsWith(s.t rim()
        464                                               .toUpperCa se(Locale. ENGLISH))) ;
        465                             if (re t) {
        466                                      break;
        467                             }
        468                    }
        469  
        470                    retu rn ret;
        471           }
        472  
        473           //  Utility m ethods
        474           pr ivate bool ean valueI nArray(fin al String  value, fin al String[ ] array) {
        475                    bool ean ret =  false;
        476  
        477                    for  (final Str ing s : ar ray) {
        478                             ret =  (s.trim(). equals("*" ) || s.tri m().equals IgnoreCase (
        479                                               value.trim ()));
        480                             if (re t) {
        481                                      break;
        482                             }
        483                    }
        484  
        485                    retu rn ret;
        486           }
        487  
        488           pr ivate bool ean valueS tartsWithI nArray(fin al String  value,
        489                             final  String[] a rray) {
        490                    bool ean ret =  false;
        491                    fina l String t oUpperValu e = value. toUpperCas e().trim() ;
        492  
        493                    for  (final Str ing s : ar ray) {
        494                             ret =  (s.trim(). equals("*" ) || toUpp erValue.st artsWith(s .trim()
        495                                               .toUpperCa se(Locale. ENGLISH))) ;
        496                             if (re t) {
        497                                      break;
        498                             }
        499                    }
        500  
        501                    retu rn ret;
        502           }
        503  
        504           //  --------- ---------- ---------- ---------- -----
        505           //  OLD Artif acts - Del ete
        506           /*
        507            *  private b oolean isP atientOpte dIn(String  patientId ) { // Ori ginal
        508            *  Implement ation Pati ent patien t =
        509            *  patientMa nager.getP atientByIC N(patientI d); return  patient ! = null &&
        510            *  patient.g etExpirati on().after (new Date( )); }
        511            *  
        512            *  private b oolean isP atientCorr elatedToRe quester(St ring patie ntId, Stri ng
        513            *  homeCommu nityId, Ob ject remot ePatientId ) { boolea n ret = fa lse;
        514            *  
        515            *  Facility  facility =
        516            *  facilityM anager.get FacilityBy HomeCommun ityId(stri pDecoratio ns
        517            *  (homeComm unityId));  if (facil ity != nul l) { DataQ uery dataQ uery =
        518            *  getDataMa nager().ge tQuery("MP I.findNHIN Correlatio ns");
        519            *  dataQuery .setParame ter("icn",  patientId );
        520            *  dataQuery .setParame ter("corre latedFacil ityNumber" ,
        521            *  facility. getFacilit yNumber()) ; List<Map > results  =
        522            *  dataQuery .getResult s(); for ( Map result  : results ) { String
        523            *  correlate dPatientId  = (String )result.ge t("correla tedPatient Id"); Stri ng
        524            *  correlate dAssigning Authority  =
        525            *  (String)r esult.get( "correlate dAssigning Authority" ); if
        526            *  (correlat edAssignin gAuthority .equals(re motePatien tId.getRoo t()) &&
        527            *  correlate dPatientId .equals(re motePatien tId.getExt ension()))  { ret = t rue;
        528            *  break; }  } } else {  ret = fal se; }
        529            *  
        530            *  return re t; }
        531            *  
        532            *  private S tring stri pDecoratio ns(String  homeCommun ityId) { S tring ret;
        533            *  
        534            *  if (homeC ommunityId .startsWit h("urn:oid :")) { ret  =
        535            *  homeCommu nityId.sub string(8);  } else {  ret = home CommunityI d; }
        536            *  
        537            *  return re t; }
        538            *  
        539            *  private S tring getP atientFrom MPI(String  patientId ) { String  ret = nul l;
        540            *  DataQuery  dataQuery  = getData Manager(). getQuery(" MPI.findDe mographics ");
        541            *  dataQuery .setParame ter("icn",
        542            *  PatientId FormatUtil .parsePati entId(pati entId)); L ist<Map> r esults =
        543            *  dataQuery .getResult s(); if (! NullChecke r.isNullOr Empty(resu lts)) { St ring
        544            *  pid = (St ring)resul ts.get(0). get("MRN") ; if (!pat ientId.sta rtsWith(pi d))
        545            *  { logger. severe("In put patien tId (" + p atientId +
        546            *  ") does n ot match M PI patient Id (" + pi d + ").  C heck confi guration." ); }
        547            *  else { re t = pid; }  } else {  logger.war ning("pati entId (" +  patientId  +
        548            *  ") is not  in the MP I."); }
        549            *  
        550            *  return re t; }
        551            *  
        552            *  
        553            *  private D ataManager  getDataMa nager() {  return
        554            *  DataManag erFactory. getDataMan ager
        555            *  (property Lookup.get Property(" dataManage rConfigFil ename"));  }
        556            * /
        557   }