public static void main(String[] args) throws IOException, Exception { if (args.length < 4) { System.out.println("Batch uploader takes 4 parameters in order: server base url, file/folder to upload, xml/json, and batch size"); } else { String server = args[0]; String file = args[1]; IParser p = new JsonParser(); // args[2].equals("json") ? new JsonParser() : new XmlParser(); int size = Integer.parseInt(args[3]); size = 500; if (file.endsWith(".xml")) { throw new FHIRException("Unimplemented file type "+file); } else if (file.endsWith(".json")) { throw new FHIRException("Unimplemented file type "+file); } else if (file.endsWith(".zip")) { LoadZipFile(server, file, p, size, 0, -1); } else if (new File(file).isDirectory()) { LoadDirectory(server, file, p, size); } else throw new FHIRException("Unknown file type "+file); } }
private static void LoadZipFile(String server, String file, IParser p, int size, int start, int end) throws IOException, Exception { System.out.println("Load Zip file "+file); Bundle b = new Bundle(); b.setType(BundleType.COLLECTION); b.setId(UUID.randomUUID().toString().toLowerCase()); ZipInputStream zip = new ZipInputStream(new FileInputStream(file)); ZipEntry entry; while((entry = zip.getNextEntry())!=null) { try { Resource r = p.parse(zip); b.addEntry().setResource(r); } catch (Exception e) { throw new Exception("Error parsing "+entry.getName()+": "+e.getMessage(), e); } } loadBundle(server, b, size, start, end); }
private static void LoadDirectory(String server, String file, IParser p, int size) throws IOException, Exception { // LoadZipFile(server, Utilities.path(file, "Patient.json.zip"), p, size, 1000, -1); // LoadZipFile(server, Utilities.path(file, "Binary.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "DocumentReference.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Encounter.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Organization.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Procedure.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "AllergyIntolerance.json.zip"), p, size, 1500, -1); // LoadZipFile(server, Utilities.path(file, "Condition.json.zip"), p, size, 0, -1); LoadZipFile(server, Utilities.path(file, "Immunization.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "MedicationStatement.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-res.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-sh.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-vs.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-gen.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "List.json.zip"), p, size, 6500, -1); // LoadZipFile(server, Utilities.path(file, "List-res.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "List-vs.json.zip"), p, size, 0, -1); }
private static void LoadDirectory(String server, String file, IParser p, int size) throws IOException, Exception { // LoadZipFile(server, Utilities.path(file, "Patient.json.zip"), p, size, 1000, -1); // LoadZipFile(server, Utilities.path(file, "Binary.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "DocumentReference.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Encounter.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Organization.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Procedure.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "AllergyIntolerance.json.zip"), p, size, 1500, -1); // LoadZipFile(server, Utilities.path(file, "Condition.json.zip"), p, size, 0, -1); LoadZipFile(server, Utilities.path(file, "Immunization.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "MedicationStatement.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-res.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-sh.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-vs.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "Observation-gen.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "List.json.zip"), p, size, 6500, -1); // LoadZipFile(server, Utilities.path(file, "List-res.json.zip"), p, size, 0, -1); // LoadZipFile(server, Utilities.path(file, "List-vs.json.zip"), p, size, 0, -1); }
public static void main(String[] args) throws IOException, Exception { if (args.length < 4) { System.out.println("Batch uploader takes 4 parameters in order: server base url, file/folder to upload, xml/json, and batch size"); } else { String server = args[0]; String file = args[1]; IParser p = new JsonParser(); // args[2].equals("json") ? new JsonParser() : new XmlParser(); int size = Integer.parseInt(args[3]); size = 500; if (file.endsWith(".xml")) { throw new FHIRException("Unimplemented file type "+file); } else if (file.endsWith(".json")) { throw new FHIRException("Unimplemented file type "+file); } else if (file.endsWith(".zip")) { LoadZipFile(server, file, p, size, 0, -1); } else if (new File(file).isDirectory()) { LoadDirectory(server, file, p, size); } else throw new FHIRException("Unknown file type "+file); } }
private static void LoadZipFile(String server, String file, IParser p, int size, int start, int end) throws IOException, Exception { System.out.println("Load Zip file "+file); Bundle b = new Bundle(); b.setType(BundleType.COLLECTION); b.setId(UUID.randomUUID().toString().toLowerCase()); ZipInputStream zip = new ZipInputStream(new FileInputStream(file)); ZipEntry entry; while((entry = zip.getNextEntry())!=null) { try { Resource r = p.parse(zip); b.addEntry().setResource(r); } catch (Exception e) { throw new Exception("Error parsing "+entry.getName()+": "+e.getMessage(), e); } } loadBundle(server, b, size, start, end); }