org.hl7.fhir.dstu3.model.DiagnosticReport Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.DiagnosticReport. 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: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam DiagnosticReport diagnosticReport, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    try {
    DiagnosticReport newDiagnosticReport = diagnosticReportDao.create(ctx,diagnosticReport, theId, theConditional);
    method.setId(newDiagnosticReport.getIdElement());
    method.setResource(newDiagnosticReport);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #2
Source File: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam DiagnosticReport diagnosticReport) {

	resourcePermissionProvider.checkPermission("create");
	MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    try {
    DiagnosticReport newDiagnosticReport = diagnosticReportDao.create(ctx,diagnosticReport, null,null);
    method.setId(newDiagnosticReport.getIdElement());
    method.setResource(newDiagnosticReport);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #3
Source File: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Search
public List<DiagnosticReport> search(HttpServletRequest theRequest,
                              @OptionalParam(name = DiagnosticReport.SP_PATIENT) ReferenceParam patient
        , @OptionalParam(name = DiagnosticReport.SP_IDENTIFIER) TokenParam identifier
        , @OptionalParam(name = DiagnosticReport.SP_RES_ID) StringParam resid
                              ) {
    return diagnosticReportDao.search(ctx,patient,identifier,resid);
}
 
Example #4
Source File: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Read()
public DiagnosticReport get(@IdParam IdType diagnosticReportId) {
	resourcePermissionProvider.checkPermission("read");
    DiagnosticReport diagnosticReport = diagnosticReportDao.read(ctx,diagnosticReportId);

    if ( diagnosticReport == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No DiagnosticReport/ " + diagnosticReportId.getIdPart()),
                 OperationOutcome.IssueType.NOTFOUND);
    }

    return diagnosticReport;
}
 
Example #5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public boolean generate(ResourceContext rcontext, DomainResource r) throws EOperationOutcome, FHIRException, IOException {
  if (rcontext == null)
    rcontext = new ResourceContext(null, r);
  
  if (r instanceof ConceptMap) {
    return generate(rcontext, (ConceptMap) r); // Maintainer = Grahame
  } else if (r instanceof ValueSet) {
    return generate(rcontext, (ValueSet) r, true); // Maintainer = Grahame
  } else if (r instanceof CodeSystem) {
    return generate(rcontext, (CodeSystem) r, true); // Maintainer = Grahame
  } else if (r instanceof OperationOutcome) {
    return generate(rcontext, (OperationOutcome) r); // Maintainer = Grahame
  } else if (r instanceof CapabilityStatement) {
    return generate(rcontext, (CapabilityStatement) r);   // Maintainer = Grahame
  } else if (r instanceof CompartmentDefinition) {
    return generate(rcontext, (CompartmentDefinition) r);   // Maintainer = Grahame
  } else if (r instanceof OperationDefinition) {
    return generate(rcontext, (OperationDefinition) r);   // Maintainer = Grahame
  } else if (r instanceof StructureDefinition) {
    return generate(rcontext, (StructureDefinition) r);   // Maintainer = Grahame
  } else if (r instanceof ImplementationGuide) {
    return generate(rcontext, (ImplementationGuide) r);   // Maintainer = Lloyd (until Grahame wants to take over . . . :))
  } else if (r instanceof DiagnosticReport) {
    inject(r, generateDiagnosticReport(new ResourceWrapperDirect(r)),  NarrativeStatus.GENERATED);   // Maintainer = Grahame
    return true;
  } else {
    StructureDefinition p = null;
    if (r.hasMeta())
      for (UriType pu : r.getMeta().getProfile())
        if (p == null)
          p = context.fetchResource(StructureDefinition.class, pu.getValue());
    if (p == null)
      p = context.fetchResource(StructureDefinition.class, r.getResourceType().toString());
    if (p == null)
      p = context.fetchTypeDefinition(r.getResourceType().toString().toLowerCase());
    if (p != null)
      return generateByProfile(r, p, true);
    else
      return false;
  }
}
 
Example #6
Source File: DiagnosticReportEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public DiagnosticReport.DiagnosticReportStatus getStatus() {
    return status;
}
 
Example #7
Source File: DiagnosticReportEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public DiagnosticReportEntity setStatus(DiagnosticReport.DiagnosticReportStatus status) {
    this.status = status;
    return this;
}
 
Example #8
Source File: DiagnosticReportRepository.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
List<DiagnosticReportEntity> searchEntity(FhirContext ctx,
                                     @OptionalParam(name = DiagnosticReport.SP_PATIENT) ReferenceParam patient
        , @OptionalParam(name = DiagnosticReport.SP_IDENTIFIER) TokenParam identifier
        , @OptionalParam(name = DiagnosticReport.SP_RES_ID) StringParam id
);
 
Example #9
Source File: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends IBaseResource> getResourceType() {
    return DiagnosticReport.class;
}
 
Example #10
Source File: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Validate
public MethodOutcome testResource(@ResourceParam DiagnosticReport resource,
                              @Validate.Mode ValidationModeEnum theMode,
                              @Validate.Profile String theProfile) {
    return resourceTestProvider.testResource(resource,theMode,theProfile);
}
 
Example #11
Source File: DiagnosticReportEntityToFHIRDiagnosticReportTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public DiagnosticReport transform(final DiagnosticReportEntity diagnosticReportEntity) {
    final DiagnosticReport diagnosticReport = new DiagnosticReport();

    Meta meta = new Meta();
            //.addProfile(CareConnectProfile.Condition_1);

    if (diagnosticReportEntity.getUpdated() != null) {
        meta.setLastUpdated(diagnosticReportEntity.getUpdated());
    }
    else {
        if (diagnosticReportEntity.getCreated() != null) {
            meta.setLastUpdated(diagnosticReportEntity.getCreated());
        }
    }
    diagnosticReport.setMeta(meta);

    diagnosticReport.setId(diagnosticReportEntity.getId().toString());



    if (diagnosticReportEntity.getStatus() != null) {
        diagnosticReport.setStatus(diagnosticReportEntity.getStatus());
    }

    if (diagnosticReportEntity.getPatient() != null) {
        diagnosticReport
                .setSubject(new Reference("Patient/"+diagnosticReportEntity.getPatient().getId())
                .setDisplay(diagnosticReportEntity.getPatient().getNames().get(0).getDisplayName()));
    }



    for (DiagnosticReportIdentifier identifier : diagnosticReportEntity.getIdentifiers()) {
        Identifier ident = diagnosticReport.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    for (DiagnosticReportResult reportResult : diagnosticReportEntity.getResults()) {
        diagnosticReport.addResult(new Reference("Observation/"+reportResult.getObservation().getId()));
    }

    return diagnosticReport;

}
 
Example #12
Source File: FHIRDSTU2ExporterTest.java    From synthea with Apache License 2.0 4 votes vote down vote up
@Test
public void testFHIRDSTU2Export() throws Exception {
  TestHelper.loadTestProperties();
  Generator.DEFAULT_STATE = Config.get("test_state.default", "Massachusetts");
  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);
  generator.options.overflow = false;
  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");
    FhirDstu2.TRANSACTION_BUNDLE = person.random.nextBoolean();
    String fhirJson = FhirDstu2.convertToFHIRJson(person, System.currentTimeMillis());
    // Check that the fhirJSON doesn't contain unresolved SNOMED-CT strings
    // (these should have been converted into URIs)
    if (fhirJson.contains("SNOMED-CT")) {
      validationErrors.add(
          "JSON contains unconverted references to 'SNOMED-CT' (should be URIs)");
    }
    // Now validate the resource...
    IBaseResource resource = ctx.newJsonParser().parseResource(fhirJson);
    ValidationResult result = validator.validateWithResult(resource);
    if (!result.isSuccessful()) {
      // 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()) {
          for (SingleValidationMessage emessage : eresult.getMessages()) {
            System.out.println(parser.encodeResourceToString(entry.getResource()));
            System.out.println("ERROR: " + emessage.getMessage());
            validationErrors.add(emessage.getMessage());
          }
        }
        if (entry.getResource() instanceof DiagnosticReport) {
          DiagnosticReport report = (DiagnosticReport) entry.getResource();
          if (report.getPerformer().isEmpty()) {
            validationErrors.add("Performer is a required field on DiagnosticReport!");
          }
        }
      }
    }
    int y = validationErrors.size();
    if (x != y) {
      Exporter.export(person, System.currentTimeMillis());
    }
  }

  assertTrue("Validation of exported FHIR bundle failed: " 
      + String.join("|", validationErrors), validationErrors.size() == 0);
}
 
Example #13
Source File: DiagnosticReportRepository.java    From careconnect-reference-implementation with Apache License 2.0 3 votes vote down vote up
List<DiagnosticReport> search(FhirContext ctx,

                             @OptionalParam(name = DiagnosticReport.SP_PATIENT) ReferenceParam patient
            , @OptionalParam(name = DiagnosticReport.SP_IDENTIFIER) TokenParam identifier
            , @OptionalParam(name = DiagnosticReport.SP_RES_ID) StringParam id

    );
 
Example #14
Source File: DiagnosticReportRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
DiagnosticReport read(FhirContext ctx, IdType theId); 
Example #15
Source File: DiagnosticReportRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
DiagnosticReport create(FhirContext ctx, DiagnosticReport diagnosticReport, @IdParam IdType theId, @ConditionalUrlParam String theConditional) throws OperationOutcomeException;