当前位置: 首页>>代码示例>>Java>>正文


Java FhirContext.forDstu2方法代码示例

本文整理汇总了Java中ca.uhn.fhir.context.FhirContext.forDstu2方法的典型用法代码示例。如果您正苦于以下问题:Java FhirContext.forDstu2方法的具体用法?Java FhirContext.forDstu2怎么用?Java FhirContext.forDstu2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.uhn.fhir.context.FhirContext的用法示例。


在下文中一共展示了FhirContext.forDstu2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFHIRDSTU2Export

import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
@Test
public void testFHIRDSTU2Export() throws Exception {
  FhirContext ctx = FhirContext.forDstu2();
  FhirValidator validator = ctx.newValidator();
  validator.setValidateAgainstStandardSchema(true);
  validator.setValidateAgainstStandardSchematron(true);

  File tempOutputFolder = tempFolder.newFolder();
  Config.set("exporter.baseDirectory", tempOutputFolder.toString());
  Config.set("exporter.hospital.fhir_dstu2.export", "true");
  Hospital.loadHospitals();
  assertNotNull(Hospital.getHospitalList());
  assertFalse(Hospital.getHospitalList().isEmpty());

  Hospital.getHospitalList().get(0).incrementEncounters(EncounterType.WELLNESS.toString(), 0);
  HospitalDSTU2Exporter.export(0L);

  File expectedExportFolder = tempOutputFolder.toPath().resolve("fhir_dstu2").toFile();
  assertTrue(expectedExportFolder.exists() && expectedExportFolder.isDirectory());

  File expectedExportFile = expectedExportFolder.toPath().resolve("hospitalInformation0.json")
      .toFile();
  assertTrue(expectedExportFile.exists() && expectedExportFile.isFile());

  FileReader fileReader = new FileReader(expectedExportFile.getPath());
  BufferedReader bufferedReader = new BufferedReader(fileReader);
  StringBuilder fhirJson = new StringBuilder();
  String line = null;
  while ((line = bufferedReader.readLine()) != null) {
    fhirJson.append(line);
  }
  bufferedReader.close();
  IBaseResource resource = ctx.newJsonParser().parseResource(fhirJson.toString());
  ValidationResult result = validator.validateWithResult(resource);
  if (result.isSuccessful() == false) {
    for (SingleValidationMessage message : result.getMessages()) {
      System.out.println(message.getSeverity().toString() + ": " + message.getMessage());
    }
  }
  assertTrue(result.isSuccessful());
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:42,代码来源:HospitalDSTU2ExporterTest.java

示例2: testFHIRDSTU2Export

import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
@Test
public void testFHIRDSTU2Export() throws Exception {
  Config.set("exporter.baseDirectory", tempFolder.newFolder().toString());
  
  FhirContext ctx = FhirContext.forDstu2();
  IParser parser = ctx.newJsonParser().setPrettyPrint(true);

  FhirValidator validator = ctx.newValidator();
  validator.setValidateAgainstStandardSchema(true);
  validator.setValidateAgainstStandardSchematron(true);

  List<String> validationErrors = new ArrayList<String>();

  int numberOfPeople = 10;
  Generator generator = new Generator(numberOfPeople);
  for (int i = 0; i < numberOfPeople; i++) {
    int x = validationErrors.size();
    TestHelper.exportOff();
    Person person = generator.generatePerson(i);
    Config.set("exporter.fhir_dstu2.export", "true");
    String fhirJson = FhirDstu2.convertToFHIR(person, System.currentTimeMillis());
    IBaseResource resource = ctx.newJsonParser().parseResource(fhirJson);
    ValidationResult result = validator.validateWithResult(resource);
    if (result.isSuccessful() == false) {
      // If the validation failed, let's crack open the Bundle and validate
      // each individual entry.resource to get context-sensitive error
      // messages...
      Bundle bundle = parser.parseResource(Bundle.class, fhirJson);
      for (Entry entry : bundle.getEntry()) {
        ValidationResult eresult = validator.validateWithResult(entry.getResource());
        if (eresult.isSuccessful() == false) {
          for (SingleValidationMessage emessage : eresult.getMessages()) {
            System.out.println(parser.encodeResourceToString(entry.getResource()));
            System.out.println("ERROR: " + emessage.getMessage());
            validationErrors.add(emessage.getMessage());
          }
        }
        
      }
    }
    int y = validationErrors.size();
    if (x != y) {
      Exporter.export(person, System.currentTimeMillis());
    }
  }

  assertEquals(0, validationErrors.size());
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:49,代码来源:FHIRDSTU2ExporterTest.java

示例3: FhirResourceValidator

import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public FhirResourceValidator(StringBuilder jsonResource)
{
    this._jsonResource=jsonResource;
    _context=FhirContext.forDstu2();
    _parser=_context.newJsonParser();
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:7,代码来源:FhirResourceValidator.java


注:本文中的ca.uhn.fhir.context.FhirContext.forDstu2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。