/*
// -----------------------------------------------------------------------
// 
// Copyright (c) 2001-2009, MeVis Medical Solutions AG, Bremen, Germany
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of MeVis Medical Solutions AG nor the
//       names of its contributors may be used to endorse or promote products
//       derived from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY MEVIS MEDICAL SOLUTIONS AG ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL MEVIS MEDICAL SOLUTIONS AG BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//-----------------------------------------------------------------------------
//! DICOMUIDGenerator.js
/*!
// \file    DICOMUIDGenerator.js
// \date    07/2003
*/
//-----------------------------------------------------------------------------

function initUIDGenerator() {
  var system = MLAB.systemId();

  switch (system) {
  case "windows": 
    ctx.field("deviceType").setValue(3);
    break;
  case "macos": 
    ctx.field("deviceType").setValue(2);
    break;
  case "unix": 
    ctx.field("deviceType").setValue(4);
    break;
  case "unknown": 
    ctx.field("deviceType").setValue(4);
  }
}

function createUID() {
  var myUID = "";
  
  myUID += ctx.field("prefix").stringValue();
  myUID += ".";
  myUID += ctx.field("deviceType").stringValue();
  myUID += ".";
  myUID += ctx.field("deviceNumber").intValue();
  myUID += ".";
  myUID += ctx.field("softwareTypeID").intValue();
  myUID += ".";
  myUID += ctx.field("softwareVersion").intValue();
  myUID += ".";
  myUID += ctx.field("freestyle").intValue();
  myUID += ".";

  // add a timestamp with millisecond resolution
  myUID += MLABTimeUtils.timeStamp("yyyyMMddhhmmsszzz");

  ctx.field("UID").setStringValue(myUID);
  return myUID;
}

//# MeVis signature v1
//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
//# owner: MeVis
//# date: 2009-05-09T05:37:18
//# hash: fvHgqnCDm1fFKpFiM7dgTKbiFZeUs7zSE7d2x5wT+o94H3v1h2jq95DVM5v7HSTOIt80jLYxigDHhrw5myQbdA==
//# MeVis end
