Commit 0bef0912 authored by R.W.Majeed's avatar R.W.Majeed

fixed accurate visit count for export summary.

parent 918aa9fd
......@@ -157,7 +157,8 @@ class FragmentExporter extends VisitFragmentParser {
return patientParser.getRowCount();
}
/**
* Retrieve number of processed visits
* Retrieve number of processed visits. To make sure all visits are processed,
* {@link #close()} must be called prior to this method.
* @return visit count
*/
public int getVisitCount(){
......
......@@ -123,10 +123,11 @@ public class TableExport {
*/
public ExportSummary export(ObservationSupplier supplier, ExportWriter writer) throws ExportException, IOException{
requireDisjointConcepts();
try( FragmentExporter e = new FragmentExporter(createXPath(), desc, writer) ){
e.setErrorHandler(new ExportErrorHandler());
Streams.transfer(supplier, e);
return new ExportSummary(e.getPatientCount(), e.getVisitCount());
FragmentExporter fe = null;
try{
fe = new FragmentExporter(createXPath(), desc, writer);
fe.setErrorHandler(new ExportErrorHandler());
Streams.transfer(supplier, fe);
} catch (XMLStreamException | ParserConfigurationException e) {
throw new ExportException("Unable to create exporter", e);
} catch (UncheckedExportException e ){
......@@ -135,7 +136,13 @@ public class TableExport {
} catch (UncheckedIOException e ){
// unwrap and rethrow
throw e.getCause();
} finally {
// make sure all processing is completed before counting visits
if( fe != null ){
fe.close();
}
}
return new ExportSummary(fe.getPatientCount(), fe.getVisitCount());
}
public int getPatientCount(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment