Java Code Examples for org.hl7.fhir.dstu3.model.ValueSet#hasCompose()

The following examples show how to use org.hl7.fhir.dstu3.model.ValueSet#hasCompose() . 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: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private Integer countMembership(ValueSet vs) {
  int count = 0;
  if (vs.hasExpansion())
    count = count + conceptCount(vs.getExpansion().getContains());
  else {
    if (vs.hasCompose()) {
      if (vs.getCompose().hasExclude()) {
        try {
          ValueSetExpansionOutcome vse = context.expandVS(vs, true, false);
          count = 0;
          count += conceptCount(vse.getValueset().getExpansion().getContains());
          return count;
        } catch (Exception e) {
          return null;
        }
      }
      for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
        if (inc.hasFilter())
          return null;
        if (!inc.hasConcept())
          return null;
        count = count + inc.getConcept().size();
      }
    }
  }
  return count;
}
 
Example 2
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean checkDoSystem(ValueSet vs, ValueSet src) {
  if (src != null)
    vs = src;
  if (vs.hasCompose())
    return true;
  return false;
}
 
Example 3
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean IsNotFixedExpansion(ValueSet vs) {
  if (vs.hasCompose())
    return false;


  // it's not fixed if it has any includes that are not version fixed
  for (ConceptSetComponent cc : vs.getCompose().getInclude()) {
    if (cc.hasValueSet())
      return true;
    if (!cc.hasVersion())
      return true;
  }
  return false;
}
 
Example 4
Source File: CodeSystemUpdateProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public OperationOutcome performCodeSystemUpdate(ValueSet vs)
{
    OperationOutcomeBuilder responseBuilder = new OperationOutcomeBuilder();

    List<String> codeSystems = new ArrayList<>();
    if (vs.hasCompose() && vs.getCompose().hasInclude())
    {
        CodeSystem codeSystem;
        for (ValueSet.ConceptSetComponent csc : vs.getCompose().getInclude())
        {
            if (!csc.hasSystem()) continue;

            codeSystem = getCodeSystemByUrl(csc.getSystem());

            if (!csc.hasConcept()) continue;

            updateCodeSystem(
                    codeSystem.setUrl(csc.getSystem()),
                    getUnionDistinctCodes(csc, codeSystem)
            );

            codeSystems.add(codeSystem.getUrl());
        }
    }

    return responseBuilder.buildIssue(
            "information",
            "informational",
            "Successfully updated the following CodeSystems: " + String.join(", ", codeSystems)
    ).build();
}
 
Example 5
Source File: ValidationSupportSTU3.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);
}