private void validateIncludes(String name, List<ConceptSetComponent> listToValidate) {
   for (ConceptSetComponent nextExclude : listToValidate) {
     if (isBlank(nextExclude.getSystem())
         && !ElementUtil.isEmpty(nextExclude.getConcept(), nextExclude.getFilter())) {
       throw new InvalidRequestException(
           "ValueSet contains " + name + " criteria with no system defined");
     }
   }
 }
Example #2
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType,
       mySubject,
       myOrderer,
       myIdentifier,
       myEncounter,
       myClinicalNotes,
       mySpecimen,
       myStatus,
       myPriority,
       myEvent,
       myItem);
 }
Example #3
0
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(
           mySubject,
           myOrderer,
           myIdentifier,
           myEncounter,
           myClinicalNotes,
           mySpecimen,
           myStatus,
           myPriority,
           myEvent,
           myItem);
 }
Example #4
0
 public boolean isEmpty() {
   return super.isEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(
           identifier,
           ruleset,
           originalRuleset,
           created,
           target,
           provider,
           organization,
           request,
           response,
           paymentStatus,
           statusDate);
 }
Example #5
0
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(
           myName,
           myStatus,
           myIssued,
           mySubject,
           myPerformer,
           myIdentifier,
           myRequestDetail,
           myServiceCategory,
           myDiagnostic,
           mySpecimen,
           myResult,
           myImagingStudy,
           myImage,
           myConclusion,
           myCodedDiagnosis,
           myPresentedForm);
 }
Example #6
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType,
       myName,
       myStatus,
       myIssued,
       mySubject,
       myPerformer,
       myIdentifier,
       myRequestDetail,
       myServiceCategory,
       myDiagnostic,
       mySpecimen,
       myResult,
       myImagingStudy,
       myImage,
       myConclusion,
       myCodedDiagnosis,
       myPresentedForm);
 }
Example #7
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType, myStatus, myDescription, myDateTime, myActor);
 }
Example #8
0
 public boolean isEmpty() {
   return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(low, high);
 }
Example #9
0
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(
           myCode, mySpecimen, myBodySite, myStatus, myEvent);
 }
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(myValue, myComparator, myUnits, mySystem, myCode);
 }
Example #11
0
 public boolean isEmpty() {
   return super.isEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(versionId, lastUpdated, profile, security, tag);
 }
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(myReference, myDisplay);
 }
Example #13
0
 public boolean isEmpty() {
   return super.isEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(
           origin, period, factor, lowerLimit, upperLimit, dimensions, data);
 }
Example #14
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myComment, myLink);
 }
  private void validateQuestionAnswers(
      List<ValidationMessage> theErrors,
      QuestionComponent theQuestion,
      LinkedList<String> thePathStack,
      AnswerFormat type,
      org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionComponent answerQuestion,
      QuestionnaireResponse theAnswers,
      boolean theValidateRequired) {

    String linkId = theQuestion.getLinkId();
    Set<Class<? extends Type>> allowedAnswerTypes = determineAllowedAnswerTypes(type);
    if (allowedAnswerTypes.isEmpty()) {
      for (QuestionAnswerComponent nextAnswer : answerQuestion.getAnswer()) {
        rule(
            theErrors,
            IssueType.BUSINESSRULE,
            thePathStack,
            ElementUtil.isEmpty(nextAnswer.getValue()),
            "Question with linkId[{0}] has no answer type but an answer was provided",
            linkId);
      }
    } else {
      rule(
          theErrors,
          IssueType.BUSINESSRULE,
          thePathStack,
          !(answerQuestion.getAnswer().size() > 1 && !theQuestion.getRepeats()),
          "Multiple answers to non repeating question with linkId[{0}]",
          linkId);
      if (theValidateRequired) {
        rule(
            theErrors,
            IssueType.BUSINESSRULE,
            thePathStack,
            !(theQuestion.getRequired() && answerQuestion.getAnswer().isEmpty()),
            "Missing answer to required question with linkId[{0}]",
            linkId);
      } else {
        hint(
            theErrors,
            IssueType.BUSINESSRULE,
            thePathStack,
            !(theQuestion.getRequired() && answerQuestion.getAnswer().isEmpty()),
            "Missing answer to required question with linkId[{0}]",
            linkId);
      }
    }

    int answerIdx = -1;
    for (QuestionAnswerComponent nextAnswer : answerQuestion.getAnswer()) {
      answerIdx++;
      try {
        thePathStack.add("answer[" + answerIdx + "]");
        Type nextValue = nextAnswer.getValue();
        if (nextValue == null) {
          continue;
        }
        if (!allowedAnswerTypes.contains(nextValue.getClass())) {
          rule(
              theErrors,
              IssueType.BUSINESSRULE,
              thePathStack,
              false,
              "Answer to question with linkId[{0}] found of type [{1}] but this is invalid for question of type [{2}]",
              linkId,
              nextValue.getClass().getSimpleName(),
              type.toCode());
          continue;
        }

        // Validate choice answers
        if (type == AnswerFormat.CHOICE || type == AnswerFormat.OPENCHOICE) {
          if (nextAnswer.getValue() instanceof StringType) {
            StringType answer = (StringType) nextAnswer.getValue();
            if (answer == null || isBlank(answer.getValueAsString())) {
              rule(
                  theErrors,
                  IssueType.BUSINESSRULE,
                  thePathStack,
                  false,
                  "Answer to question with linkId[{0}] is required but answer does not have a value",
                  linkId);
              continue;
            }
          } else {
            Coding coding = (Coding) nextAnswer.getValue();
            if (isBlank(coding.getCode())) {
              rule(
                  theErrors,
                  IssueType.BUSINESSRULE,
                  thePathStack,
                  false,
                  "Answer to question with linkId[{0}] is of type {1} but coding answer does not have a code",
                  linkId,
                  type.name());
              continue;
            }
            if (isBlank(coding.getSystem())) {
              rule(
                  theErrors,
                  IssueType.BUSINESSRULE,
                  thePathStack,
                  false,
                  "Answer to question with linkId[{0}] is of type {1} but coding answer does not have a system",
                  linkId,
                  type.name());
              continue;
            }

            String optionsRef = theQuestion.getOptions().getReference();
            if (isNotBlank(optionsRef)) {
              ValueSet valueSet = getValueSet(theAnswers, theQuestion.getOptions());
              if (valueSet == null) {
                rule(
                    theErrors,
                    IssueType.BUSINESSRULE,
                    thePathStack,
                    false,
                    "Question with linkId[{0}] has options ValueSet[{1}] but this ValueSet can not be found",
                    linkId,
                    optionsRef);
                continue;
              }

              boolean found = false;
              if (coding.getSystem().equals(valueSet.getCodeSystem().getSystem())) {
                for (ConceptDefinitionComponent next : valueSet.getCodeSystem().getConcept()) {
                  if (coding.getCode().equals(next.getCode())) {
                    found = true;
                    break;
                  }
                }
              }
              if (!found) {
                for (ConceptSetComponent nextCompose : valueSet.getCompose().getInclude()) {
                  if (coding.getSystem().equals(nextCompose.getSystem())) {
                    for (ConceptReferenceComponent next : nextCompose.getConcept()) {
                      if (coding.getCode().equals(next.getCode())) {
                        found = true;
                        break;
                      }
                    }
                  }
                  if (found) {
                    break;
                  }
                }
              }

              rule(
                  theErrors,
                  IssueType.BUSINESSRULE,
                  thePathStack,
                  found,
                  "Question with linkId[{0}] has answer with system[{1}] and code[{2}] but this is not a valid answer for ValueSet[{3}]",
                  linkId,
                  coding.getSystem(),
                  coding.getCode(),
                  optionsRef);
            }
          }
        }

      } finally {
        thePathStack.removeLast();
      }
    } // for answers
  }
Example #16
0
 @Override
 public boolean isEmpty() {
   return ca.uhn.fhir.util.ElementUtil.isEmpty(myStatus, myDiv);
 }
Example #17
0
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(myComment, myLink);
 }
Example #18
0
 public boolean isEmpty() {
   return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(author, item);
 }
Example #19
0
 public boolean isEmpty() {
   return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(type, resource);
 }
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType, myValue, myComparator, myUnits, mySystem, myCode);
 }
Example #21
0
 public boolean isEmpty() {
   return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, extension);
 }
Example #22
0
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(myStatus, myDescription, myDateTime, myActor);
 }
Example #23
0
  private void encodeResourceToXmlStreamWriter(
      IBaseResource theResource,
      XMLStreamWriter theEventWriter,
      boolean theContainedResource,
      String theResourceId)
      throws XMLStreamException {
    if (!theContainedResource) {
      super.containResourcesForEncoding(theResource);
    }

    RuntimeResourceDefinition resDef = myContext.getResourceDefinition(theResource);
    if (resDef == null) {
      throw new ConfigurationException("Unknown resource type: " + theResource.getClass());
    }

    theEventWriter.writeStartElement(resDef.getName());
    theEventWriter.writeDefaultNamespace(FHIR_NS);

    if (theResource instanceof IAnyResource) {

      // HL7.org Structures
      encodeCompositeElementToStreamWriter(
          theResource, theResource, theEventWriter, resDef, theContainedResource);

    } else {

      if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {

        // DSTU2+

        IResource resource = (IResource) theResource;
        writeOptionalTagWithValue(theEventWriter, "id", theResourceId);

        InstantDt updated =
            (InstantDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
        IdDt resourceId = resource.getId();
        String versionIdPart = resourceId.getVersionIdPart();
        if (isBlank(versionIdPart)) {
          versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource);
        }
        List<BaseCodingDt> securityLabels =
            extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.SECURITY_LABELS);
        List<IdDt> profiles =
            extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.PROFILES);
        TagList tags = ResourceMetadataKeyEnum.TAG_LIST.get(resource);
        if (ElementUtil.isEmpty(versionIdPart, updated, securityLabels, profiles) == false) {
          theEventWriter.writeStartElement("meta");
          writeOptionalTagWithValue(theEventWriter, "versionId", versionIdPart);
          if (updated != null) {
            writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
          }

          for (IdDt profile : profiles) {
            theEventWriter.writeStartElement("profile");
            theEventWriter.writeAttribute("value", profile.getValue());
            theEventWriter.writeEndElement();
          }
          for (BaseCodingDt securityLabel : securityLabels) {
            theEventWriter.writeStartElement("security");
            BaseRuntimeElementCompositeDefinition<?> def =
                (BaseRuntimeElementCompositeDefinition<?>)
                    myContext.getElementDefinition(securityLabel.getClass());
            encodeCompositeElementChildrenToStreamWriter(
                resource, securityLabel, theEventWriter, def.getChildren(), theContainedResource);
            theEventWriter.writeEndElement();
          }
          if (tags != null) {
            for (Tag tag : tags) {
              theEventWriter.writeStartElement("tag");
              writeOptionalTagWithValue(theEventWriter, "system", tag.getScheme());
              writeOptionalTagWithValue(theEventWriter, "code", tag.getTerm());
              writeOptionalTagWithValue(theEventWriter, "display", tag.getLabel());
              theEventWriter.writeEndElement();
            }
          }
          theEventWriter.writeEndElement();
        }

        if (theResource instanceof IBaseBinary) {
          IBaseBinary bin = (IBaseBinary) theResource;
          writeOptionalTagWithValue(theEventWriter, "contentType", bin.getContentType());
          writeOptionalTagWithValue(theEventWriter, "content", bin.getContentAsBase64());
        } else {
          encodeResourceToStreamWriterInDstu2Format(
              resDef, theResource, theResource, theEventWriter, resDef, theContainedResource);
        }

      } else {

        // DSTU1
        if (theResourceId != null && theContainedResource) {
          theEventWriter.writeAttribute("id", theResourceId);
        }

        if (theResource instanceof IBaseBinary) {
          IBaseBinary bin = (IBaseBinary) theResource;
          if (bin.getContentType() != null) {
            theEventWriter.writeAttribute("contentType", bin.getContentType());
          }
          theEventWriter.writeCharacters(bin.getContentAsBase64());
        } else {
          encodeCompositeElementToStreamWriter(
              theResource, theResource, theEventWriter, resDef, theContainedResource);
        }
      }
    }

    theEventWriter.writeEndElement();
  }
Example #24
0
 @Override
 public boolean isEmpty() {
   return super.isBaseEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(
           myUse, myLabel, mySystem, myValue, myPeriod, myAssigner);
 }
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myReference, myDisplay);
 }
Example #26
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType, myUse, myLabel, mySystem, myValue, myPeriod, myAssigner);
 }
Example #27
0
 public boolean isEmpty() {
   return super.isEmpty()
       && ca.uhn.fhir.util.ElementUtil.isEmpty(value, comparator, unit, system, code);
 }
Example #28
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType, myCode, mySpecimen, myBodySite, myStatus, myEvent);
 }
 @Override
 public boolean isEmpty() {
   return super.isEmpty() && ElementUtil.isEmpty(mySecondOrg);
 }
Example #30
0
 @Override
 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) {
   return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(
       theType, mySystem, myVersion, myCode, myDisplay, myPrimary);
 }