<?xsltforms-options debug="no" lang="en"?>
<!--
   Copyright 2012, XML Solutions.  All rights reserved.
   
   Licensed under the Artistic License: 
   http://www.opensource.org/licenses/artistic-license.php
 -->
<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <meta charset="utf-8"></meta>
    <title>forms4health</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
    <meta name="description" content=""></meta>
    <meta name="author" content=""></meta>

    <link href="css/bootstrap.css" rel="stylesheet"></link>
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet"></link>
    <link href="css/xform-styling.css" rel="stylesheet"></link>

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    
    
    <!-- XForms model & controller -->
    <xf:model id="booking">
         
          <xf:instance id="booking-document" src="booking-model.xml"/>         
          <xf:submission id="save" method="post" mediatype="text/xml" replace="none" resource="book" omit-xml-declaration="false">
             <xf:action  ev:event="xforms-submit-error">
                <!-- xf:dispatch name="xforms-invalid" targetid="email"/-->
                <!-- xf:message level="modal">A submission error occurred (<xf:output value="event('error-type')"/>). <xf:output value="choose(event('response-body'), event('response-body'), '')"/></xf:message-->
                <xf:setvalue bind="WarningMessage" value="choose(event('response-body'), event('response-body'), event('error-type'))"/>            
             </xf:action>
             <xf:action ev:event="xforms-submit-done">
                <xf:toggle case="letter"/>
             </xf:action>
          </xf:submission>
          
           <xf:bind id="CallBackEmail"
                   nodeset="instance('booking-document')/call-back-email"
                   required="true()"
                   type="xf:email"/>
           
           <xf:bind id="DeliveryFormat"
                   nodeset="instance('booking-document')/delivery-format"
                   type="xs:string"/>
                   
           <xf:bind id="BookingCount"
                   calculate="count(instance('booking-document')/bookings/booking[normalize-space(.) != ''])"
                   nodeset="instance('booking-document')/bookings/@booking-count"
                   type="xs:string"/>
                   
           <xf:bind id="FirstBookingRef"
                   nodeset="instance('booking-document')/bookings/booking[1]"
                   type="xs:string"/>
           
           <xf:setfocus ev:event="xforms-ready" control="email"/>
       </xf:model>
       <xf:model id="reference-data">
          <xf:instance id="formats" src="reference-data/supported-formats.xml"/>
       </xf:model>
       <xf:model id="warning-messages">
           <xf:instance id="header-warning-message">
              <message></message>
           </xf:instance>
           <xf:bind id="WarningMessage"
                    nodeset="instance('header-warning-message')"
                    relevant="normalize-space(.) != ''"/>
       </xf:model>
  </head>

  <body>

    <div id="navbar-example" class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-inner">
          <div class="container">
            <a class="brand" href="/">forms4health</a>
            <ul class="nav" role="navigation">
              <ul class="nav">
          <li><a href="overview.xml">process overview</a></li>
          <li><a href="features.xml">features</a></li> 
          <li class="divider-vertical"></li>
          <li class="active"><a href="registration.xml">book</a></li>
          <li><a href="preop.xml">patient form</a></li>
        </ul>
            </ul>
            <ul class="nav pull-right">
              <li id="fat-menu" class="dropdown">
                <a href="#" id="drop3" role="button" class="dropdown-toggle" data-toggle="dropdown">other forms <b class="caret"></b></a>
                <ul class="dropdown-menu" role="menu" aria-labelledby="drop3">
                  <li><a href="preop.xml">pre-op assessment</a></li>
                  <li><a href="aaa.xml">AAA screening enrolment</a></li>
                  <li class="divider"></li>
                  <li><a href="registration.xml">booking</a></li>
                </ul>
              </li>
            </ul>
          </div>
        </div>
      </div>

    <div class="container">
      <xf:switch>
         <xf:case id="registration">
             <div class="row">
                <div class="span3">
                     <h2><span class="label label-success label-large">1</span> Book</h2>
                    <p>A healthcare administrator <strong>books</strong> the assessment (or similar electronic form) via the service, providing unique booking references for each patient. The references are known only to the healthcare organisation creating the booking. The administrator also provides a return email address and selects the delivery format for the completed forms.</p>
                </div>
                <div class="span1"></div>
                <div class="span8">
                         <xf:group bind="WarningMessage">
                            <p class="alert alert-error form-section">
			                     <a href="#" class="close" data-dismiss="alert">×</a>
			                     Please correct the following:
			                     <strong><xf:output value="."/></strong>
			                 </p>
                         </xf:group>
			             <h3>Delivery Preferences</h3>
			             <xf:group class="well form-section">
			                 <xf:input id="email" bind="CallBackEmail" class="input-large">
			                    <xf:label>Please enter the email address for completed forms to be delivered to</xf:label>
			                    <xf:alert>The entered email address is not valid.</xf:alert>
			                 </xf:input>
			                 <xf:select1  bind="DeliveryFormat" appearance="full">
			                     <xf:label>Please specify the delivery format</xf:label>
			                     <xf:itemset nodeset="instance('formats')/choice" model="reference-data">
			                         <xf:label ref="displayName"/>
			                         <xf:value ref="code"/>
			                     </xf:itemset>
			                </xf:select1>       
			            </xf:group>         
			            <h3>Booking References</h3>
			            <xf:group xmlns:xs="http://www.w3.org/2001/XMLSchema" class="well form-section">
			               <xf:label>Please enter the unique booking reference(s) for your patient(s)</xf:label>   
			               <xf:repeat nodeset="instance('booking-document')/bookings/booking" id="booking-repeat" appearance="full">
			                  
			                  <div class="input-append">
			                     <xf:input ref="." incremental="true"/>
			                     <xf:trigger ref=".[count(instance('booking-document')/bookings/booking) > 1]" class="add-on btn-danger">
			                        <xf:label>x</xf:label>
			                        <xf:delete nodeset="instance('booking-document')/bookings/booking"
			                                   at="index('booking-repeat')"
			                                   ev:event="DOMActivate"/>
			                     </xf:trigger>
			                  </div>
			               </xf:repeat> 
			               <xf:trigger class="btn btn-info btn-small">
			                  <xf:label>additional reference</xf:label>
			                  <xf:action ev:event="DOMActivate">
			                     <xf:insert nodeset="instance('booking-document')/bookings/booking"
			                                position="after"
			                                at="count(instance('booking-document')/bookings/booking)"/>
			                     <xf:setvalue ref="instance('booking-document')/bookings/booking[last()]"
			                                  value="''"/>
			                  </xf:action>
			               </xf:trigger> 
			            </xf:group>
			             <div class="page-control">
			                 <!-- xf:trigger class="btn-large btn-primary" ref=".[count(instance('booking-document')/bookings/booking[normalize-space(.) != '']) > 0 and instance('booking-document')/call-back-email[normalize-space(.) != '']]"-->
			                 <xf:trigger class="btn-large btn-primary">
			                   <xf:label>Book »</xf:label>
			                   <xf:action ev:event="DOMActivate">
			                        <xf:dispatch name="xforms-submit" targetid="save"/>                    
			                   </xf:action>               
			                </xf:trigger>            
			            </div>
                </div>
            </div>
         </xf:case>
         <xf:case id="letter">
             <div class="row">
                <div class="span3">
                     <h2><span class="label label-success label-large">2</span> Letter</h2>
                    <p>A <strong>letter</strong> is posted out to the patient including their unique booking reference. The patient letter typically also contains alternative options for completing the assessment/form such as telephone or face-to-face consultation.</p>
                </div>
                <div class="span1"></div>
                <div class="span8">
             <xf:group>
                <div class="letter well">
	                <div class="rhs">
	                    <img class="letter-logo" src="img/NHS-RGB.jpeg" width="100px"/>
	                    <span class="line">YourEfficientHealthTrust</span>
	                    <span class="line">GleemingHospital</span>
	                    <span class="line">Somewhere</span>
	                    <span class="line"></span>
	                    <span class="line">10th October 2012</span>
	                </div>
	                <div class="letter-body">
	                    <span class="line">Dear Mr Bloggs,</span><br/>
	                    <span class="line">You have been scheduled for surgery on the 20th October 2012. Before your surgery, we require you to complete a questionnaire. This can be done online, or alternatively please contact 01234 567890 to arrange an appointment at the pre-operative assessment clinic.</span>
	                </div>
	                <div class="letter-body reference-number alert alert-success">
	                    <span class="line">To complete the assessment online please go to <a href="preop.xml">http://www.formsforhealth.co.uk</a></span>
	                    <span class="line"></span>
	                    <span class="line">Your reference Id is <strong><xf:output bind="FirstBookingRef"/></strong></span>                    
	                </div>
	                <div class="letter-body">
	                    <span class="line">None of your information is stored online - once completed the information will be sent directly to the hospital for review by the anaesthetist.</span>
	                </div>
	                <div class="letter-body">
	                    Yours sincerely,<br/>
	                    Pre-operative assessment team
	                </div>
                </div>
             </xf:group>
             <a class="btn-large btn-primary page-control" href="preop.xml">Continue »</a>
             
             </div>
           </div>
         </xf:case>
       </xf:switch>
      

    </div> <!-- /container -->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>


    
  </body>
</html>
