@import com.pharmpress.common.model.dmd.Vmp
@import views.DmdHelper

@(dmd: String, vmp: Vmp)

@dmdMain {
  <div class="page-header" ng-init="controller.loadAmpsAndVmpps('@dmd', '@vmp.id')">
  <h1>Virtual Medicinal Product</h1>
    </div>
  <table class="table table-striped">
    <tr><td>ID</td><td>@vmp.id</td></tr>
    <tr><td>Valid date</td><td>@vmp.validDate</td></tr>
    <tr><td>Previous ID</td><td>@vmp.idPrev</td></tr>
    <tr><td>Virtual therapeutic moiety</td><td>
      @if(vmp.vtmId.nonEmpty) {
        <a href="/@dmd/vtm/@vmp.vtmId.get">@vmp.vtmId</a>
      }
    </td></tr>
    <tr><td>Invalid</td><td>@vmp.invalid</td></tr>

    <tr><td>Name                </td><td>@vmp.name               </td></tr>
    <tr><td>Abbreviated name          </td><td>@vmp.abbrevName         </td></tr>
    <tr><td>BasisOfName         </td><td>@vmp.basisOfName        </td></tr>
    <tr><td>NameDate            </td><td>@vmp.nameDate           </td></tr>
    <tr><td>NamePrev            </td><td>@vmp.namePrev           </td></tr>
    <tr><td>BasisOfNamePrev     </td><td>@vmp.basisOfNamePrev    </td></tr>
    <tr><td>NameChangeReason    </td><td>@vmp.nameChangeReason   </td></tr>
    <tr><td>CombProd            </td><td>@vmp.combProd           </td></tr>
    <tr><td>PresStatus          </td><td>@vmp.presStatus         </td></tr>
    <tr><td>Sugar free?</td><td>@DmdHelper.boolean(vmp.sugarFree)</td></tr>
    <tr><td>Gluten free?</td><td>@DmdHelper.boolean(vmp.glutenFree)</td></tr>
    <tr><td>Preservative free?</td><td>@DmdHelper.boolean(vmp.preservativeFree)</td></tr>
    <tr><td>CFC free?</td><td>@DmdHelper.boolean(vmp.cfcFree)</td></tr>
    <tr><td>Non-availability indicator</td><td>@vmp.nonAvailable</td></tr>
    <tr><td>Non-availablilty date</td><td>@vmp.nonAvailableDate</td></tr>
    <tr><td>Dose form indicator</td><td>@vmp.dfInd</td></tr>
    <tr><td>Unit dose form size</td><td>@vmp.udfs</td></tr>
    <tr><td>Unit dose form units</td><td>@vmp.udfsUOM</td></tr>
    <tr><td>Unit dose form unit of measure</td><td>@vmp.unitDoseUOM</td></tr>
    <tr><td>Ontology form and route</td><td>@vmp.ontDrugForm.map(_.map(_.form).mkString(", "))</td></tr>
    <tr><td>Form</td><td>@vmp.drugForm.map(_.form)</td></tr>
    <tr><td>Route</td><td>@vmp.drugRoute.map(_.map(_.route).mkString(", "))</td></tr>
  </table>

  @if(vmp.virtualProductIngredients.nonEmpty) {
    <h2>Virtual Product Ingredients</h2>
    <table class="table table-striped">
      <tr>
        <th>Substance</th>
        <th>Basis of strength</th>
        <th>Basis substance</th>
        <th>Strength numerator</th>
        <th>Strength numerator unit</th>
        <th>Strength denominator</th>
        <th>Strength denominator unit</th>
      </tr>
      @for(ingredient <- vmp.virtualProductIngredients.get) {
        <tr>
          <td>@ingredient.ingredientSubstance.name</td>
          <td>@ingredient.basisStrength</td>
          <td>@ingredient.basisSubstance.map(_.name)</td>
          <td>@ingredient.strengthNumeratorVal</td>
          <td>@ingredient.strengthNumeratorUOM</td>
          <td>@ingredient.strengthDenominatorVal</td>
          <td>@ingredient.strengthDenominatorUOM</td>
        </tr>
      }
    </table>
  }

  <h2>Controlled Drug Information</h2>
  <table class="table table-striped">
    <tr><td>Category</td><td>@vmp.controlDrugInfo.category</td></tr>
    <tr><td>Category date</td><td>@vmp.controlDrugInfo.categoryDate</td></tr>
    <tr><td>Previous category</td><td>@vmp.controlDrugInfo.categoryPrev</td></tr>
  </table>

  <h2>Actual Medicinal Products</h2>
  <table class="table table-striped">
    <tr ng-repeat="amp in amps | orderBy: 'title'">
      <td>{{amp.id}}</td><td><a href="/@dmd/amp/{{amp.id}}">{{amp.title}}</a></td>
    </tr>
  </table>

  <h2>Virtual Medicinal Product Packs</h2>
  <table class="table table-striped">
    <tr ng-repeat="vmpp in vmpps | orderBy: 'title'">
      <td>{{vmpp.id}}</td><td><a href="/@dmd/vmpp/{{vmpp.id}}">{{vmpp.title}}</a></td>
    </tr>
  </table>
}