 
 messageStore = require "../middleware/messageStore"
 Transaction = require("../model/transactions").Transaction
-router = require "../middleware/router"
+Client = require("../model/clients").Client
+Authorisation = require "../middleware/authorisation"
+Router = require "../middleware/router"
 
 
 




          


          Transaction.findOne
            _id: transactionID
          , (err, transaction) ->
            console.log(transaction)


          ###
          ctx = new Object()
          ctx.path = "/api/test/request"
          ctx.header =
            headerName: "headerValue"
            "Content-Type": "application/json"            
            "Content-Length": "9313219921"

          ctx.querystring = "param1=value1&param2=value2"
          ctx.body = "<HTTP body>"
          ctx.method = "POST"

          ctx.status = "Processing"
          ctx.authenticated = new Object()
          ctx.authenticated.clientID = "Master_OpenMRS_Instance"

          messageStore.storeTransaction ctx, (error, result) ->
            router.route ctx ->

              res = new Object()
              res.status = "200"
              res.headers =
                header: "value"
                header2: "value2"
              res.body = "<HTTP response>"
              res.timestamp = new Date()

              messageStore.storeTransaction ctx ->
            ###












              ###
              # This is code we had originally for the router call and the transaction update save
              Client.findOne clientID: transaction.clientID, (err, client) ->
                #console.log(client)

                ctx.authenticated = new Object()
                ctx.authenticated = client

                Q.denodeify ->
                  Authorisation.authorise ctx, (error, authorise) -> 
                    console.log(authorise);
                    
                    Router.route ctx, (error, router) ->

                      console.log(router);

                      
                      messageStore.storeTransaction ctx, (error, updateMessage) ->
                      
                        console.log(updateMessage);  
              ### 



