#!/usr/bin/env bash # Usage: ./evaluate-measure.sh -f .cql # Takes a CQL file, creates a Library resource from it, references that from a # Measure resource and calls $evaluate-measure on it. library() { cat < /dev/null MEASURE_ID=$(create-measure ${MEASURE_URI} ${LIBRARY_URI} ${SUBJECT_TYPE} | post "Measure" | jq -r .id | tr -d '\r') if [ "subject-list" = "$REPORT_TYPE" ]; then echo "Generating a report including the list of matching ${SUBJECT_TYPE_LOWER}s..." MEASURE_REPORT=$(evaluate-measure-list ${MEASURE_ID}) COUNT=$(echo $MEASURE_REPORT | jq -r '.group[0].population[0].count' | tr -d '\r') LIST_REFERENCE=$(echo $MEASURE_REPORT | jq -r '.group[0].population[0].subjectResults.reference' | tr -d '\r') LIST_ID=$(echo $LIST_REFERENCE | cut -d '/' -f2) echo "Found $COUNT ${SUBJECT_TYPE_LOWER}s that can be found on List $BASE/$LIST_REFERENCE." echo "" echo "Please use the following blazectl command to download the ${SUBJECT_TYPE_LOWER}s:" echo " blazectl download --server $BASE $SUBJECT_TYPE -q '_list=$LIST_ID' -o ${SUBJECT_TYPE_LOWER}s.ndjson" else echo "Generating a population count report..." MEASURE_REPORT=$(evaluate-measure ${MEASURE_ID}) COUNT=$(echo $MEASURE_REPORT | jq -r '.group[0].population[0].count' | tr -d '\r') echo "Found $COUNT ${SUBJECT_TYPE_LOWER}s." fi