Java Code Examples for org.hl7.fhir.dstu3.model.Bundle#setId()

The following examples show how to use org.hl7.fhir.dstu3.model.Bundle#setId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ObservationStatsBuilder.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private static void buildVitalSignsSet() throws FileNotFoundException, IOException, FHIRFormatError {
  Calendar base = Calendar.getInstance();
  base.add(Calendar.DAY_OF_MONTH, -1);
  Bundle b = new Bundle();
  b.setType(BundleType.COLLECTION);
  b.setId(UUID.randomUUID().toString().toLowerCase());
  
  vitals(b, base, 0, 80, 120, 95, 37.1);
  vitals(b, base, 35, 85, 140, 98, 36.9);
  vitals(b, base, 53, 75, 110, 96, 36.2);
  vitals(b, base, 59, 65, 100, 94, 35.5);
  vitals(b, base, 104, 60, 90, 90, 35.9);
  vitals(b, base, 109, 65, 100, 92, 36.5);
  vitals(b, base, 114, 70, 130, 94, 37.5);
  vitals(b, base, 120, 90, 150, 97, 37.3);
  vitals(b, base, 130, 95, 133, 97, 37.2);
  vitals(b, base, 150, 85, 125, 98, 37.1);
  
  new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\vitals.xml"), b);
}
 
Example 2
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public Bundle process(String sourceFile) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
  this.definitions = sourceFile;
  log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions);
  loadLoinc();
  log("LOINC loaded");

  now = DateTimeType.now();

  bundle = new Bundle();
  bundle.setType(BundleType.COLLECTION);
  bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
  bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));

  processLoincCodes();
  return bundle;
}
 
Example 3
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public void process() throws FHIRFormatError, IOException, XmlPullParserException, SAXException, ParserConfigurationException {
	log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions);
	loadLoinc();
	log("LOINC loaded");

	now = DateTimeType.now();

	bundle = new Bundle();
	bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
   bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));

	processLoincCodes();
	if (dest != null) {
		log("Saving...");
		saveBundle();
	}
	log("Done");

}
 
Example 4
Source File: ObservationStatsBuilder.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
/**
*     

* @throws FHIRException
* @throws IOException
* @throws FileNotFoundException
*/
 public static void buildStatsSeries() throws FHIRException, IOException, FileNotFoundException {
   Bundle b = new Bundle();
   b.setType(BundleType.COLLECTION);
   b.setId(UUID.randomUUID().toString().toLowerCase());

   addAge(b, 5, 1, "18.3");
   addAge(b, 5, 2, "18.4");
   addAge(b, 5, 3, "18.6");
   addAge(b, 5, 4, "18.8");
   addAge(b, 5, 5, "19.0");
   addAge(b, 5, 6, "19.1");
   addAge(b, 5, 7, "19.3");
   addAge(b, 5, 8, "19.5");
   addAge(b, 5, 9, "19.6");
   addAge(b, 5,10, "19.8");
   addAge(b, 5,11, "20.0");
   addAge(b, 6, 0, "20.2");
   addAge(b, 6, 1, "20.3");
   addAge(b, 6, 2, "20.5");
   addAge(b, 6, 3, "20.7");
   addAge(b, 6, 4, "20.9");
   addAge(b, 6, 5, "21.0");
   addAge(b, 6, 6, "21.2");
   addAge(b, 6, 7, "21.4");
   addAge(b, 6, 8, "21.6");
   addAge(b, 6, 9, "21.8");
   addAge(b, 6,10, "22.0");
   addAge(b, 6,11, "22.2");
   addAge(b, 7, 0, "22.4");
   addAge(b, 7, 1, "22.6");
   addAge(b, 7, 2, "22.8");
   addAge(b, 7, 3, "23.0");
   addAge(b, 7, 4, "23.2");
   addAge(b, 7, 5, "23.4");
   addAge(b, 7, 6, "23.6");
   addAge(b, 7, 7, "23.9");
   addAge(b, 7, 8, "24.1");
   addAge(b, 7, 9, "24.3");
   addAge(b, 7,10, "24.5");
   addAge(b, 7,11, "24.8");
   addAge(b, 8, 0, "25.0");
   addAge(b, 8, 1, "25.3");
   addAge(b, 8, 2, "25.5");
   addAge(b, 8, 3, "25.8");
   addAge(b, 8, 4, "26.0");
   addAge(b, 8, 5, "26.3");
   addAge(b, 8, 6, "26.6");
   addAge(b, 8, 7, "26.8");
   addAge(b, 8, 8, "27.1");
   addAge(b, 8, 9, "27.4");
   addAge(b, 8,10, "27.6");
   addAge(b, 8,11, "27.9");
   addAge(b, 9, 0, "28.2");
   addAge(b, 9, 1, "28.5");
   addAge(b, 9, 2, "28.8");
   addAge(b, 9, 3, "29.1");
   addAge(b, 9, 4, "29.4");
   addAge(b, 9, 5, "29.7");
   addAge(b, 9, 6, "30.0");
   addAge(b, 9, 7, "30.3");
   addAge(b, 9, 8, "30.6");
   addAge(b, 9, 9, "30.9");
   addAge(b, 9, 10, "31.2");
   addAge(b, 9, 11, "31.5");
   addAge(b, 10, 0, "31.9");

 
   new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\obs.xml"), b);
 }
 
Example 5
Source File: BatchLoader.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private static void sendFile(FHIRToolingClient client, File f, int size, IniFile ini) throws FHIRFormatError, FileNotFoundException, IOException {
  long ms = System.currentTimeMillis();
  System.out.print("Loading "+f.getName()+".. ");
  IParser parser = f.getName().endsWith(".json") ? new JsonParser() : new XmlParser();
  Resource res = parser.parse(new FileInputStream(f));
  System.out.println("  done: ("+Long.toString(System.currentTimeMillis()-ms)+" ms)");
  
  if (res instanceof Bundle) {
    Bundle bnd = (Bundle) res;
    int cursor = ini.hasProperty("progress", f.getName()) ? ini.getIntegerProperty("progress", f.getName()) : 0;
    while (cursor < bnd.getEntry().size()) {
      Bundle bt = new Bundle();
      bt.setType(BundleType.BATCH);     
      bt.setId(UUID.randomUUID().toString().toLowerCase());
      for (int i = cursor; i < Math.min(bnd.getEntry().size(), cursor+size); i++) {
        if (i >=0 && i < bnd.getEntry().size()) {
          BundleEntryComponent be = bt.addEntry();
          be.setResource(bnd.getEntry().get(i).getResource());
          be.getRequest().setMethod(HTTPVerb.PUT);
          be.getRequest().setUrl(be.getResource().getResourceType().toString()+"/"+be.getResource().getId());
        }
      }
      System.out.print(f.getName()+" ("+cursor+"/"+bnd.getEntry().size()+"): ");
      ms = System.currentTimeMillis();
      Bundle resp = client.transaction(bt);

      int ncursor = cursor+size;
      for (int i = 0; i < resp.getEntry().size(); i++) {
        BundleEntryComponent t = resp.getEntry().get(i);
        if (!t.getResponse().getStatus().startsWith("2")) { 
          System.out.println("failed status at "+Integer.toString(i)+": "+t.getResponse().getStatus());
          ncursor = cursor+i-1;
          break;
        }
      }
      cursor = ncursor;
      System.out.println("  .. done: ("+Long.toString(System.currentTimeMillis()-ms)+" ms) "+SimpleDateFormat.getInstance().format(new Date()));
      ini.setIntegerProperty("progress", f.getName(), cursor, null);
      ini.save();
    }
    ini.setBooleanProperty("finished", f.getName(), true, null);
    ini.save();
  } else {
    client.update(res);
    ini.setBooleanProperty("finished", f.getName(), true, null);
    ini.save();
  }    
}