291. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/5/2017 4:22:07 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.

291.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\SpecProcessor\src\main\java\gov\va\ccd\components\transform SubstanceAdminTransformer.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\SpecProcessor\src\main\java\gov\va\ccd\components\transform SubstanceAdminTransformer.java Mon Apr 3 14:39:07 2017 UTC

291.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 6 1222
Changed 5 10
Inserted 0 0
Removed 0 0

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

291.4 Active regular expressions

No regular expressions were active.

291.5 Comparison detail

  1   package go v.va.ccd.c omponents. transform;
  2  
  3   import gov .va.ccd.se rvice.util .Utils;
  4  
  5   import jav a.util.Has hMap;
  6   import jav a.util.Lis t;
  7   import jav a.util.Map ;
  8  
  9   import org .apache.co mmons.coll ections.Co llectionUt ils;
  10   import org .apache.co mmons.lang 3.StringUt ils;
  11   import org .eclipse.e mf.common. util.EList ;
  12   import org .openhealt htools.mdh t.uml.cda. Act;
  13   import org .openhealt htools.mdh t.uml.cda. Author;
  14   import org .openhealt htools.mdh t.uml.cda. EntryRelat ionship;
  15   import org .openhealt htools.mdh t.uml.cda. Observatio n;
  16   import org .openhealt htools.mdh t.uml.cda. StrucDocTe xt;
  17   import org .openhealt htools.mdh t.uml.cda. SubstanceA dministrat ion;
  18   import org .openhealt htools.mdh t.uml.cda. Supply;
  19   import org .openhealt htools.mdh t.uml.hl7. datatypes. CD;
  20   import org .openhealt htools.mdh t.uml.hl7. datatypes. EIVL_TS;
  21   import org .openhealt htools.mdh t.uml.hl7. datatypes. IVL_TS;
  22   import org .openhealt htools.mdh t.uml.hl7. datatypes. PIVL_TS;
  23   import org .openhealt htools.mdh t.uml.hl7. datatypes. PQ;
  24   import org .openhealt htools.mdh t.uml.hl7. datatypes. RTO_PQ_PQ;
  25   import org .openhealt htools.mdh t.uml.hl7. datatypes. SXCM_TS;
  26   import org .openhealt htools.mdh t.uml.hl7. vocab.SetO perator;
  27   import org .openhealt htools.mdh t.uml.hl7. vocab.x_Ac tRelations hipEntryRe lationship ;
  28   import org .openhealt htools.mdh t.uml.hl7. vocab.x_Do cumentSubs tanceMood;
  29  
  30   public cla ss Substan ceAdminTra nsformer
  31   {
  32           /* *
  33            *  Loops thr ough all o f the entr y relation ships to f ind specif ic items.
  34            *  
  35            *  @param re sults
  36            *  @param su bAdm
  37            *  @param na rrative
  38            *  @see #pro cessFulfil lment(Map,  EntryRela tionship,  StrucDocTe xt)
  39            *  @see #pro cessMedInd ication(Ma p, EntryRe lationship , StrucDoc Text)
  40            *  @see #pro cessMedSta tus(Map, E ntryRelati onship, St rucDocText )
  41            *  @see #pro cessMedTyp e(Map, Ent ryRelation ship, Stru cDocText)
  42            *  @see #pro cessOrder( Map, Entry Relationsh ip, StrucD ocText)
  43            *  @see #pro cessPatIns tructions( Map, Entry Relationsh ip, StrucD ocText)
  44            *  @see #pro cessReacti on(Map, En tryRelatio nship, Str ucDocText)
  45            * /
  46           pu blic stati c void map EntryRels( final Map< String, Ob ject> resu lts, final  Substance Administra tion subAd m, final S trucDocTex t narrativ e)
  47           {
  48                    if(s ubAdm != n ull)
  49                    {
  50                             EList< EntryRelat ionship> r els = subA dm.getEntr yRelations hips();
  51                             for(En tryRelatio nship rel  : rels)
  52                             {
  53                                      processF ulfillment (results,  rel, narra tive);
  54                                      processO rder(resul ts, rel, n arrative);
  55                                      processP atInstruct ions(resul ts, rel, n arrative);
  56                                      processR eaction(re sults, rel , narrativ e);
  57                                      processM edType(res ults, rel,  narrative );
  58                                      processM edIndicati on(results , rel, nar rative);
  59                                      processM edStatus(r esults, re l, narrati ve);
  60                             }
  61                    }
  62           }
  63  
  64           /* *
  65            *  Maps the  original t ext from t he entryRe l/Obs for  instructio ns into it s
  66            *  own map a nd then pl aces it in  results k ey <b>inst ructions</ b>
  67            *  {@link Tr ansformer# mapOrigina lText(Map,  String, o rg.openhea lthtools.m dht.uml.hl 7.datatype s.ED, Stru cDocText)}
  68            *  
  69            *  @param re sults
  70            *  @param re l
  71            *  @param na rrative
  72            *  @see Tran sformer#ma pOriginalT ext(Map, S tring,
  73            *       org. openhealth tools.mdht .uml.hl7.d atatypes.E D, StrucDo cText)
  74            * /
  75           pu blic stati c void pro cessPatIns tructions( final Map< String, Ob ject> resu lts, final  EntryRela tionship r el, StrucD ocText nar rative)
  76           {
  77                    if(r el != null )
  78                    {
  79                             Act ac t = rel.ge tAct();
  80                              if(act !=  null && Ut ils.contai nsTemplate Id(act.get TemplateId s(), "2.16 .840.1.113 883. IP          "))
  81                             {
  82                                      Map<Stri ng, Object > instruct ions = new  HashMap<S tring, Obj ect>();
  83                                      Transfor mer.mapOri ginalText( instructio ns, "", ac t.getText( ), narrati ve);
  84                                      if(!inst ructions.i sEmpty())
  85                                      {
  86                                               results.pu t("instruc tions", in structions );
  87                                      }
  88                             }
  89  
  90                    }
  91           }
  92  
  93           /* *
  94            *  Will add  a map a va lue like a  code for  <b>medType </b> using
  95            *  {@link Tr ansformer# mapWrapped Code(Map,  String, CD , StrucDoc Text)}
  96            *  
  97            *  @param re sults
  98            *  @param re l
  99            *  @param na rrative
  100            * /
  101           pu blic stati c void pro cessMedTyp e(final Ma p<String,  Object> re sults, fin al EntryRe lationship  rel, Stru cDocText n arrative)
  102           {
  103                    if(r el != null  && x_ActR elationshi pEntryRela tionship.S UBJ.equals (rel.getTy peCode()))
  104                    {
  105                             Observ ation obs  = rel.getO bservation ();
  106  
  107                             if(obs  != null & & Utils.co ntainsTemp lateId(obs .getTempla teIds(), " 2.16.840.1 .113883.3. 88.11.83.8 .1"))
  108                             {
  109                                      Transfor mer.mapObs ValueOrCod e(results,  "medType" , obs, nar rative);
  110                             }
  111                    }
  112           }
  113  
  114           /* *
  115            *  Will add  a map a va lue like a  code for  <b>medStat us</b> usi ng
  116            *  {@link Tr ansformer# mapWrapped Code(Map,  String, CD , StrucDoc Text)}
  117            *  
  118            *  @param re sults
  119            *  @param re l
  120            *  @param na rrative
  121            * /
  122           pu blic stati c void pro cessMedSta tus(final  Map<String , Object>  results, f inal Entry Relationsh ip rel, St rucDocText  narrative )
  123           {
  124                    if(r el != null  && x_ActR elationshi pEntryRela tionship.R EFR.equals (rel.getTy peCode()))
  125                    {
  126                             Observ ation obs  = rel.getO bservation ();
  127  
  128                              if(obs !=  null && Ut ils.contai nsTemplate Id(obs.get TemplateId s(), "2.16 .840.1.113 883. IP          "))
  129                             {
  130                                      Transfor mer.mapObs ValueOrCod e(results,  "medStatu s", obs, n arrative);
  131                             }
  132                    }
  133           }
  134  
  135           /* *
  136            *  * Will ad d a map a  value like  a code fo r <b>medIn dication</ b> using
  137            *  {@link Tr ansformer# mapWrapped Code(Map,  String, CD , StrucDoc Text)}
  138            *  
  139            *  @param re sults
  140            *  @param re l
  141            *  @param na rrative
  142            * /
  143           pu blic stati c void pro cessMedInd ication(fi nal Map<St ring, Obje ct> result s, final E ntryRelati onship rel , StrucDoc Text narra tive)
  144           {
  145                    if(r el != null  && x_ActR elationshi pEntryRela tionship.R SON.equals (rel.getTy peCode()))
  146                    {
  147                             Observ ation obs  = rel.getO bservation ();
  148  
  149                              if(obs !=  null && Ut ils.contai nsTemplate Id(obs.get TemplateId s(), "2.16 .840.1.113 883. IP          "))
  150                             {
  151                                      Transfor mer.mapObs ValueOrCod e(results,  "medIndic ation", ob s, narrati ve);
  152                             }
  153                    }
  154           }
  155  
  156           /* *
  157            *  Maps the  original t ext from t he entryRe l/Obs for  reaction i nto result s
  158            *  key <b>re action</b>
  159            *  {@link Tr ansformer# mapOrigina lText(Map,  String, o rg.openhea lthtools.m dht.uml.hl 7.datatype s.ED, Stru cDocText)}
  160            *  
  161            *  @param re sults
  162            *  @param re l
  163            *  @param na rrative
  164            * /
  165           pu blic stati c void pro cessReacti on(final M ap<String,  Object> r esults, fi nal EntryR elationshi p rel, Str ucDocText  narrative)
  166           {
  167                    if(r el != null )
  168                    {
  169                             Observ ation obs  = rel.getO bservation ();
  170  
  171                              if(obs !=  null && Ut ils.contai nsTemplate Id(obs.get TemplateId s(), "2.16 .840.1.113 883. IP          "))
  172                             {
  173                                      Map<Stri ng, Object > reaction  = new Has hMap<Strin g, Object> ();
  174                                      Transfor mer.mapOri ginalText( reaction,  "", obs.ge tText(), n arrative);
  175                                      if(!reac tion.isEmp ty())
  176                                      {
  177                                               results.pu t("reactio n", reacti on);
  178                                      }
  179                             }
  180  
  181                    }
  182           }
  183  
  184           /* *
  185            *  <pre>
  186            *  Creates a  map <b>fu lfillment< /b> in res ults from  EntryRel/a ct.  With  the follow ing object s in the m ap:
  187            *  <ul>
  188            *  <li>{@lin k Transfor mer#mapOri ginalText( Map, Strin g, org.ope nhealthtoo ls.mdht.um l.hl7.data types.ED,  StrucDocTe xt)} of Te xt block.< /li>
  189            *  <li>{@lin k Transfor mer#mapIds (Map, List )} of all  the ids.</ li>
  190            *  <li>{@lin k Transfor mer#mapPQV alue(Map,  String, or g.openheal thtools.md ht.uml.hl7 .datatypes .PQ, Struc DocText)}  for <b>qua ntity</b>< /li>
  191            *  <li>{@lin k Transfor mer#mapEff ectiveTime (Map, org. openhealth tools.mdht .uml.hl7.d atatypes.S XCM_TS)} f or the fir st availab le effecti veTime</li >
  192            *  <li>{@lin k Transfor mer#mapPer formers(Ma p, String,  EList)} f or Provide r/Pharmacy  Informati on</li>
  193            *  <li>{@lin k Transfor mer#mapWra ppedCode(M ap, String , CD, Stru cDocText)}  for <b>fi llStatus</ b></li>
  194            *  <li>{@lin k Transfor mer#mapStr ing(Map, S tring, Str ing)} for  <b>fillNum ber</b></l i>
  195            *  
  196            *  </ul>
  197            *  </pre>
  198            *  
  199            *  @param re sults
  200            *  @param re l
  201            *  @param na rrative
  202            * /
  203           pu blic stati c void pro cessFulfil lment(fina l Map<Stri ng, Object > results,  final Ent ryRelation ship rel,  StrucDocTe xt narrati ve)
  204           {
  205                    if(r el != null )
  206                    {
  207                             Act ac t = rel.ge tAct();
  208                              if(act !=  null && Ut ils.contai nsTemplate Id(act.get TemplateId s(), "2.16 .840.1.113 883. IP          "))
  209                             {
  210                                      if(rel.g etSupply()  != null)
  211                                      {
  212                                               Supply sup ply = rel. getSupply( );
  213                                               if(x_Docum entSubstan ceMood.EVN .equals(su pply.getMo odCode()))
  214                                               {
  215                                                       Ma p<String,  Object> fu lfill = ne w HashMap< String, Ob ject>();
  216                                                       //  Fulfillme nt instruc tions
  217                                                       Tr ansformer. mapOrigina lText(fulf ill, "", a ct.getText (), narrat ive);
  218                                                       //  This is t he item we  are looki ng for for  Order
  219                                                       //  informati on.
  220                                                       Tr ansformer. mapIds(ful fill, supp ly.getIds( ));
  221                                                       //  Quantity
  222                                                       Tr ansformer. mapPQValue (fulfill,  "quantity" , supply.g etQuantity (), narrat ive);
  223                                                       //  Get the f irst effec tive time  if availab le.
  224                                                       if (Collectio nUtils.isN otEmpty(su pply.getEf fectiveTim es()))
  225                                                       {
  226                                                                Tran sformer.ma pEffective Time(fulfi ll, supply .getEffect iveTimes() .get(0));
  227                                                       }
  228                                                       //  Get Provi der/Pharma cy informa tion
  229                                                       Tr ansformer. mapPerform ers(fulfil l, "", sup ply.getPer formers()) ;
  230                                                       Tr ansformer. mapWrapped Code(fulfi ll, "fillS tatus", su pply.getSt atusCode() , narrativ e);
  231  
  232                                                       if (Collectio nUtils.isN otEmpty(su pply.getEn tryRelatio nships()))
  233                                                       {
  234                                                                for( EntryRelat ionship en tryRel : s upply.getE ntryRelati onships())
  235                                                                {
  236                                                                         if(x_A ctRelation shipEntryR elationshi p.COMP.equ als(entryR el.getType Code()))
  237                                                                         {
  238                                                                                  // fillN umber
  239                                                                                  Transfor mer.mapStr ing(fulfil l, "fillNu mber", ent ryRel.getS equenceNum ber().getV alue().toS tring());
  240                                                                         }
  241                                                                }
  242                                                       }
  243                                                       if (!fulfill. isEmpty())
  244                                                       {
  245                                                                resu lts.put("f ulfillment ", fulfill );
  246                                                       }
  247                                               }
  248                                      }
  249                             }
  250                    }
  251           }
  252  
  253           /* *
  254            *  <pre>
  255            *  Creates a n <b>order </b> in re sults from  EntryRel/ supply.  W ith the fo llowing ob jects in e ach map:
  256            *  <ul>
  257            *  <li>{@lin k Transfor mer#mapIds (Map, List )} of all  the ids.</ li>
  258            *  <li>{@lin k Transfor mer#mapStr ing(Map, S tring, Str ing)} for  <b>fill</b ></li>
  259            *  <li>{@lin k Transfor mer#mapPQV alue(Map,  String, or g.openheal thtools.md ht.uml.hl7 .datatypes .PQ, Struc DocText)}  for <b>qua ntity</b>< /li>
  260            *  <li>{@lin k Transfor mer#mapEff ectiveTime (Map, org. openhealth tools.mdht .uml.hl7.d atatypes.S XCM_TS)} f or the fir st availab le effecti veTime</li >
  261            *  <li>{@lin k Transfor mer#mapEff ectiveTime (Map, org. openhealth tools.mdht .uml.hl7.d atatypes.T S)} into a  map then  into resul ts as <b>o rderTime</ b></li>
  262            *  <li>{@lin k Transfor mer#mapStr ing(Map, S tring, Str ing)} to a dd <b>prov ider</b> n ames</li>
  263            *  
  264            *  </ul>
  265            *  </pre>
  266            *  
  267            *  @param re sults
  268            *  @param re l
  269            *  @param na rrative
  270            * /
  271           pu blic stati c void pro cessOrder( final Map< String, Ob ject> resu lts, final  EntryRela tionship r el, StrucD ocText nar rative)
  272           {
  273                    if(r el != null  && rel.ge tSupply()  != null)
  274                    {
  275                             Supply  supply =  rel.getSup ply();
  276                             if(x_A ctRelation shipEntryR elationshi p.REFR.equ als(rel.ge tTypeCode( )) && x_Do cumentSubs tanceMood. INT.equals (supply.ge tMoodCode( )))
  277                             {
  278                                      Map<Stri ng, Object > order =  new HashMa p<String,  Object>();
  279                                      // This  is the ite m we are l ooking for  for Order  informati on.
  280                                      Transfor mer.mapIds (order, su pply.getId s());
  281                                      // Fills
  282                                      if(suppl y.getRepea tNumber()  != null &&  supply.ge tRepeatNum ber().getV alue() !=  null)
  283                                      {
  284                                               Transforme r.mapStrin g(order, " fill", sup ply.getRep eatNumber( ).getValue ().toStrin g());
  285                                      }
  286                                      // Quant ity
  287                                      Transfor mer.mapPQV alue(order , "quantit y", supply .getQuanti ty(), narr ative);
  288                                      // Get t he first e ffective t ime if ava ilable.
  289                                      if(Colle ctionUtils .isNotEmpt y(supply.g etEffectiv eTimes()))
  290                                      {
  291                                               Transforme r.mapEffec tiveTime(o rder, supp ly.getEffe ctiveTimes ().get(0)) ;
  292                                      }
  293                                      if(Colle ctionUtils .isNotEmpt y(supply.g etAuthors( )))
  294                                      {
  295                                               Author aut hor = supp ly.getAuth ors().get( 0);
  296                                               Map<String , Object>  orderTime  = new Hash Map<String , Object>( );
  297                                               Transforme r.mapEffec tiveTime(o rderTime,  author.get Time());
  298                                               if(!orderT ime.isEmpt y())
  299                                               {
  300                                                       or der.put("o rderTime",  orderTime );
  301                                               }
  302                                               if(author. getAssigne dAuthor()  != null &&  author.ge tAssignedA uthor().ge tAssignedP erson() !=  null)
  303                                               {
  304                                                       St ring name  = Transfor mer.create Names(auth or.getAssi gnedAuthor ().getAssi gnedPerson ().getName s());
  305                                                       if (StringUti ls.isNotBl ank(name))
  306                                                       {
  307                                                                Tran sformer.ma pString(or der, "prov ider", nam e);
  308                                                       }
  309                                               }
  310                                      }
  311  
  312                                      if(!orde r.isEmpty( ))
  313                                      {
  314                                               results.pu t("order",  order);
  315                                      }
  316                             }
  317                    }
  318           }
  319  
  320           pu blic stati c void map SubstanceT imes(final  Map<Strin g, Object>  results,  final Subs tanceAdmin istration  subAdm, St rucDocText  narrative )
  321           {
  322                    if(s ubAdm != n ull && Col lectionUti ls.isNotEm pty(subAdm .getEffect iveTimes() ))
  323                    {
  324  
  325                    }
  326           }
  327  
  328           pu blic stati c void map SubstanceE ffectiveTi mes(final  SubstanceA dministrat ion subAdm in, final  Map<String , Object>  results)
  329           {
  330                    Stri ngBuilder  ret = new  StringBuil der();
  331  
  332                    for( SXCM_TS ti me : subAd min.getEff ectiveTime s())
  333                    {
  334                             if(tim e instance of PIVL_TS )
  335                             {
  336                                      ret.appe nd(process PIVL((PIVL _TS) time) ).append("  ");
  337                             }
  338                             else i f(time ins tanceof EI VL_TS)
  339                             {
  340                                      ret.appe nd(process EIVL((EIVL _TS) time) ).append("  ");
  341                             }
  342                             else i f(time ins tanceof IV L_TS)
  343                             {
  344                                      ret.appe nd(process IVL((IVL_T S) time, r esults)).a ppend(" ") ;
  345                             }
  346                             else i f(StringUt ils.isNotB lank(time. getValue() ))
  347                             {
  348                                      // Fall  through te st
  349                                      ret.appe nd("Once o n " + time .getValue( ));
  350                             }
  351                    }
  352  
  353                    if(r et.length( ) > 0)
  354                    {
  355                             result s.put("adm inTiming",  ret.toStr ing());
  356                    }
  357           }
  358  
  359           /* *
  360            *  Will set  Indicate m ed stopped  only if t ime.getHig h != null  and
  361            *  time.getL ow == null
  362            *  
  363            *  Otherwise  this will  return th e time str ing for in dicating t iming.
  364            *  
  365            *  @param ti me
  366            *  @param vo
  367            *  @return
  368            * /
  369           pr ivate stat ic String  processIVL (final IVL _TS time,  final Map< String, Ob ject> resu lts)
  370           {
  371                    if(t ime == nul l)
  372                    {
  373                             return  StringUti ls.EMPTY;
  374                    }
  375                    Stri ng timeLow ;
  376                    Stri ng timeHig h;
  377  
  378                    if(t ime.getLow () != null )
  379                    {
  380                             timeLo w = time.g etLow().ge tValue();
  381                    }
  382                    else
  383                    {
  384                             timeLo w = String Utils.EMPT Y;
  385                    }
  386  
  387                    if(t ime.getHig h() != nul l)
  388                    {
  389                             timeHi gh = time. getHigh(). getValue() ;
  390                    }
  391                    else
  392                    {
  393                             timeHi gh = Strin gUtils.EMP TY;
  394                    }
  395  
  396                    if(S tringUtils .isNotBlan k(timeHigh ) && Strin gUtils.isB lank(timeL ow))
  397                    {
  398                             // Ind icate MedS topped
  399                             result s.put("med Stopped",  timeHigh);
  400                             return  StringUti ls.EMPTY;
  401                    }
  402  
  403                    if(S tringUtils .isNotBlan k(timeLow)  && String Utils.isNo tBlank(tim eHigh))
  404                    {
  405                             return  "From: "  + timeLow  + " To: "  + timeHigh ;
  406                    }
  407  
  408                    if(S tringUtils .isNotBlan k(time.get Value()))
  409                    {
  410                             return  "Once on  " + time.g etValue();
  411                    }
  412  
  413                    if(S tringUtils .isNotBlan k(timeLow) )
  414                    {
  415                             return  "From: "  + timeLow;
  416                    }
  417  
  418                    retu rn StringU tils.EMPTY ;
  419           }
  420  
  421           pr ivate stat ic String  processPIV L(final PI VL_TS time )
  422           {
  423                    if(t ime == nul l)
  424                    {
  425                             return  null;
  426                    }
  427  
  428                    Stri ngBuilder  effectiveT ime = new  StringBuil der();
  429  
  430                    if(t ime.getOpe rator() !=  null && t ime.getOpe rator().eq uals(SetOp erator.A)  && time.ge tPeriod()  != null &&  time.getP eriod().ge tValue() ! = null)
  431                    {
  432                             if(tim e.getInsti tutionSpec ified() &&  "h".equal sIgnoreCas e(time.get Period().g etUnit()))
  433                             {
  434                                      Double v alue = tim e.getPerio d().getVal ue().doubl eValue();
  435                                      Double p eriod = 0. 0;
  436                                      if(value  != null)
  437                                      {
  438                                               if(value <  1.0)
  439                                               {
  440                                                       pe riod = 24. 0 * value;
  441                                               }
  442                                               else
  443                                               {
  444                                                       pe riod = 24. 0 / value;
  445                                               }
  446                                      }
  447  
  448                                      effectiv eTime.appe nd(period) ;
  449                                      effectiv eTime.appe nd(" ");
  450                                      effectiv eTime.appe nd("time(s ) a day");
  451                             }
  452                             else
  453                             {
  454                                      effectiv eTime.appe nd("every  ");
  455                                      effectiv eTime.appe nd(time.ge tPeriod(). getValue() );
  456                                      effectiv eTime.appe nd(" ");
  457                                      effectiv eTime.appe nd(time.ge tPeriod(). getUnit()) .append("  ");
  458                                      String p hase = pro cessPhase( time.getPh ase());
  459                                      if(Strin gUtils.isN otBlank(ph ase))
  460                                      {
  461                                               effectiveT ime.append ("for ").a ppend(phas e).append( " ");
  462                                      }
  463  
  464                             }
  465                    }
  466                    else  if(time.g etPhase()  != null)
  467                    {
  468                             effect iveTime.ap pend(" ");
  469                             effect iveTime.ap pend("for  ");
  470                             effect iveTime.ap pend(proce ssPhase(ti me.getPhas e()));
  471                    }
  472                    retu rn effecti veTime.toS tring().tr im();
  473           }
  474  
  475           pr ivate stat ic String  processPha se(final I VL_TS phas e)
  476           {
  477                    Stri ngBuilder  sb = new S tringBuild er();
  478  
  479                    if(p hase != nu ll)
  480                    {
  481                             sb.app end(phase. getWidth() .getValue( ));
  482                             sb.app end(" ");
  483                             sb.app end(phase. getWidth() .getUnit() );
  484  
  485                             if(pha se.getLow( ) != null)
  486                             {
  487                                      String t ime = phas e.getLow() .getValue( );
  488                                      if(Strin gUtils.isN otBlank(ti me))
  489                                      {
  490                                               sb.append( " at ");
  491                                               sb.append( time.subst ring(time. length() -  4));
  492                                      }
  493                             }
  494                    }
  495                    retu rn sb.toSt ring().tri m();
  496           }
  497  
  498           pr ivate stat ic String  processEIV L(final EI VL_TS time )
  499           {
  500                    if(t ime == nul l)
  501                    {
  502                             return  null;
  503                    }
  504  
  505                    Stri ngBuilder  ret = new  StringBuil der();
  506  
  507                    if(S etOperator .A.equals( time.getOp erator()))
  508                    {
  509                             if(tim e.getEvent () != null  && String Utils.isNo tBlank(tim e.getEvent ().getCode ()))
  510                             {
  511                                      // Cycle  through a ll of the  possible c ode values  to get th e
  512                                      // prope r return.
  513                                      if("AC". equalsIgno reCase(tim e.getEvent ().getCode ()))
  514                                      {
  515                                               ret.append ("before m eal");
  516                                      }
  517                                      else if( "ACD".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  518                                      {
  519                                               ret.append ("before l unch");
  520                                      }
  521                                      else if( "ACM".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  522                                      {
  523                                               ret.append ("before b reakfast") ;
  524                                      }
  525                                      else if( "ACV".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  526                                      {
  527                                               ret.append ("before d inner");
  528                                      }
  529                                      else if( "HS".equal sIgnoreCas e(time.get Event().ge tCode()))
  530                                      {
  531                                               ret.append ("hour of  sleep");
  532                                      }
  533                                      else if( "IC".equal sIgnoreCas e(time.get Event().ge tCode()))
  534                                      {
  535                                               ret.append ("between  meals");
  536                                      }
  537                                      else if( "ICD".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  538                                      {
  539                                               ret.append ("between  lunch and  dinner");
  540                                      }
  541                                      else if( "ICM".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  542                                      {
  543                                               ret.append ("between  breakfast  and lunch" );
  544                                      }
  545                                      else if( "ICV".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  546                                      {
  547                                               ret.append ("between  dinner and  hour of s leep");
  548                                      }
  549                                      else if( "PC".equal sIgnoreCas e(time.get Event().ge tCode()))
  550                                      {
  551                                               ret.append ("after me al");
  552                                      }
  553                                      else if( "PCD".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  554                                      {
  555                                               ret.append ("after lu nch");
  556                                      }
  557                                      else if( "PCM".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  558                                      {
  559                                               ret.append ("after br eakfast");
  560                                      }
  561                                      else if( "PCV".equa lsIgnoreCa se(time.ge tEvent().g etCode()))
  562                                      {
  563                                               ret.append ("after di nner");
  564                                      }
  565                             }
  566                             if(ret .length()  > 1)
  567                             {
  568                                      return r et.toStrin g();
  569                             }
  570                    }
  571                    retu rn null;
  572           }
  573  
  574           pu blic stati c void map DoseRestri ction(fina l Substanc eAdministr ation subA dmin, fina l Map<Stri ng, Object > results)
  575           {
  576                    fina l RTO_PQ_P Q maxDoseQ nty = subA dmin.getMa xDoseQuant ity();
  577  
  578                    fina l StringBu ilder maxD oseString  = new Stri ngBuilder( );
  579  
  580                    if(m axDoseQnty  != null)
  581                    {
  582  
  583                             if(max DoseQnty.g etNumerato r() != nul l)
  584                             {
  585                                      PQ num =  maxDoseQn ty.getNume rator();
  586                                      if(num.g etValue()  != null)
  587                                      {
  588                                               maxDoseStr ing.append (num.getVa lue().toSt ring());
  589                                      }
  590                                      if(Strin gUtils.isN otBlank(nu m.getUnit( )))
  591                                      {
  592                                               maxDoseStr ing.append (num.getUn it());
  593                                      }
  594                             }
  595  
  596                             if(max DoseQnty.g etDenomina tor() != n ull)
  597                             {
  598                                      maxDoseS tring.appe nd(" / ");
  599                                      if(maxDo seQnty.get Denominato r().getVal ue() != nu ll)
  600                                      {
  601                                               maxDoseStr ing.append (maxDoseQn ty.getDeno minator(). getValue() .toString( ));
  602                                      }
  603                                      if(Strin gUtils.isN otBlank(ma xDoseQnty. getDenomin ator().get Unit()))
  604                                      {
  605                                               maxDoseStr ing.append (maxDoseQn ty.getDeno minator(). getUnit()) ;
  606                                      }
  607                             }
  608                    }
  609  
  610                    if(m axDoseStri ng.length( ) > 0)
  611                    {
  612                             result s.put("dos eRestricti on", maxDo seString.t oString()) ;
  613                    }
  614           }
  615  
  616   }