use of org.hl7.fhir.r5.elementmodel.JsonParser in project org.hl7.fhir.core by hapifhir.
the class PhinVadsImporter method process.
private void process(String source, String dest) {
for (File f : new File(source).listFiles()) {
try {
System.out.println("Process " + f.getName());
ValueSet vs = importValueSet(TextFile.fileToBytes(f));
if (vs.getId() != null) {
new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + vs.getId() + ".json")), vs);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of org.hl7.fhir.r5.elementmodel.JsonParser in project org.hl7.fhir.core by hapifhir.
the class VSACImporter method process.
private void process(String source, String dest, String username, String password) throws FHIRException, IOException, URISyntaxException {
CSVReader csv = new CSVReader(new FileInputStream(source));
csv.readHeaders();
FHIRToolingClient fhirToolingClient = new FHIRToolingClient("https://cts.nlm.nih.gov/fhir", "fhir/vsac");
fhirToolingClient.setUsername(username);
fhirToolingClient.setPassword(password);
int i = 0;
while (csv.line()) {
String oid = csv.cell("OID");
try {
ValueSet vs = fhirToolingClient.read(ValueSet.class, oid);
new JsonParser().compose(new FileOutputStream(Utilities.path(dest, "ValueSet-" + oid + ".json")), vs);
i++;
if (i % 100 == 0) {
System.out.println(i);
}
} catch (Exception e) {
System.out.println("Unable to fetch OID " + oid + ": " + e.getMessage());
}
}
System.out.println("Done. " + i + " ValueSets");
}
use of org.hl7.fhir.r5.elementmodel.JsonParser in project org.hl7.fhir.core by hapifhir.
the class Convertor_Factory_40_50Test method convertBundleContainingAccountsToTestPathing.
@Test
void convertBundleContainingAccountsToTestPathing() throws IOException {
JsonParser r4parser = new JsonParser();
org.hl7.fhir.r5.formats.JsonParser r5parser = new org.hl7.fhir.r5.formats.JsonParser();
InputStream accountr4InputStream = this.getClass().getResourceAsStream("/bundle_of_accounts_path_test_r4.json");
org.hl7.fhir.r4.model.Bundle bundle_r4 = (org.hl7.fhir.r4.model.Bundle) r4parser.parse(accountr4InputStream);
Resource account_r5 = VersionConvertorFactory_40_50.convertResource(bundle_r4);
System.out.println(r5parser.composeString(account_r5));
}
use of org.hl7.fhir.r5.elementmodel.JsonParser in project org.hl7.fhir.core by hapifhir.
the class Convertor_Factory_40_50Test method convertResource.
@Test
void convertResource() throws IOException {
JsonParser r4parser = new JsonParser();
org.hl7.fhir.r5.formats.JsonParser r5parser = new org.hl7.fhir.r5.formats.JsonParser();
InputStream accountr4InputStream = this.getClass().getResourceAsStream("/account_r4.json");
org.hl7.fhir.r4.model.Account account_r4 = (org.hl7.fhir.r4.model.Account) r4parser.parse(accountr4InputStream);
Resource account_r5 = VersionConvertorFactory_40_50.convertResource(account_r4);
System.out.println(r5parser.composeString(account_r5));
}
use of org.hl7.fhir.r5.elementmodel.JsonParser in project org.hl7.fhir.core by hapifhir.
the class UTGCaseSensitivePopulator method scanFolders.
private void scanFolders(File folder, Bundle bundle) throws FileNotFoundException, IOException {
Calendar today = Calendar.getInstance();
Date dt = today.getTime();
today.set(Calendar.HOUR_OF_DAY, 0);
Date d = today.getTime();
System.out.println("Scan " + folder.getAbsolutePath());
for (File f : folder.listFiles()) {
if (f.isDirectory() && !f.getName().equals("retired")) {
scanFolders(f, bundle);
} else if (f.getName().endsWith(".xml")) {
processFile(f, bundle, new XmlParser(), d, dt);
} else if (f.getName().endsWith(".json")) {
processFile(f, bundle, new JsonParser(), d, dt);
}
}
}
Aggregations