Changeset 3925


Ignore:
Timestamp:
May 10, 2016, 4:59:33 PM (5 years ago)
Author:
olle
Message:

Refs #525. INCA importer updated to only use a single *.csv file for import. Unused functionality is removed, in order to simplify the code and user interface:

  1. Javascript file import-inca.js in resources/personal/ updated:
    a. Function initializeStep2(response) updated to obtain a JSONObject fileProp from JSON key "incaFileProperties", instead of a JSONArray filePropArray from JSON key "incaFilePropertiesArray".
    b. Function createTableHeader() updated to have no argument.
    c. Functions fetchTableRowStatus(...), createTableRow(...), and createTableRow2(...) updated to take first argument JSONObject instead of a JSONArray.
  2. Java servlet class/file IncaServlet.java in src/net/sf/basedb/reggie/servlet/ updated:
    a. Protected method void doPost(HttpServletRequest req, HttpServletResponse resp) updated for command "ImportInca" by using the first (= the only) input file for import. Data are now stored for later use in JSONObjects instead of JSONArrays.
    b. Private method LineDatabaseMappingResult lineDatabaseMapping(DbControl dc, List<PotentialIncaImportLine> potentialIncaImportLines, ...) updated by removing arguments int fileNo and int numFiles, since they are no longer needed for the progress report calculation.
    c. Private method String createIncaImportReportFile(JSONArray jsonIncaFilePropDetailsArr, List<String> missingIncaHeadersList, String message) updated by exchanging first argument JSONArray jsonIncaFilePropDetailsArr for JSONObject jsonIncaFilePropDetails.
Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/personal/import-inca.js

    r3920 r3925  
    134134   
    135135    // INCA file properties - basic check
    136     var filePropArray = response.incaFilePropertiesArray;
     136    var fileProp = response.incaFileProperties;
    137137    var simpleCheckOnly = response.simpleCheckOnly;
    138138
    139     // List names of files
     139    // Print name of file
    140140    var filelisttext = '';
    141     for (var i = 0; i < filePropArray.length; i++)
    142     {
    143       var tmpFileProp = filePropArray[i];
    144       var tmpFilename = tmpFileProp.filename;
    145       filelisttext += '<b>&nbsp;File&nbsp;' + (i+1) + ':&nbsp;' + tmpFilename + '</b><br>';
    146     }
     141    var tmpFilename = fileProp.filename;
     142    filelisttext += '<b>&nbsp;File:&nbsp;' + tmpFilename + '</b><br>';
    147143    Doc.element('incafilenames').innerHTML = filelisttext;
    148144
     
    153149
    154150    // Table header
    155     basicchecktabletext += iport.createTableHeader(filePropArray);
     151    basicchecktabletext += iport.createTableHeader();
    156152
    157153    // # Header columns
    158     var numHeaderColumnsOk = iport.fetchTableRowStatus(filePropArray, 'numHeaderColumns', 'lt', 3);
    159     basicchecktabletext += iport.createTableRow(filePropArray, '# Header columns', 'numHeaderColumns', numHeaderColumnsOk, 'error', '&#8805; 3 allowed');
     154    var numHeaderColumnsOk = iport.fetchTableRowStatus(fileProp, 'numHeaderColumns', 'lt', 3);
     155    basicchecktabletext += iport.createTableRow(fileProp, '# Header columns', 'numHeaderColumns', numHeaderColumnsOk, 'error', '&#8805; 3 allowed');
    160156
    161157    // # Lines of data
    162     var numLinesOk = iport.fetchTableRowStatus(filePropArray, 'numLines', 'lt', 1);
    163     basicchecktabletext += iport.createTableRow(filePropArray, '# Lines of data', 'numLines', numLinesOk, 'error', '');
     158    var numLinesOk = iport.fetchTableRowStatus(fileProp, 'numLines', 'lt', 1);
     159    basicchecktabletext += iport.createTableRow(fileProp, '# Lines of data', 'numLines', numLinesOk, 'error', '');
    164160
    165161    // # Lines with internal line feeds
    166     var numLinesWithLineFeedsOk = iport.fetchTableRowStatus(filePropArray, 'numLinesWithLineFeeds', 'gt', 0);
    167     basicchecktabletext += iport.createTableRow(filePropArray, '# Lines with internal line feeds', 'numLinesWithLineFeeds', numLinesWithLineFeedsOk, 'warning', '');
     162    var numLinesWithLineFeedsOk = iport.fetchTableRowStatus(fileProp, 'numLinesWithLineFeeds', 'gt', 0);
     163    basicchecktabletext += iport.createTableRow(fileProp, '# Lines with internal line feeds', 'numLinesWithLineFeeds', numLinesWithLineFeedsOk, 'warning', '');
    168164
    169165    // # Lines with too many columns
    170     var numLinesWithTooManyColumnsOk = iport.fetchTableRowStatus(filePropArray, 'numLinesWithTooManyColumns', 'gt', 0);
    171     basicchecktabletext += iport.createTableRow(filePropArray, '# Lines with too many columns', 'numLinesWithTooManyColumns', numLinesWithTooManyColumnsOk, 'error', '0 allowed');
     166    var numLinesWithTooManyColumnsOk = iport.fetchTableRowStatus(fileProp, 'numLinesWithTooManyColumns', 'gt', 0);
     167    basicchecktabletext += iport.createTableRow(fileProp, '# Lines with too many columns', 'numLinesWithTooManyColumns', numLinesWithTooManyColumnsOk, 'error', '0 allowed');
    172168
    173169    // # Lines with too few columns
    174     var numLinesWithTooFewColumnsOk = iport.fetchTableRowStatus(filePropArray, 'numLinesWithTooFewColumns', 'gt', 0);
    175     basicchecktabletext += iport.createTableRow(filePropArray, '# Lines with too few columns', 'numLinesWithTooFewColumns', numLinesWithTooFewColumnsOk, 'error', '0 allowed');
     170    var numLinesWithTooFewColumnsOk = iport.fetchTableRowStatus(fileProp, 'numLinesWithTooFewColumns', 'gt', 0);
     171    basicchecktabletext += iport.createTableRow(fileProp, '# Lines with too few columns', 'numLinesWithTooFewColumns', numLinesWithTooFewColumnsOk, 'error', '0 allowed');
    176172
    177173    //
     
    185181
    186182    // Table header
    187     internalchecktabletext += iport.createTableHeader(filePropArray);
     183    internalchecktabletext += iport.createTableHeader();
    188184
    189185    // # Duplicate header columns
    190     var numHeaderDuplicatesOk = iport.fetchTableRowStatus(filePropArray, 'numHeaderDuplicates', 'gt', 0);
    191     internalchecktabletext += iport.createTableRow(filePropArray, '# Duplicate header columns', 'numHeaderDuplicates', numHeaderDuplicatesOk, 'error', '0 allowed');
     186    var numHeaderDuplicatesOk = iport.fetchTableRowStatus(fileProp, 'numHeaderDuplicates', 'gt', 0);
     187    internalchecktabletext += iport.createTableRow(fileProp, '# Duplicate header columns', 'numHeaderDuplicates', numHeaderDuplicatesOk, 'error', '0 allowed');
    192188
    193189    // Temporary patient ID column index
    194     var tempPatIdClmIndexOk = iport.fetchTableRowStatus(filePropArray, 'tempPatIdClmIndex', 'lt', 0);
    195     internalchecktabletext += iport.createTableRow(filePropArray, 'Temporary patient ID column index', 'tempPatIdClmIndex', tempPatIdClmIndexOk, 'error', '&#8805; 0 allowed');
     190    var tempPatIdClmIndexOk = iport.fetchTableRowStatus(fileProp, 'tempPatIdClmIndex', 'lt', 0);
     191    internalchecktabletext += iport.createTableRow(fileProp, 'Temporary patient ID column index', 'tempPatIdClmIndex', tempPatIdClmIndexOk, 'error', '&#8805; 0 allowed');
    196192
    197193    // Personal number column index
    198     var personalNoClmIndexOk = iport.fetchTableRowStatus(filePropArray, 'personalNoClmIndex', 'lt', 0);
    199     internalchecktabletext += iport.createTableRow(filePropArray, 'Personal number column index', 'personalNoClmIndex', personalNoClmIndexOk, 'error', '&#8805; 0 allowed');
     194    var personalNoClmIndexOk = iport.fetchTableRowStatus(fileProp, 'personalNoClmIndex', 'lt', 0);
     195    internalchecktabletext += iport.createTableRow(fileProp, 'Personal number column index', 'personalNoClmIndex', personalNoClmIndexOk, 'error', '&#8805; 0 allowed');
    200196
    201197    // Laterality description column index
    202     var lateralityDescriptionClmIndexOk = iport.fetchTableRowStatus(filePropArray, 'lateralityDescriptionClmIndex', 'lt', 0);
    203     internalchecktabletext += iport.createTableRow(filePropArray, 'Laterality description column index', 'lateralityDescriptionClmIndex', lateralityDescriptionClmIndexOk, 'error', '&#8805; 0 allowed');
     198    var lateralityDescriptionClmIndexOk = iport.fetchTableRowStatus(fileProp, 'lateralityDescriptionClmIndex', 'lt', 0);
     199    internalchecktabletext += iport.createTableRow(fileProp, 'Laterality description column index', 'lateralityDescriptionClmIndex', lateralityDescriptionClmIndexOk, 'error', '&#8805; 0 allowed');
    204200
    205201    // # Unknown headers
    206     var numUnknownHeadersOk = iport.fetchTableRowStatus(filePropArray, 'numUnknownHeaders', 'gt', 0);
    207     internalchecktabletext += iport.createTableRow(filePropArray, '# Unknown headers', 'numUnknownHeaders', numUnknownHeadersOk, 'warning', 'Columns skipped');
     202    var numUnknownHeadersOk = iport.fetchTableRowStatus(fileProp, 'numUnknownHeaders', 'gt', 0);
     203    internalchecktabletext += iport.createTableRow(fileProp, '# Unknown headers', 'numUnknownHeaders', numUnknownHeadersOk, 'warning', 'Columns skipped');
    208204
    209205    // # Data lines with personal no.
    210     var numPersonalNoLinesOk = iport.fetchTableRowStatus(filePropArray, 'numPersonalNoLines', 'eq', 0);
    211     internalchecktabletext += iport.createTableRow(filePropArray, '# Data lines with personal no.', 'numPersonalNoLines', numPersonalNoLinesOk, 'error', 'Required for import');
     206    var numPersonalNoLinesOk = iport.fetchTableRowStatus(fileProp, 'numPersonalNoLines', 'eq', 0);
     207    internalchecktabletext += iport.createTableRow(fileProp, '# Data lines with personal no.', 'numPersonalNoLines', numPersonalNoLinesOk, 'error', 'Required for import');
    212208
    213209    // # Personal no. with more than 2 lines
    214     var numPersonalNoWithMoreThanTwoLinesOk = iport.fetchTableRowStatus(filePropArray, 'numPersonalNoWithMoreThanTwoLines', 'gt', 0);
    215     internalchecktabletext += iport.createTableRow(filePropArray, '# Personal no. with more than 2 lines', 'numPersonalNoWithMoreThanTwoLines', numPersonalNoWithMoreThanTwoLinesOk, 'warning', 'Data lines skipped');
     210    var numPersonalNoWithMoreThanTwoLinesOk = iport.fetchTableRowStatus(fileProp, 'numPersonalNoWithMoreThanTwoLines', 'gt', 0);
     211    internalchecktabletext += iport.createTableRow(fileProp, '# Personal no. with more than 2 lines', 'numPersonalNoWithMoreThanTwoLines', numPersonalNoWithMoreThanTwoLinesOk, 'warning', 'Data lines skipped');
    216212
    217213    // # Personal no.s with many identical lateralities
    218     var numPersonalNoWithManyIdenticalLateralityLinesOk = iport.fetchTableRowStatus(filePropArray, 'numPersonalNoWithManyIdenticalLateralityLines', 'gt', 0);
    219     internalchecktabletext += iport.createTableRow(filePropArray, '# Personal no.s with many identical lateralities', 'numPersonalNoWithManyIdenticalLateralityLines', numPersonalNoWithManyIdenticalLateralityLinesOk, 'warning', 'Data lines skipped');
     214    var numPersonalNoWithManyIdenticalLateralityLinesOk = iport.fetchTableRowStatus(fileProp, 'numPersonalNoWithManyIdenticalLateralityLines', 'gt', 0);
     215    internalchecktabletext += iport.createTableRow(fileProp, '# Personal no.s with many identical lateralities', 'numPersonalNoWithManyIdenticalLateralityLines', numPersonalNoWithManyIdenticalLateralityLinesOk, 'warning', 'Data lines skipped');
    220216
    221217    //
     
    244240
    245241      // Table header
    246       consistencychecktabletext += iport.createTableHeader(filePropArray);
     242      consistencychecktabletext += iport.createTableHeader();
    247243
    248244      // # Data lines with personal no. not in database
    249       var numDataLinesWithoutDatabaseReferenceOk = iport.fetchTableRowStatus(filePropArray, 'numDataLinesWithoutDatabaseReference', 'gt', 0);
    250       consistencychecktabletext += iport.createTableRow(filePropArray, '# Data lines with personal no. not in database', 'numDataLinesWithoutDatabaseReference', numDataLinesWithoutDatabaseReferenceOk, 'warning', 'Data lines skipped');
     245      var numDataLinesWithoutDatabaseReferenceOk = iport.fetchTableRowStatus(fileProp, 'numDataLinesWithoutDatabaseReference', 'gt', 0);
     246      consistencychecktabletext += iport.createTableRow(fileProp, '# Data lines with personal no. not in database', 'numDataLinesWithoutDatabaseReference', numDataLinesWithoutDatabaseReferenceOk, 'warning', 'Data lines skipped');
    251247
    252248      // # Patient lateralities without database reference
    253       var numPatientLateralitiesWithoutDatabaseReferenceOk = iport.fetchTableRowStatus(filePropArray, 'numPatientLateralitiesWithoutDatabaseReference', 'gt', 0);
    254       consistencychecktabletext += iport.createTableRow(filePropArray, '# Patient lateralities without database reference', 'numPatientLateralitiesWithoutDatabaseReference', numPatientLateralitiesWithoutDatabaseReferenceOk, 'warning', 'Data lines skipped');
     249      var numPatientLateralitiesWithoutDatabaseReferenceOk = iport.fetchTableRowStatus(fileProp, 'numPatientLateralitiesWithoutDatabaseReference', 'gt', 0);
     250      consistencychecktabletext += iport.createTableRow(fileProp, '# Patient lateralities without database reference', 'numPatientLateralitiesWithoutDatabaseReference', numPatientLateralitiesWithoutDatabaseReferenceOk, 'warning', 'Data lines skipped');
    255251
    256252      // # Data lines with bad values
    257       var numBadValueLinesOk = iport.fetchTableRowStatus(filePropArray, 'numBadValueLines', 'gt', 0);
    258       consistencychecktabletext += iport.createTableRow(filePropArray, '# Data lines with bad values', 'numBadValueLines', numBadValueLinesOk, 'warning', 'Data lines skipped');
     253      var numBadValueLinesOk = iport.fetchTableRowStatus(fileProp, 'numBadValueLines', 'gt', 0);
     254      consistencychecktabletext += iport.createTableRow(fileProp, '# Data lines with bad values', 'numBadValueLines', numBadValueLinesOk, 'warning', 'Data lines skipped');
    259255
    260256      //
     
    306302    if (!simpleCheckOnly)
    307303    {
    308       var numDataLinesForImport = 0;
    309       var numPersonalNoLines = 0;
    310       for (var i = 0; i < filePropArray.length; i++)
    311       {
    312         var tmpFileProp = filePropArray[i];
    313         numDataLinesForImport += tmpFileProp.numDataLinesForImport;
    314         numPersonalNoLines += tmpFileProp.numPersonalNoLines;
    315       }
     304      var numDataLinesForImport = fileProp.numDataLinesForImport;
     305      numPersonalNoLines = fileProp.numPersonalNoLines;
    316306      text += "&nbsp;# Data lines for import = " + numDataLinesForImport + " of " + numPersonalNoLines + "<br><br>";
    317307    }
     
    359349  }
    360350
    361   iport.createTableHeader = function(filePropArr)
     351  iport.createTableHeader = function()
    362352  {
    363353    // Table header
     
    365355    text += '<tr>';
    366356    text += '<th class="propertycolumn">Property</th>';
    367     for (var i = 0; i < filePropArr.length; i++)
    368     {
    369       text += '<th class="valuecolumn">File&nbsp;' + (i+1) + '</th>';
    370     }
     357    text += '<th class="valuecolumn">Value</th>';
    371358    text += '<th class="statuscolumn">Status</th>';
    372359    text += '<th>Comment</th>';
     
    375362  }
    376363
    377   iport.fetchTableRowStatus = function(filePropArr, clmKey, failOperator, failLimit)
     364  iport.fetchTableRowStatus = function(tmpFileProp, clmKey, failOperator, failLimit)
    378365  {
    379366    var valuesOk = true;
    380     for (var i = 0; i < filePropArr.length; i++)
    381     {
    382       var tmpFileProp = filePropArr[i];
    383       var value = tmpFileProp[clmKey];
    384       if (failOperator == 'eq')
     367    var value = tmpFileProp[clmKey];
     368    if (failOperator == 'eq')
     369    {
     370      if (value == failLimit)
    385371      {
    386         if (value == failLimit)
    387         {
    388           valuesOk = false;
    389         }
     372        valuesOk = false;
    390373      }
    391       else if (failOperator == 'lt')
     374    }
     375    else if (failOperator == 'lt')
     376    {
     377      if (value < failLimit)
    392378      {
    393         if (value < failLimit)
    394         {
    395           valuesOk = false;
    396         }
     379        valuesOk = false;
    397380      }
    398       else if (failOperator == 'gt')
     381    }
     382    else if (failOperator == 'gt')
     383    {
     384      if (value > failLimit)
    399385      {
    400         if (value > failLimit)
    401         {
    402           valuesOk = false;
    403         }
     386        valuesOk = false;
    404387      }
    405388    }
     
    407390  }
    408391
    409   iport.createTableRow = function(filePropArr, title, clmKey, status, alertType, cmt)
     392  iport.createTableRow = function(tmpFileProp, title, clmKey, status, alertType, cmt)
    410393  {
    411394    // Table row
     
    413396    text += '<tr>';
    414397    text += '<td class="propertycolumn">' + title + '</td>';
    415     for (var i = 0; i < filePropArr.length; i++)
    416     {
    417       var tmpFileProp = filePropArr[i];
    418       var value = tmpFileProp[clmKey];
    419       text += '<td class="valuecolumn">' + value + '</td>';
    420     }
     398    var value = tmpFileProp[clmKey];
     399    text += '<td class="valuecolumn">' + value + '</td>';
    421400    var statusTag = iport.fetchValidityIcon(status, alertType);
    422401    text += '<td class="statuscolumn">' + statusTag + '</td>';
     
    426405  }
    427406
    428   iport.createTableRow2 = function(filePropArr, title, clmKey, failOperator, failLimit, alertType, cmt)
     407  iport.createTableRow2 = function(tmpFileProp, title, clmKey, failOperator, failLimit, alertType, cmt)
    429408  {
    430409    // Table row
     
    433412    text += '<td class="propertycolumn">' + title + '</td>';
    434413    var valuesOk = true;
    435     for (var i = 0; i < filePropArr.length; i++)
    436     {
    437       var tmpFileProp = filePropArr[i];
    438       var value = tmpFileProp[clmKey];
    439       text += '<td class="valuecolumn">' + value + '</td>';
    440       if (failOperator == 'eq')
     414    var value = tmpFileProp[clmKey];
     415    text += '<td class="valuecolumn">' + value + '</td>';
     416    if (failOperator == 'eq')
     417    {
     418      if (value == failLimit)
    441419      {
    442         if (value == failLimit)
    443         {
    444           valuesOk = false;
    445         }
     420        valuesOk = false;
    446421      }
    447       else if (failOperator == 'lt')
     422    }
     423    else if (failOperator == 'lt')
     424    {
     425      if (value < failLimit)
    448426      {
    449         if (value < failLimit)
    450         {
    451           valuesOk = false;
    452         }
     427        valuesOk = false;
    453428      }
    454       else if (failOperator == 'gt')
     429    }
     430    else if (failOperator == 'gt')
     431    {
     432      if (value > failLimit)
    455433      {
    456         if (value > failLimit)
    457         {
    458           valuesOk = false;
    459         }
     434        valuesOk = false;
    460435      }
    461436    }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/IncaServlet.java

    r3923 r3925  
    265265        Date incaImportDate = calImport.getTime();
    266266
    267         JSONArray jsonIncaFilePropArr = new JSONArray();
    268         JSONArray jsonIncaFilePropDetailsArr = new JSONArray();
    269267        List<String> foundIncaHeadersList = new ArrayList<String>();
    270268
    271         // Get list of unprocessed data for each INCA file
     269        // Get list of unprocessed data for INCA file
    272270        List<UnprocessedIncaFile> unprocIncaFiles = fetchUnprocessedIncaFiles(req);
    273271System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" Data for " + unprocIncaFiles.size() + " files read.");
     272        // Get first file in list
     273        UnprocessedIncaFile unprocIncaFile = null;
     274        if (unprocIncaFiles.size() > 0)
     275        {
     276          unprocIncaFile = (UnprocessedIncaFile)unprocIncaFiles.get(0);
     277        }
    274278
    275279        // Map bioSource ID to personal number
     
    282286        }
    283287
    284         // Check file properties of INCA import files
    285         List<IncaFile> incaFiles = new ArrayList<IncaFile>();
     288        // Check file properties of INCA import file
     289        IncaFile incaFile = null;
    286290        List<Integer> excludeCaseIdList = new ArrayList<Integer>();
    287         int numUnprocIncaFiles = unprocIncaFiles.size();
    288         for (int fileNo = 0; fileNo < unprocIncaFiles.size(); fileNo++)
    289         {
    290           // Get data for current file
    291           UnprocessedIncaFile unprocIncaFile = (UnprocessedIncaFile)unprocIncaFiles.get(fileNo);
    292           String filename = unprocIncaFile.getFilename();
    293           List<String> headerList = unprocIncaFile.getHeaders();
    294           List<String> lines = unprocIncaFile.getLines();
    295           int numLinesWithLineFeeds = unprocIncaFile.getNumLinesWithLineFeeds();
    296           int numLinesWithTooManyColumns = unprocIncaFile.getNumLinesWithTooManyColumns();
    297           int numLinesWithTooFewColumns = unprocIncaFile.getNumLinesWithTooFewColumns();
    298 
    299           int numHeaderColumns = headerList.size();
    300           int numLines = lines.size();
    301           //
    302           JSONObject jsonIncaFileProp = new JSONObject();
    303           JSONObject jsonIncaFilePropDetails = new JSONObject();
    304           // General data for session
    305           jsonIncaFilePropDetails.put("incaImportStart", incaImportStart);
    306           jsonIncaFileProp.put("incaExportDate", incaExportDateStr);
    307           jsonIncaFileProp.put("importCheckOnly", importCheckOnly);
    308           jsonIncaFileProp.put("simpleCheckOnly", simpleCheckOnly);
    309           // File specific properties from basic input
    310           jsonIncaFileProp.put("filename", filename);
    311           jsonIncaFileProp.put("numHeaderColumns", numHeaderColumns);
    312           jsonIncaFileProp.put("numLines", numLines);
    313           jsonIncaFileProp.put("numLinesWithLineFeeds", numLinesWithLineFeeds);
    314           jsonIncaFileProp.put("numLinesWithTooManyColumns", numLinesWithTooManyColumns);
    315           jsonIncaFileProp.put("numLinesWithTooFewColumns", numLinesWithTooFewColumns);
    316           //
    317           // INCA file properties - Internal data check
    318           //
    319           // Find number of header duplicates
    320           int numHeaderDuplicates = 0;
    321           JSONArray jsonHeaderDuplicates = new JSONArray();
    322           for (int i = 0; i < headerList.size(); i++)
    323           {
    324             String header = (String)headerList.get(i);
    325             for (int j = (i + 1); j < headerList.size(); j++)
    326             {
    327               String header2 = (String)headerList.get(j);
    328               if (header.equals(header2))
     291        // Get data for current file
     292        String filename = unprocIncaFile.getFilename();
     293        List<String> headerList = unprocIncaFile.getHeaders();
     294        List<String> lines = unprocIncaFile.getLines();
     295        int numLinesWithLineFeeds = unprocIncaFile.getNumLinesWithLineFeeds();
     296        int numLinesWithTooManyColumns = unprocIncaFile.getNumLinesWithTooManyColumns();
     297        int numLinesWithTooFewColumns = unprocIncaFile.getNumLinesWithTooFewColumns();
     298
     299        int numHeaderColumns = headerList.size();
     300        int numLines = lines.size();
     301        //
     302        JSONObject jsonIncaFileProp = new JSONObject();
     303        JSONObject jsonIncaFilePropDetails = new JSONObject();
     304        // General data for session
     305        jsonIncaFilePropDetails.put("incaImportStart", incaImportStart);
     306        jsonIncaFileProp.put("incaExportDate", incaExportDateStr);
     307        jsonIncaFileProp.put("importCheckOnly", importCheckOnly);
     308        jsonIncaFileProp.put("simpleCheckOnly", simpleCheckOnly);
     309        // File specific properties from basic input
     310        jsonIncaFileProp.put("filename", filename);
     311        jsonIncaFileProp.put("numHeaderColumns", numHeaderColumns);
     312        jsonIncaFileProp.put("numLines", numLines);
     313        jsonIncaFileProp.put("numLinesWithLineFeeds", numLinesWithLineFeeds);
     314        jsonIncaFileProp.put("numLinesWithTooManyColumns", numLinesWithTooManyColumns);
     315        jsonIncaFileProp.put("numLinesWithTooFewColumns", numLinesWithTooFewColumns);
     316        //
     317        // INCA file properties - Internal data check
     318        //
     319        // Find number of header duplicates
     320        int numHeaderDuplicates = 0;
     321        JSONArray jsonHeaderDuplicates = new JSONArray();
     322        for (int i = 0; i < headerList.size(); i++)
     323        {
     324          String header = (String)headerList.get(i);
     325          for (int j = (i + 1); j < headerList.size(); j++)
     326          {
     327            String header2 = (String)headerList.get(j);
     328            if (header.equals(header2))
     329            {
     330              numHeaderDuplicates++;
     331              if (!jsonHeaderDuplicates.contains(header))
    329332              {
    330                 numHeaderDuplicates++;
    331                 if (!jsonHeaderDuplicates.contains(header))
    332                 {
    333                   jsonHeaderDuplicates.add(header);
    334                 }
     333                jsonHeaderDuplicates.add(header);
    335334              }
    336335            }
    337336          }
    338           jsonIncaFileProp.put("numHeaderDuplicates", numHeaderDuplicates);
    339           jsonIncaFilePropDetails.put("jsonHeaderDuplicates", jsonHeaderDuplicates);
    340 
    341           // Find column indexes for key columns from header
    342           jsonIncaFileProp = fetchKeyColumnIndexes(headerList, jsonIncaFileProp);
    343           int tempPatIdClmIndex = (Integer)jsonIncaFileProp.get("tempPatIdClmIndex");
    344           int personalNoClmIndex = (Integer)jsonIncaFileProp.get("personalNoClmIndex");
    345           int lateralityDescriptionClmIndex = (Integer)jsonIncaFileProp.get("lateralityDescriptionClmIndex");
    346 
    347           // Get INCA data with personal number
    348           // Note that several lines may have same personal number
    349           List<PotentialIncaImportLine> potentialIncaImportLines = fetchPotentialIncaImportLines(tempPatIdClmIndex, personalNoClmIndex, lateralityDescriptionClmIndex, lines);
    350           int numPersonalNoLines = potentialIncaImportLines.size();
    351           jsonIncaFileProp.put("numPersonalNoLines", numPersonalNoLines);
    352 
    353           // Check laterality for data lines with personal number
    354           InternalLateralityCheckResult internalLateralityCheckResult = internalLateralityCheck(potentialIncaImportLines);
    355           JSONArray jsonPatientIdWithMoreThanTwoLines = internalLateralityCheckResult.getJsonPatientIdWithMoreThanTwoLines();
    356           JSONArray jsonPatientIdWithManyIdenticalLateralityLines = internalLateralityCheckResult.getJsonPatientIdWithManyIdenticalLateralityLines();
    357           List<Integer> excludeLineList = internalLateralityCheckResult.getExcludeLineList();
    358           int numPersonalNoWithMoreThanTwoLines = jsonPatientIdWithMoreThanTwoLines.size();
    359           int numPersonalNoWithManyIdenticalLateralityLines = jsonPatientIdWithManyIdenticalLateralityLines.size();
     337        }
     338        jsonIncaFileProp.put("numHeaderDuplicates", numHeaderDuplicates);
     339        jsonIncaFilePropDetails.put("jsonHeaderDuplicates", jsonHeaderDuplicates);
     340
     341        // Find column indexes for key columns from header
     342        jsonIncaFileProp = fetchKeyColumnIndexes(headerList, jsonIncaFileProp);
     343        int tempPatIdClmIndex = (Integer)jsonIncaFileProp.get("tempPatIdClmIndex");
     344        int personalNoClmIndex = (Integer)jsonIncaFileProp.get("personalNoClmIndex");
     345        int lateralityDescriptionClmIndex = (Integer)jsonIncaFileProp.get("lateralityDescriptionClmIndex");
     346
     347        // Get INCA data with personal number
     348        // Note that several lines may have same personal number
     349        List<PotentialIncaImportLine> potentialIncaImportLines = fetchPotentialIncaImportLines(tempPatIdClmIndex, personalNoClmIndex, lateralityDescriptionClmIndex, lines);
     350        int numPersonalNoLines = potentialIncaImportLines.size();
     351        jsonIncaFileProp.put("numPersonalNoLines", numPersonalNoLines);
     352
     353        // Check laterality for data lines with personal number
     354        InternalLateralityCheckResult internalLateralityCheckResult = internalLateralityCheck(potentialIncaImportLines);
     355        JSONArray jsonPatientIdWithMoreThanTwoLines = internalLateralityCheckResult.getJsonPatientIdWithMoreThanTwoLines();
     356        JSONArray jsonPatientIdWithManyIdenticalLateralityLines = internalLateralityCheckResult.getJsonPatientIdWithManyIdenticalLateralityLines();
     357        List<Integer> excludeLineList = internalLateralityCheckResult.getExcludeLineList();
     358        int numPersonalNoWithMoreThanTwoLines = jsonPatientIdWithMoreThanTwoLines.size();
     359        int numPersonalNoWithManyIdenticalLateralityLines = jsonPatientIdWithManyIdenticalLateralityLines.size();
    360360         
    361           jsonIncaFileProp.put("numPersonalNoWithMoreThanTwoLines", numPersonalNoWithMoreThanTwoLines);
    362           jsonIncaFileProp.put("numPersonalNoWithManyIdenticalLateralityLines", numPersonalNoWithManyIdenticalLateralityLines);
    363           jsonIncaFilePropDetails.put("jsonPatientIdWithMoreThanTwoLines", jsonPatientIdWithMoreThanTwoLines);
    364           jsonIncaFilePropDetails.put("jsonPatientIdWithManyIdenticalLateralityLines", jsonPatientIdWithManyIdenticalLateralityLines);
    365 
    366           // Check if data consistency check is feasible
    367           boolean numHeaderColumnsOk = (numHeaderColumns > 0);
    368           boolean numLinesOk = (numLines > 0);
    369           boolean numLinesWithTooManyColumnsOk = (numLinesWithTooManyColumns == 0);
    370           boolean numLinesWithTooFewColumnsOk = (numLinesWithTooFewColumns == 0);
    371           boolean numHeaderDuplicatesOk = (numHeaderDuplicates == 0);
    372           boolean tempPatIdClmIndexOk = (tempPatIdClmIndex >= 0);
    373           boolean personalNoClmIndexOk = (personalNoClmIndex >= 0);
    374           boolean lateralityDescriptionClmIndexOk = (lateralityDescriptionClmIndex >= 0);
    375           boolean numPersonalNoLinesOk = (numPersonalNoLines > 0);
    376 
    377           boolean importFileStructureIsValid = false;
    378           if (numHeaderColumnsOk &&
    379               numLinesOk &&
    380               numLinesWithTooManyColumnsOk &&
    381               numLinesWithTooFewColumnsOk &&
    382               numHeaderDuplicatesOk &&
    383               tempPatIdClmIndexOk &&
    384               personalNoClmIndexOk &&
    385               lateralityDescriptionClmIndexOk &&
    386               numPersonalNoLinesOk)
    387           {
    388             importFileStructureIsValid = true;
    389           }
    390 
    391           //
    392           // INCA file properties - Database consistency check
    393           //
    394           int numUnknownHeaders = 0;
    395           JSONArray jsonUnknownHeaders = new JSONArray();
    396           List<Integer> importHeaderIndexList = new ArrayList<Integer>();
    397           for (int i = 0; i < headerList.size(); i++)
    398           {
    399             String header = (String)headerList.get(i);
    400             // Skip mapping columns and ignored columns
    401             if (!unImportedHeaders.contains(header))
    402             {
    403               String annotationtypeName = "INCA_" + header;
    404               if (!incaAnnoTypeNameList.contains(annotationtypeName))
     361        jsonIncaFileProp.put("numPersonalNoWithMoreThanTwoLines", numPersonalNoWithMoreThanTwoLines);
     362        jsonIncaFileProp.put("numPersonalNoWithManyIdenticalLateralityLines", numPersonalNoWithManyIdenticalLateralityLines);
     363        jsonIncaFilePropDetails.put("jsonPatientIdWithMoreThanTwoLines", jsonPatientIdWithMoreThanTwoLines);
     364        jsonIncaFilePropDetails.put("jsonPatientIdWithManyIdenticalLateralityLines", jsonPatientIdWithManyIdenticalLateralityLines);
     365
     366        // Check if data consistency check is feasible
     367        boolean numHeaderColumnsOk = (numHeaderColumns > 0);
     368        boolean numLinesOk = (numLines > 0);
     369        boolean numLinesWithTooManyColumnsOk = (numLinesWithTooManyColumns == 0);
     370        boolean numLinesWithTooFewColumnsOk = (numLinesWithTooFewColumns == 0);
     371        boolean numHeaderDuplicatesOk = (numHeaderDuplicates == 0);
     372        boolean tempPatIdClmIndexOk = (tempPatIdClmIndex >= 0);
     373        boolean personalNoClmIndexOk = (personalNoClmIndex >= 0);
     374        boolean lateralityDescriptionClmIndexOk = (lateralityDescriptionClmIndex >= 0);
     375        boolean numPersonalNoLinesOk = (numPersonalNoLines > 0);
     376
     377        boolean importFileStructureIsValid = false;
     378        if (numHeaderColumnsOk &&
     379            numLinesOk &&
     380            numLinesWithTooManyColumnsOk &&
     381            numLinesWithTooFewColumnsOk &&
     382            numHeaderDuplicatesOk &&
     383            tempPatIdClmIndexOk &&
     384            personalNoClmIndexOk &&
     385            lateralityDescriptionClmIndexOk &&
     386            numPersonalNoLinesOk)
     387        {
     388          importFileStructureIsValid = true;
     389        }
     390
     391        //
     392        // INCA file properties - Database consistency check
     393        //
     394        int numUnknownHeaders = 0;
     395        JSONArray jsonUnknownHeaders = new JSONArray();
     396        List<Integer> importHeaderIndexList = new ArrayList<Integer>();
     397        for (int i = 0; i < headerList.size(); i++)
     398        {
     399          String header = (String)headerList.get(i);
     400          // Skip mapping columns and ignored columns
     401          if (!unImportedHeaders.contains(header))
     402          {
     403            String annotationtypeName = "INCA_" + header;
     404            if (!incaAnnoTypeNameList.contains(annotationtypeName))
     405            {
     406              numUnknownHeaders++;
     407              if (!jsonUnknownHeaders.contains(header))
    405408              {
    406                 numUnknownHeaders++;
    407                 if (!jsonUnknownHeaders.contains(header))
    408                 {
    409                   jsonUnknownHeaders.add(header);
    410                 }
     409                jsonUnknownHeaders.add(header);
    411410              }
    412               else
     411            }
     412            else
     413            {
     414              importHeaderIndexList.add(i);
     415              if (!foundIncaHeadersList.contains(header))
    413416              {
    414                 importHeaderIndexList.add(i);
    415                 if (!foundIncaHeadersList.contains(header))
    416                 {
    417                   foundIncaHeadersList.add(header);
    418                 }
     417                foundIncaHeadersList.add(header);
    419418              }
    420419            }
    421420          }
    422           jsonIncaFileProp.put("numUnknownHeaders", numUnknownHeaders);
    423           jsonIncaFilePropDetails.put("jsonUnknownHeaders", jsonUnknownHeaders);
    424           //
    425           if (!simpleCheckOnly)
    426           {
    427 System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" fileNo = " + fileNo + " potentialIncaImportLines.size() = " + potentialIncaImportLines.size());
    428             // Perform mapping of potential INCA import lines to database
    429             LineDatabaseMappingResult lineDatabaseMappingResult = lineDatabaseMapping(dc, potentialIncaImportLines, pnoBioSourceIdHM, incaLateralityHM, excludeLineList, importHeaderIndexList, headerList, incaAnnoNameAnnoTypeHM, fileNo, numUnprocIncaFiles, progress, progressTestFraction, progressOffset);
    430             progressOffset += Math.round(100.0*progressTestFraction);
    431             HashMap<Integer,Integer> rawLineNumberCaseIdHM = lineDatabaseMappingResult.getRawLineNumberCaseIdHM();
    432             excludeLineList = lineDatabaseMappingResult.getExcludeLineList();
    433             excludeCaseIdList = lineDatabaseMappingResult.getExcludeCaseIdList();
    434             int numPersonalNoWithoutDatabaseReference = lineDatabaseMappingResult.getNumPersonalNoWithoutDatabaseReference();
    435             int numPatientLateralitiesWithoutDatabaseReference = lineDatabaseMappingResult.getNumPatientLateralitiesWithoutDatabaseReference();
    436             JSONArray jsonPatientIdForPersonalNoWithoutDatabaseReference = lineDatabaseMappingResult.getJsonPatientIdForPersonalNoWithoutDatabaseReference();
    437             JSONArray jsonPatientLateralitiesWithoutDatabaseReference = lineDatabaseMappingResult.getJsonPatientLateralitiesWithoutDatabaseReference();
    438             JSONArray jsonBadValueLines = lineDatabaseMappingResult.getJsonBadValueLines();
    439 
    440             int numBadValueLines = jsonBadValueLines.size();
    441             jsonIncaFileProp.put("numDataLinesWithoutDatabaseReference", numPersonalNoWithoutDatabaseReference);
    442             jsonIncaFileProp.put("numPatientLateralitiesWithoutDatabaseReference", numPatientLateralitiesWithoutDatabaseReference);
    443             jsonIncaFileProp.put("numBadValueLines", numBadValueLines);
    444             jsonIncaFilePropDetails.put("jsonPatientIdForPersonalNoWithoutDatabaseReference", jsonPatientIdForPersonalNoWithoutDatabaseReference);
    445             jsonIncaFilePropDetails.put("jsonPatientLateralitiesWithoutDatabaseReference", jsonPatientLateralitiesWithoutDatabaseReference);
    446             jsonIncaFilePropDetails.put("jsonBadValueLines", jsonBadValueLines);
    447 
    448             // Data lines passing file check
    449             List<RawIncaCase> rawIncaCases = new ArrayList<RawIncaCase>();
    450             // Note that potentialIncaImportLines may contain data for same personal no. more than once (for different lateralities)
    451             for (int i = 0; i < potentialIncaImportLines.size(); i++)
    452             {
    453               if (!excludeLineList.contains(i))
    454               {
    455                 PotentialIncaImportLine potentialIncaImportLine = (PotentialIncaImportLine) potentialIncaImportLines.get(i);
    456                 String personalNoLine = potentialIncaImportLine.getLine();
    457                 Integer caseId = rawLineNumberCaseIdHM.get(i);
    458                 // Store data for case from one INCA file in RawIncaCase object
    459                 RawIncaCase rawIncaCase = new RawIncaCase();
    460                 rawIncaCase.setCaseId(caseId);
    461                 rawIncaCase.setLine(personalNoLine);
    462                 // Add RawIncaCase object to list
    463                 rawIncaCases.add(rawIncaCase);
    464               }
    465             }
    466             int numDataLinesForImport = rawIncaCases.size();
    467             jsonIncaFileProp.put("numDataLinesForImport", numDataLinesForImport);
    468 System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" fileNo = " + fileNo + " Case mapping done: numDataLinesForImport = " + numDataLinesForImport);
    469 
    470             // Store data for processed INCA file in IncaFile object
    471             IncaFile incaFile = new IncaFile();
    472             incaFile.setFilename(filename);
    473             incaFile.setHeaders(headerList);
    474             incaFile.setHeaderIndexList(importHeaderIndexList);
    475             incaFile.setRawIncaCases(rawIncaCases);
    476             // Add IncaFile object to list
    477             incaFiles.add(incaFile);
    478           }
    479           // End of if (!simpleCheckOnly)
    480 
    481           // Add JSON data for file to JSONArray
    482           jsonIncaFilePropArr.add(jsonIncaFileProp);
    483           //
    484           jsonIncaFilePropDetails.put("jsonIncaFileProp", jsonIncaFileProp);
    485           jsonIncaFilePropDetailsArr.add(jsonIncaFilePropDetails);
    486         }
    487         // End of loop over 'unprocIncaFiles' (unprocessed INCA files)
     421        }
     422        jsonIncaFileProp.put("numUnknownHeaders", numUnknownHeaders);
     423        jsonIncaFilePropDetails.put("jsonUnknownHeaders", jsonUnknownHeaders);
     424        //
     425        if (!simpleCheckOnly)
     426        {
     427System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" potentialIncaImportLines.size() = " + potentialIncaImportLines.size());
     428          // Perform mapping of potential INCA import lines to database
     429          LineDatabaseMappingResult lineDatabaseMappingResult = lineDatabaseMapping(dc, potentialIncaImportLines, pnoBioSourceIdHM, incaLateralityHM, excludeLineList, importHeaderIndexList, headerList, incaAnnoNameAnnoTypeHM, progress, progressTestFraction, progressOffset);
     430          progressOffset += Math.round(100.0*progressTestFraction);
     431          HashMap<Integer,Integer> rawLineNumberCaseIdHM = lineDatabaseMappingResult.getRawLineNumberCaseIdHM();
     432          excludeLineList = lineDatabaseMappingResult.getExcludeLineList();
     433          excludeCaseIdList = lineDatabaseMappingResult.getExcludeCaseIdList();
     434          int numPersonalNoWithoutDatabaseReference = lineDatabaseMappingResult.getNumPersonalNoWithoutDatabaseReference();
     435          int numPatientLateralitiesWithoutDatabaseReference = lineDatabaseMappingResult.getNumPatientLateralitiesWithoutDatabaseReference();
     436          JSONArray jsonPatientIdForPersonalNoWithoutDatabaseReference = lineDatabaseMappingResult.getJsonPatientIdForPersonalNoWithoutDatabaseReference();
     437          JSONArray jsonPatientLateralitiesWithoutDatabaseReference = lineDatabaseMappingResult.getJsonPatientLateralitiesWithoutDatabaseReference();
     438          JSONArray jsonBadValueLines = lineDatabaseMappingResult.getJsonBadValueLines();
     439
     440          int numBadValueLines = jsonBadValueLines.size();
     441          jsonIncaFileProp.put("numDataLinesWithoutDatabaseReference", numPersonalNoWithoutDatabaseReference);
     442          jsonIncaFileProp.put("numPatientLateralitiesWithoutDatabaseReference", numPatientLateralitiesWithoutDatabaseReference);
     443          jsonIncaFileProp.put("numBadValueLines", numBadValueLines);
     444          jsonIncaFilePropDetails.put("jsonPatientIdForPersonalNoWithoutDatabaseReference", jsonPatientIdForPersonalNoWithoutDatabaseReference);
     445          jsonIncaFilePropDetails.put("jsonPatientLateralitiesWithoutDatabaseReference", jsonPatientLateralitiesWithoutDatabaseReference);
     446          jsonIncaFilePropDetails.put("jsonBadValueLines", jsonBadValueLines);
     447
     448          // Data lines passing file check
     449          List<RawIncaCase> rawIncaCases = new ArrayList<RawIncaCase>();
     450          // Note that potentialIncaImportLines may contain data for same personal no. more than once (for different lateralities)
     451          for (int i = 0; i < potentialIncaImportLines.size(); i++)
     452          {
     453            if (!excludeLineList.contains(i))
     454            {
     455              PotentialIncaImportLine potentialIncaImportLine = (PotentialIncaImportLine) potentialIncaImportLines.get(i);
     456              String personalNoLine = potentialIncaImportLine.getLine();
     457              Integer caseId = rawLineNumberCaseIdHM.get(i);
     458              // Store data for case from one INCA file in RawIncaCase object
     459              RawIncaCase rawIncaCase = new RawIncaCase();
     460              rawIncaCase.setCaseId(caseId);
     461              rawIncaCase.setLine(personalNoLine);
     462              // Add RawIncaCase object to list
     463              rawIncaCases.add(rawIncaCase);
     464            }
     465          }
     466          int numDataLinesForImport = rawIncaCases.size();
     467          jsonIncaFileProp.put("numDataLinesForImport", numDataLinesForImport);
     468System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" Case mapping done: numDataLinesForImport = " + numDataLinesForImport);
     469
     470          // Store data for processed INCA file in IncaFile object
     471          incaFile = new IncaFile();
     472          incaFile.setFilename(filename);
     473          incaFile.setHeaders(headerList);
     474          incaFile.setHeaderIndexList(importHeaderIndexList);
     475          incaFile.setRawIncaCases(rawIncaCases);
     476        }
     477        // End of if (!simpleCheckOnly)
     478        jsonIncaFilePropDetails.put("jsonIncaFileProp", jsonIncaFileProp);
    488479
    489480        // Check for missing INCA headers
     
    523514          HashMap<Integer,IncaCase> caseIdIncaCaseHM = new HashMap<Integer,IncaCase>();
    524515
    525           // Collect data from all INCA files for same case ID
    526           for (int fileNo = 0; fileNo < incaFiles.size(); fileNo++)
    527           {
    528             // Get data for current file
    529             IncaFile incaFile = (IncaFile)incaFiles.get(fileNo);
    530             String filename = incaFile.getFilename();
     516          // Collect data from INCA file for same case ID
     517          if (incaFile != null)
     518          {
    531519            List<String> fileHeaderList = incaFile.getHeaders();
    532520            List<Integer> fileHeaderIndexList = incaFile.getHeaderIndexList();
     
    739727          int numEntriesChangedInExportImportDates = incaExportImportDateAnnotationChangedCaseIdList.size();
    740728          // Get total number of lines for import
    741           int numDataLinesForImport = 0;
    742           for (int fileNo = 0; fileNo < incaFiles.size(); fileNo++)
    743           {
    744             IncaFile incaFile = (IncaFile)incaFiles.get(fileNo);
    745             List<RawIncaCase> rawIncaCases = (List<RawIncaCase>) incaFile.getRawIncaCases();
    746             numDataLinesForImport += rawIncaCases.size();
    747           }
     729          List<RawIncaCase> rawIncaCases = (List<RawIncaCase>) incaFile.getRawIncaCases();
     730          int numDataLinesForImport = rawIncaCases.size();
    748731
    749732System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" Import: numEntriesChangedInExportImportDates = " + numEntriesChangedInExportImportDates + " Calling dc.commit()");
    750733          dc.commit();
    751           message = "" + numIncaAnnotationsChanged + " INCA annotations updated for " + numEntriesChanged + " cases from " + numDataLinesForImport + " lines from " + incaFiles.size() + " file[s].";
     734          message = "" + numIncaAnnotationsChanged + " INCA annotations updated for " + numEntriesChanged + " cases from " + numDataLinesForImport + " lines from one file.";
    752735          message += " " + numIncaExportImportDateAnnotationsChanged + " INCA date annotations updated for " + numEntriesChangedInExportImportDates + " cases.";
    753736System.out.println(new Date() + " doPost(): cmd = \"" + cmd + "\" Import: message = " + message);
     
    758741        }
    759742        // Create INCA import report file
    760         String reportFilePath = createIncaImportReportFile(jsonIncaFilePropDetailsArr, missingIncaHeadersList, message);
    761 
    762         json.put("incaFilePropertiesArray", jsonIncaFilePropArr);
     743        String reportFilePath = createIncaImportReportFile(jsonIncaFilePropDetails, missingIncaHeadersList, message);
     744
     745        json.put("incaFileProperties", jsonIncaFileProp);
    763746        json.put("numMissingIncaHeaders", numMissingIncaHeaders);
    764747        json.put("simpleCheckOnly", simpleCheckOnly);
     
    11781161   * @param headerList List<String> List of columns headers.
    11791162   * @param incaAnnoNameAnnoTypeHM HashMap<String,AnnotationType> A hash map mapping INCA annotation type names to annotation types.
    1180    * @param fileNo int Index for the current file processed (for progress calculation).
    1181    * @param numFiles int Number of files to process (for progress calculation).
    11821163   * @param progress SimpleProgressReporter Progress reporter to use.
    11831164   * @param progressTestFraction float Estimated test phase fraction of process time.
     
    11941175      List<String> headerList,
    11951176      HashMap<String,AnnotationType> incaAnnoNameAnnoTypeHM,
    1196       int fileNo,
    1197       int numFiles,
    11981177      SimpleProgressReporter progress,
    11991178      float progressTestFraction,
     
    13851364      if (i % 1000 == 0)
    13861365      {
    1387 System.out.println(new Date() + " lineDatabaseMapping(): fileNo = " + fileNo + " i = " + i + " excludeLineList.size() = " + excludeLineList.size());
     1366System.out.println(new Date() + " lineDatabaseMapping(): i = " + i + " excludeLineList.size() = " + excludeLineList.size());
    13881367      }
    13891368      // Progress reporting
    1390       localProgressFraction = (fileNo + (float)i/numLines)/numFiles;
     1369      localProgressFraction = (float)i/numLines;
    13911370      int progressPct = progressOffset + Math.round(100*progressTestFraction*localProgressFraction);
    13921371      if (progressPct > 99)
     
    14301409  }
    14311410
    1432   private String createIncaImportReportFile(JSONArray jsonIncaFilePropDetailsArr, List<String> missingIncaHeadersList, String message)
     1411  private String createIncaImportReportFile(JSONObject jsonIncaFilePropDetails, List<String> missingIncaHeadersList, String message)
    14331412  {
    14341413    String reportFilePath = fetchReportFilePath();
     
    14421421    Date now = new Date();
    14431422    String importEnd = d1.convert(now);
    1444     JSONObject tmpJsonIncaFilePropDetails = (JSONObject)jsonIncaFilePropDetailsArr.get(0);
    1445     JSONObject tmpJsonIncaFileProp = (JSONObject)tmpJsonIncaFilePropDetails.get("jsonIncaFileProp");
    1446     Date importStartDateTime = (Date)tmpJsonIncaFilePropDetails.get("incaImportStart");
     1423    JSONObject tmpJsonIncaFileProp = (JSONObject)jsonIncaFilePropDetails.get("jsonIncaFileProp");
     1424    Date importStartDateTime = (Date)jsonIncaFilePropDetails.get("incaImportStart");
    14471425    String importStart = d1.convert(importStartDateTime);
    14481426    String incaExportDate = (String)tmpJsonIncaFileProp.get("incaExportDate");
     
    14641442      fileWriter.write("\n");
    14651443      fileWriter.write("INCA import files:\n");
    1466       for (int fileNo = 0; fileNo < jsonIncaFilePropDetailsArr.size(); fileNo++)
    1467       {
    1468         JSONObject jsonIncaFilePropDetails = (JSONObject)jsonIncaFilePropDetailsArr.get(fileNo);
    1469         JSONObject jsonIncaFileProp = (JSONObject)jsonIncaFilePropDetails.get("jsonIncaFileProp");
    1470         String incaImportFilename = (String)jsonIncaFileProp.get("filename");
    1471         fileWriter.write(incaImportFilename + "\n");
    1472       }
     1444      JSONObject jsonIncaFileProp = (JSONObject)jsonIncaFilePropDetails.get("jsonIncaFileProp");
     1445      String incaImportFilename = (String)jsonIncaFileProp.get("filename");
     1446      fileWriter.write(incaImportFilename + "\n");
    14731447      fileWriter.write("\n");
    1474       for (int fileNo = 0; fileNo < jsonIncaFilePropDetailsArr.size(); fileNo++)
    1475       {
    1476         JSONObject jsonIncaFilePropDetails = (JSONObject)jsonIncaFilePropDetailsArr.get(fileNo);
    1477         JSONObject jsonIncaFileProp = (JSONObject)jsonIncaFilePropDetails.get("jsonIncaFileProp");
    1478         String incaImportFilename = (String)jsonIncaFileProp.get("filename");
    1479         fileWriter.write("______________________________________________________________________\n");
    1480         fileWriter.write("INCA import file:" + separator + incaImportFilename + "\n");
     1448      fileWriter.write("______________________________________________________________________\n");
     1449      fileWriter.write("INCA import file:" + separator + incaImportFilename + "\n");
     1450      fileWriter.write("\n");
     1451      //
     1452      // INCA file properties - Basic check
     1453      Integer numHeaderColumns = (Integer)jsonIncaFileProp.get("numHeaderColumns");
     1454      Integer numLines = (Integer)jsonIncaFileProp.get("numLines");
     1455      Integer numLinesWithLineFeeds = (Integer)jsonIncaFileProp.get("numLinesWithLineFeeds");
     1456      Integer numLinesWithTooManyColumns = (Integer)jsonIncaFileProp.get("numLinesWithTooManyColumns");
     1457      Integer numLinesWithTooFewColumns = (Integer)jsonIncaFileProp.get("numLinesWithTooFewColumns");
     1458
     1459      fileWriter.write("INCA file properties - Basic check" + "\n");
     1460      fileWriter.write("__________________________________" + "\n");
     1461      fileWriter.write("# Header columns: " + separator + numHeaderColumns + "\n");
     1462      fileWriter.write("# Lines of data: " + separator + numLines + "\n");
     1463      fileWriter.write("# Lines with internal line feeds: " + separator + numLinesWithLineFeeds + "\n");
     1464      fileWriter.write("# Lines with too many columns: " + separator + numLinesWithTooManyColumns + "\n");
     1465      fileWriter.write("# Lines with too few columns: " + separator + numLinesWithTooFewColumns + "\n");
     1466      fileWriter.write("\n");
     1467      //
     1468      // INCA file properties - Internal data check
     1469      Integer numHeaderDuplicates = (Integer)jsonIncaFileProp.get("numHeaderDuplicates");
     1470      Integer tempPatIdClmIndex = (Integer)jsonIncaFileProp.get("tempPatIdClmIndex");
     1471      Integer personalNoClmIndex = (Integer)jsonIncaFileProp.get("personalNoClmIndex");
     1472      Integer lateralityDescriptionClmIndex = (Integer)jsonIncaFileProp.get("lateralityDescriptionClmIndex");
     1473      Integer numUnknownHeaders = (Integer)jsonIncaFileProp.get("numUnknownHeaders");
     1474      Integer numPersonalNoLines = (Integer)jsonIncaFileProp.get("numPersonalNoLines");
     1475      Integer numPersonalNoWithMoreThanTwoLines = (Integer)jsonIncaFileProp.get("numPersonalNoWithMoreThanTwoLines");
     1476      Integer numPersonalNoWithManyIdenticalLateralityLines = (Integer)jsonIncaFileProp.get("numPersonalNoWithManyIdenticalLateralityLines");
     1477
     1478      fileWriter.write("INCA file properties - Internal data check" + "\n");
     1479      fileWriter.write("__________________________________________" + "\n");
     1480      fileWriter.write("# Duplicate header columns: " + separator + numHeaderDuplicates + "\n");
     1481      fileWriter.write("Temporary patient ID column index: " + separator + tempPatIdClmIndex + "\n");
     1482      fileWriter.write("Personal number column index: " + separator + personalNoClmIndex + "\n");
     1483      fileWriter.write("Laterality description column index: " + separator + lateralityDescriptionClmIndex + "\n");
     1484      fileWriter.write("# Unknown headers: " + separator + numUnknownHeaders + "\n");
     1485      fileWriter.write("# Data lines with personal no.: " + separator + numPersonalNoLines + "\n");
     1486      fileWriter.write("# Personal no. with more than 2 lines: " + separator + numPersonalNoWithMoreThanTwoLines + "\n");
     1487      fileWriter.write("# Personal no.s with many identical lateralities: " + separator + numPersonalNoWithManyIdenticalLateralityLines + "\n");
     1488      fileWriter.write("\n");
     1489
     1490      if (numHeaderDuplicates > 0)
     1491      {
     1492        JSONArray jsonHeaderDuplicates = (JSONArray) jsonIncaFilePropDetails.get("jsonHeaderDuplicates");
     1493        if (jsonHeaderDuplicates != null)
     1494        {
     1495          fileWriter.write("Duplicate headers:\n");
     1496          for (int i = 0; i < jsonHeaderDuplicates.size(); i++)
     1497          {
     1498            String duplicateHeader = (String)jsonHeaderDuplicates.get(i);
     1499            fileWriter.write("" + duplicateHeader + "\n");
     1500          }
     1501          fileWriter.write("\n");         
     1502        }
     1503      }
     1504      if (numUnknownHeaders > 0)
     1505      {
     1506        JSONArray jsonUnknownHeaders = (JSONArray) jsonIncaFilePropDetails.get("jsonUnknownHeaders");
     1507        if (jsonUnknownHeaders != null)
     1508        {
     1509          fileWriter.write("Unknown headers:\n");
     1510          for (int i = 0; i < jsonUnknownHeaders.size(); i++)
     1511          {
     1512            String unknownHeader = (String)jsonUnknownHeaders.get(i);
     1513            fileWriter.write("" + unknownHeader + "\n");
     1514          }
     1515          fileWriter.write("\n");         
     1516        }
     1517      }
     1518      if (numPersonalNoWithMoreThanTwoLines > 0)
     1519      {
     1520        JSONArray jsonPatientIdWithMoreThanTwoLines = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientIdWithMoreThanTwoLines");
     1521        if (jsonPatientIdWithMoreThanTwoLines != null)
     1522        {
     1523          fileWriter.write("Temporary patient IDs with more than two lines:\n");
     1524          for (int i = 0; i < jsonPatientIdWithMoreThanTwoLines.size(); i++)
     1525          {
     1526            String patId = (String)jsonPatientIdWithMoreThanTwoLines.get(i);
     1527            fileWriter.write("" + patId + "\n");
     1528          }
     1529          fileWriter.write("\n");         
     1530        }
     1531      }
     1532      if (numPersonalNoWithManyIdenticalLateralityLines > 0)
     1533      {
     1534        JSONArray jsonPatientIdWithManyIdenticalLateralityLines = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientIdWithManyIdenticalLateralityLines");
     1535        if (jsonPatientIdWithManyIdenticalLateralityLines != null)
     1536        {
     1537          fileWriter.write("Temporary patient IDs with many identical laterality lines:\n");
     1538          for (int i = 0; i < jsonPatientIdWithManyIdenticalLateralityLines.size(); i++)
     1539          {
     1540            String patId = (String)jsonPatientIdWithManyIdenticalLateralityLines.get(i);
     1541            fileWriter.write("" + patId + "\n");
     1542          }
     1543          fileWriter.write("\n");         
     1544        }
     1545      }
     1546      if (!simpleCheckOnly)
     1547      {
     1548        //
     1549        // INCA file properties - Database consistency check (only lines with personal no. processed)
     1550        Integer numPersonalNoWithoutDatabaseReference = (Integer)jsonIncaFileProp.get("numDataLinesWithoutDatabaseReference");
     1551        Integer numPatientLateralitiesWithoutDatabaseReference = (Integer)jsonIncaFileProp.get("numPatientLateralitiesWithoutDatabaseReference");
     1552        Integer numBadValueLines = (Integer)jsonIncaFileProp.get("numBadValueLines");
     1553        Integer numDataLinesForImport = (Integer)jsonIncaFileProp.get("numDataLinesForImport");
     1554
     1555        fileWriter.write("INCA file properties - Database consistency check (only lines with personal no. processed)" + "\n");
     1556        fileWriter.write("_________________________________________________" + "\n");
     1557        fileWriter.write("# Data lines with personal no. not in database: " + separator + numPersonalNoWithoutDatabaseReference + "\n");
     1558        fileWriter.write("# Patient lateralities without database reference: " + separator + numPatientLateralitiesWithoutDatabaseReference + "\n");
     1559        fileWriter.write("# Data lines with bad values: " + separator + numBadValueLines + "\n");
    14811560        fileWriter.write("\n");
    1482         //
    1483         // INCA file properties - Basic check
    1484         Integer numHeaderColumns = (Integer)jsonIncaFileProp.get("numHeaderColumns");
    1485         Integer numLines = (Integer)jsonIncaFileProp.get("numLines");
    1486         Integer numLinesWithLineFeeds = (Integer)jsonIncaFileProp.get("numLinesWithLineFeeds");
    1487         Integer numLinesWithTooManyColumns = (Integer)jsonIncaFileProp.get("numLinesWithTooManyColumns");
    1488         Integer numLinesWithTooFewColumns = (Integer)jsonIncaFileProp.get("numLinesWithTooFewColumns");
    1489 
    1490         fileWriter.write("INCA file properties - Basic check" + "\n");
    1491         fileWriter.write("__________________________________" + "\n");
    1492         fileWriter.write("# Header columns: " + separator + numHeaderColumns + "\n");
    1493         fileWriter.write("# Lines of data: " + separator + numLines + "\n");
    1494         fileWriter.write("# Lines with internal line feeds: " + separator + numLinesWithLineFeeds + "\n");
    1495         fileWriter.write("# Lines with too many columns: " + separator + numLinesWithTooManyColumns + "\n");
    1496         fileWriter.write("# Lines with too few columns: " + separator + numLinesWithTooFewColumns + "\n");
     1561        fileWriter.write("# Data lines for import = " + numDataLinesForImport + " of " + numPersonalNoLines + "\n");
    14971562        fileWriter.write("\n");
    1498         //
    1499         // INCA file properties - Internal data check
    1500         Integer numHeaderDuplicates = (Integer)jsonIncaFileProp.get("numHeaderDuplicates");
    1501         Integer tempPatIdClmIndex = (Integer)jsonIncaFileProp.get("tempPatIdClmIndex");
    1502         Integer personalNoClmIndex = (Integer)jsonIncaFileProp.get("personalNoClmIndex");
    1503         Integer lateralityDescriptionClmIndex = (Integer)jsonIncaFileProp.get("lateralityDescriptionClmIndex");
    1504         Integer numUnknownHeaders = (Integer)jsonIncaFileProp.get("numUnknownHeaders");
    1505         Integer numPersonalNoLines = (Integer)jsonIncaFileProp.get("numPersonalNoLines");
    1506         Integer numPersonalNoWithMoreThanTwoLines = (Integer)jsonIncaFileProp.get("numPersonalNoWithMoreThanTwoLines");
    1507         Integer numPersonalNoWithManyIdenticalLateralityLines = (Integer)jsonIncaFileProp.get("numPersonalNoWithManyIdenticalLateralityLines");
    1508 
    1509         fileWriter.write("INCA file properties - Internal data check" + "\n");
    1510         fileWriter.write("__________________________________________" + "\n");
    1511         fileWriter.write("# Duplicate header columns: " + separator + numHeaderDuplicates + "\n");
    1512         fileWriter.write("Temporary patient ID column index: " + separator + tempPatIdClmIndex + "\n");
    1513         fileWriter.write("Personal number column index: " + separator + personalNoClmIndex + "\n");
    1514         fileWriter.write("Laterality description column index: " + separator + lateralityDescriptionClmIndex + "\n");
    1515         fileWriter.write("# Unknown headers: " + separator + numUnknownHeaders + "\n");
    1516         fileWriter.write("# Data lines with personal no.: " + separator + numPersonalNoLines + "\n");
    1517         fileWriter.write("# Personal no. with more than 2 lines: " + separator + numPersonalNoWithMoreThanTwoLines + "\n");
    1518         fileWriter.write("# Personal no.s with many identical lateralities: " + separator + numPersonalNoWithManyIdenticalLateralityLines + "\n");
    1519         fileWriter.write("\n");
    1520 
    1521         if (numHeaderDuplicates > 0)
    1522         {
    1523           JSONArray jsonHeaderDuplicates = (JSONArray) jsonIncaFilePropDetails.get("jsonHeaderDuplicates");
    1524           if (jsonHeaderDuplicates != null)
    1525           {
    1526             fileWriter.write("Duplicate headers:\n");
    1527             for (int i = 0; i < jsonHeaderDuplicates.size(); i++)
    1528             {
    1529               String duplicateHeader = (String)jsonHeaderDuplicates.get(i);
    1530               fileWriter.write("" + duplicateHeader + "\n");
     1563
     1564        if (numPersonalNoWithoutDatabaseReference > 0)
     1565        {
     1566          JSONArray jsonPatientIdForPersonalNoWithoutDatabaseReference = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientIdForPersonalNoWithoutDatabaseReference");
     1567          if (jsonPatientIdForPersonalNoWithoutDatabaseReference != null)
     1568          {
     1569            fileWriter.write("Temporary patient IDs for personal numbers without database reference:\n");
     1570            for (int i = 0; i < jsonPatientIdForPersonalNoWithoutDatabaseReference.size(); i++)
     1571            {
     1572              String patId = (String)jsonPatientIdForPersonalNoWithoutDatabaseReference.get(i);
     1573              fileWriter.write("" + patId + "\n");
    15311574            }
    15321575            fileWriter.write("\n");         
    15331576          }
    15341577        }
    1535         if (numUnknownHeaders > 0)
    1536         {
    1537           JSONArray jsonUnknownHeaders = (JSONArray) jsonIncaFilePropDetails.get("jsonUnknownHeaders");
    1538           if (jsonUnknownHeaders != null)
    1539           {
    1540             fileWriter.write("Unknown headers:\n");
    1541             for (int i = 0; i < jsonUnknownHeaders.size(); i++)
    1542             {
    1543               String unknownHeader = (String)jsonUnknownHeaders.get(i);
    1544               fileWriter.write("" + unknownHeader + "\n");
     1578        if (numPatientLateralitiesWithoutDatabaseReference > 0)
     1579        {
     1580          JSONArray jsonPatientLateralitiesWithoutDatabaseReference = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientLateralitiesWithoutDatabaseReference");
     1581          if (jsonPatientLateralitiesWithoutDatabaseReference != null)
     1582          {
     1583            fileWriter.write("Temporary patient ID/laterality for personal number/laterality without database reference:\n");
     1584            for (int i = 0; i < jsonPatientLateralitiesWithoutDatabaseReference.size(); i++)
     1585            {
     1586              JSONObject jsonPnoLat = (JSONObject)jsonPatientLateralitiesWithoutDatabaseReference.get(i);
     1587              String patid = (String)jsonPnoLat.get("patientId");
     1588              String lat = (String)jsonPnoLat.get("laterality");
     1589              fileWriter.write("" + patid + separator + lat + "\n");
    15451590            }
    15461591            fileWriter.write("\n");         
    15471592          }
    15481593        }
    1549         if (numPersonalNoWithMoreThanTwoLines > 0)
    1550         {
    1551           JSONArray jsonPatientIdWithMoreThanTwoLines = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientIdWithMoreThanTwoLines");
    1552           if (jsonPatientIdWithMoreThanTwoLines != null)
    1553           {
    1554             fileWriter.write("Temporary patient IDs with more than two lines:\n");
    1555             for (int i = 0; i < jsonPatientIdWithMoreThanTwoLines.size(); i++)
    1556             {
    1557               String patId = (String)jsonPatientIdWithMoreThanTwoLines.get(i);
    1558               fileWriter.write("" + patId + "\n");
    1559             }
    1560             fileWriter.write("\n");         
    1561           }
    1562         }
    1563         if (numPersonalNoWithManyIdenticalLateralityLines > 0)
    1564         {
    1565           JSONArray jsonPatientIdWithManyIdenticalLateralityLines = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientIdWithManyIdenticalLateralityLines");
    1566           if (jsonPatientIdWithManyIdenticalLateralityLines != null)
    1567           {
    1568             fileWriter.write("Temporary patient IDs with many identical laterality lines:\n");
    1569             for (int i = 0; i < jsonPatientIdWithManyIdenticalLateralityLines.size(); i++)
    1570             {
    1571               String patId = (String)jsonPatientIdWithManyIdenticalLateralityLines.get(i);
    1572               fileWriter.write("" + patId + "\n");
    1573             }
    1574             fileWriter.write("\n");         
    1575           }
    1576         }
    1577         if (!simpleCheckOnly)
    1578         {
    1579           //
    1580           // INCA file properties - Database consistency check (only lines with personal no. processed)
    1581           Integer numPersonalNoWithoutDatabaseReference = (Integer)jsonIncaFileProp.get("numDataLinesWithoutDatabaseReference");
    1582           Integer numPatientLateralitiesWithoutDatabaseReference = (Integer)jsonIncaFileProp.get("numPatientLateralitiesWithoutDatabaseReference");
    1583           Integer numBadValueLines = (Integer)jsonIncaFileProp.get("numBadValueLines");
    1584           Integer numDataLinesForImport = (Integer)jsonIncaFileProp.get("numDataLinesForImport");
    1585 
    1586           fileWriter.write("INCA file properties - Database consistency check (only lines with personal no. processed)" + "\n");
    1587           fileWriter.write("_________________________________________________" + "\n");
    1588           fileWriter.write("# Data lines with personal no. not in database: " + separator + numPersonalNoWithoutDatabaseReference + "\n");
    1589           fileWriter.write("# Patient lateralities without database reference: " + separator + numPatientLateralitiesWithoutDatabaseReference + "\n");
    1590           fileWriter.write("# Data lines with bad values: " + separator + numBadValueLines + "\n");
    1591           fileWriter.write("\n");
    1592           fileWriter.write("# Data lines for import = " + numDataLinesForImport + " of " + numPersonalNoLines + "\n");
    1593           fileWriter.write("\n");
    1594 
    1595           if (numPersonalNoWithoutDatabaseReference > 0)
    1596           {
    1597             JSONArray jsonPatientIdForPersonalNoWithoutDatabaseReference = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientIdForPersonalNoWithoutDatabaseReference");
    1598             if (jsonPatientIdForPersonalNoWithoutDatabaseReference != null)
    1599             {
    1600               fileWriter.write("Temporary patient IDs for personal numbers without database reference:\n");
    1601               for (int i = 0; i < jsonPatientIdForPersonalNoWithoutDatabaseReference.size(); i++)
     1594        if (numBadValueLines > 0)
     1595        {
     1596          JSONArray jsonBadValueLines = (JSONArray) jsonIncaFilePropDetails.get("jsonBadValueLines");
     1597          fileWriter.write("Temporary patient ID/header/value type/value string/enumeration list:\n");
     1598          for (int i = 0; i < jsonBadValueLines.size(); i++)
     1599          {
     1600            JSONArray jsonBadLine = (JSONArray)jsonBadValueLines.get(i);
     1601            for (int j = 0; j < jsonBadLine.size(); j++)
     1602            {
     1603              JSONObject jsonBadValue = (JSONObject)jsonBadLine.get(j);
     1604              String patid = (String)jsonBadValue.get("patientId");
     1605              String header = (String)jsonBadValue.get("header");
     1606              String valuetype = (String)jsonBadValue.get("valuetype");
     1607              String valueStr = (String)jsonBadValue.get("valuestring");
     1608              String enumListStr = (String)jsonBadValue.get("enumvalues");
     1609              if (enumListStr == null)
    16021610              {
    1603                 String patId = (String)jsonPatientIdForPersonalNoWithoutDatabaseReference.get(i);
    1604                 fileWriter.write("" + patId + "\n");
     1611                fileWriter.write("" + patid + separator + header + separator + valuetype + separator + valueStr + "\n");
    16051612              }
    1606               fileWriter.write("\n");         
    1607             }
    1608           }
    1609           if (numPatientLateralitiesWithoutDatabaseReference > 0)
    1610           {
    1611             JSONArray jsonPatientLateralitiesWithoutDatabaseReference = (JSONArray) jsonIncaFilePropDetails.get("jsonPatientLateralitiesWithoutDatabaseReference");
    1612             if (jsonPatientLateralitiesWithoutDatabaseReference != null)
    1613             {
    1614               fileWriter.write("Temporary patient ID/laterality for personal number/laterality without database reference:\n");
    1615               for (int i = 0; i < jsonPatientLateralitiesWithoutDatabaseReference.size(); i++)
     1613              else
    16161614              {
    1617                 JSONObject jsonPnoLat = (JSONObject)jsonPatientLateralitiesWithoutDatabaseReference.get(i);
    1618                 String patid = (String)jsonPnoLat.get("patientId");
    1619                 String lat = (String)jsonPnoLat.get("laterality");
    1620                 fileWriter.write("" + patid + separator + lat + "\n");
     1615                fileWriter.write("" + patid + separator + header + separator + valuetype + separator + valueStr + separator + enumListStr + "\n");
    16211616              }
    1622               fileWriter.write("\n");         
    1623             }
    1624           }
    1625           if (numBadValueLines > 0)
    1626           {
    1627             JSONArray jsonBadValueLines = (JSONArray) jsonIncaFilePropDetails.get("jsonBadValueLines");
    1628             fileWriter.write("Temporary patient ID/header/value type/value string/enumeration list:\n");
    1629             for (int i = 0; i < jsonBadValueLines.size(); i++)
    1630             {
    1631               JSONArray jsonBadLine = (JSONArray)jsonBadValueLines.get(i);
    1632               for (int j = 0; j < jsonBadLine.size(); j++)
    1633               {
    1634                 JSONObject jsonBadValue = (JSONObject)jsonBadLine.get(j);
    1635                 String patid = (String)jsonBadValue.get("patientId");
    1636                 String header = (String)jsonBadValue.get("header");
    1637                 String valuetype = (String)jsonBadValue.get("valuetype");
    1638                 String valueStr = (String)jsonBadValue.get("valuestring");
    1639                 String enumListStr = (String)jsonBadValue.get("enumvalues");
    1640                 if (enumListStr == null)
    1641                 {
    1642                   fileWriter.write("" + patid + separator + header + separator + valuetype + separator + valueStr + "\n");
    1643                 }
    1644                 else
    1645                 {
    1646                   fileWriter.write("" + patid + separator + header + separator + valuetype + separator + valueStr + separator + enumListStr + "\n");
    1647                 }
    1648               }
    1649             }
    1650             fileWriter.write("\n");         
    1651           }
     1617            }
     1618          }
     1619          fileWriter.write("\n");         
    16521620        }
    16531621      }
Note: See TracChangeset for help on using the changeset viewer.