示例#1
0
  public static MetaResourceSet getPatientAndMedicationStatementEg()
      throws DatatypeConfigurationException {
    MetaResourceSet s1 = new MetaResourceSet();

    Patient p = new Patient();
    p.setId("Patient/1000000005");

    MedicationStatement ms = new MedicationStatement();
    ms.setId("MedicationStatement/1000000005-1");
    ms.setPatient(FhirUtil.getResourceReferenceForRessource(p));

    MetaResource mr1 = new MetaResource();
    MetaData md1 = new MetaData();
    // md1.setId(p.getId());
    mr1.setResource(p);
    mr1.setMetaData(md1);
    GregorianCalendar gc = new GregorianCalendar();
    md1.setLastUpdated(DatatypeFactory.newInstance().newXMLGregorianCalendar(gc));
    s1.getMetaResource().add(mr1);

    MetaResource mr2 = new MetaResource();
    MetaData md2 = new MetaData();
    // md2.setId(ms.getId());
    mr2.setResource(ms);
    mr2.setMetaData(md2);
    md2.setLastUpdated(DatatypeFactory.newInstance().newXMLGregorianCalendar(gc));

    s1.getMetaResource().add(mr2);
    return s1;
  }
  private void fetchPatientList(
      String i2b2User, String i2b2Token, String i2b2Url, String i2b2Domain, String projectId)
      throws FhirServerException {
    status.markProcessing(projectId);
    try {
      logger.trace("fetching all Patients for project:" + projectId);
      String i2b2Xml = null;
      Bundle b = new Bundle();
      ArrayList<String> list = null;

      if (serverConfigs.GetString(ConfigParameter.patientFetchMin) != null
          && serverConfigs.GetString(ConfigParameter.patientFetchMin).equals("true")) {
        logger.debug("min call");
        i2b2Xml = I2b2Util.getAllPatientsMin(i2b2User, i2b2Token, i2b2Url, i2b2Domain, projectId);

        list = I2b2Util.getAllPatientsAsList(i2b2Xml);

        for (String id : list) {
          Patient p = new Patient();
          p = (Patient) FhirUtil.setId(p, id);
          BundleEntry be = new BundleEntry();
          be.setResource(FhirUtil.getResourceContainer(p));
          b.getEntry().add(be);
        }

      } else {
        logger.debug("max call");
        i2b2Xml = I2b2Util.getAllPatients(i2b2User, i2b2Token, i2b2Url, i2b2Domain, projectId);
        list = I2b2Util.getAllPatientsAsList(i2b2Xml);
        b = I2b2Util.getAllPatientsAsFhirBundle(i2b2Xml);
      }

      String bundleXml = JAXBUtil.toXml(b);
      service.put(projectId, list, bundleXml);
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      throw new FhirServerException("Could not fetch patient list from i2b2 server");
    }
    status.markComplete(projectId);
  }
示例#3
0
 @Test
 public void test() {
   FhirUtil.initResourceClassList();
 }