Java Code Examples for org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent#getDisplay()

The following examples show how to use org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent#getDisplay() . 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: ValueSetExpanderSimple.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private String getCodeDisplay(CodeSystem cs, String code) throws TerminologyServiceException {
  ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), code);
  if (def == null)
    throw new TerminologyServiceException("Unable to find code '" + code + "' in code system " + cs.getUrl());
  return def.getDisplay();
}
 
Example 2
Source File: ValidationSupportR4.java    From synthea with Apache License 2.0 4 votes vote down vote up
@Override
public CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem,
    String theCode, String theDisplay, String theValueSetUrl) {
  IssueSeverity severity = IssueSeverity.WARNING;
  String message = "Unsupported CodeSystem";

  if (isCodeSystemSupported(theContext, theCodeSystem)) {
    severity = IssueSeverity.ERROR;
    message = "Code not found";

    CodeSystem cs = codeSystemMap.get(theCodeSystem);
    for (ConceptDefinitionComponent def : cs.getConcept()) {
      if (def.getCode().equals(theCode)) {
        if (def.getDisplay() != null && theDisplay != null) {
          if (def.getDisplay().equals(theDisplay)) {
            severity = IssueSeverity.INFORMATION;
            message = "Validated Successfully";
          } else {
            severity = IssueSeverity.WARNING;
            message = "Validated Code; Display mismatch";
          }
        } else {
          severity = IssueSeverity.WARNING;
          message = "Validated Code; No display";
        }
      }
    }
  }

  ValueSet vs = fetchValueSet(theContext, theValueSetUrl);
  if (vs != null && vs.hasCompose() && vs.getCompose().hasExclude()) {
    for (ConceptSetComponent exclude : vs.getCompose().getExclude()) {
      if (exclude.getSystem().equals(theCodeSystem) && exclude.hasConcept()) {
        for (ConceptReferenceComponent concept : exclude.getConcept()) {
          if (concept.getCode().equals(theCode)) {
            severity = IssueSeverity.ERROR;
            message += "; Code Excluded from ValueSet";
          }
        }
      }
    }
  }

  return new CodeValidationResult(severity, message);
}