From 56e78c23961ec6aea40d23bc220d7cc8890680a7 Mon Sep 17 00:00:00 2001 From: Amy Chen <amysbubble@Amys-MacBook-Pro-3.local> Date: Mon, 6 Nov 2023 16:27:34 -0800 Subject: [PATCH] remove unused function --- .../survey_resources/Common_LogicLibrary.cql | 27 +- .../survey_resources/Common_LogicLibrary.json | 672 ++++++------------ 2 files changed, 233 insertions(+), 466 deletions(-) diff --git a/src/cql/r4/survey_resources/Common_LogicLibrary.cql b/src/cql/r4/survey_resources/Common_LogicLibrary.cql index 6a1a7413b..6bb97a5b9 100644 --- a/src/cql/r4/survey_resources/Common_LogicLibrary.cql +++ b/src/cql/r4/survey_resources/Common_LogicLibrary.cql @@ -81,27 +81,6 @@ define function MatchedReponsesByQuestionnaire(responses List<FHIR.Questionnaire sort by authored desc ) -/* - * retrieve list of Tuples containing question and its corresponding answer for a matched questionnaire - * @param currentQuestionnaire, of type FHIR.Questionnaire - * @param responses, of type FHIR.QuestionnaireResponse.Item - * @param ScoringQuestionId, question link id for question containing score - * @return {System.List<Tuple>} - */ -define function getResponsesByQuestionnaire(currentQuestionnaire FHIR.Questionnaire, responses List<FHIR.QuestionnaireResponse.Item>, scoringQuestionId String): - (currentQuestionnaire.item o - where o.linkId.value != 'introduction' and - (PositionOf(o.linkId.value, scoringQuestionId) = -1 or PositionOf(scoringQuestionId, o.linkId.value) = -1) - ) I - let - answer: First(GetResponseAnswerByLinkId(I.linkId.value, responses)) - return { - linkId: I.linkId.value, - question: I.text.value, - answer: answer, - answerText: if I.answerOption[ToInteger(answer)].value.display is not null then I.answerOption[ToInteger(answer)].value.display.value else null - } - /* * retrieve concept code of a selected answer option from a Questionnaire * @param currentQuestionnaire, of type FHIR.Questionnaire @@ -225,8 +204,10 @@ define function FormattedQuestionnaireResponses(responseItems List<FHIR.Question linkId: if I.linkId.value is not null then I.linkId.value else 'n/a', answer: case //answer in FHIR coding format - when I.answer[0].value.display is not null then I.answer[0].value.display.value - else I.answer[0].value.value + when I.answer[0].value.display is not null and I.answer[0].value.display.value is not null then + I.answer[0].value.display.value + else + I.answer[0].value.value end, question: I.text.value } diff --git a/src/cql/r4/survey_resources/Common_LogicLibrary.json b/src/cql/r4/survey_resources/Common_LogicLibrary.json index 31a7f1dc9..895fe667f 100644 --- a/src/cql/r4/survey_resources/Common_LogicLibrary.json +++ b/src/cql/r4/survey_resources/Common_LogicLibrary.json @@ -646,432 +646,6 @@ "type" : "NamedTypeSpecifier" } } ] - }, { - "name" : "GetResponseAnswerByLinkId", - "context" : "Unfiltered", - "accessLevel" : "Public", - "type" : "FunctionDef", - "expression" : { - "type" : "Query", - "source" : [ { - "alias" : "I", - "expression" : { - "type" : "Query", - "source" : [ { - "alias" : "r", - "expression" : { - "name" : "responses", - "type" : "OperandRef" - } - } ], - "relationship" : [ ], - "where" : { - "type" : "Or", - "operand" : [ { - "type" : "Not", - "operand" : { - "type" : "Equal", - "operand" : [ { - "type" : "PositionOf", - "pattern" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "r", - "type" : "Property" - } - }, - "string" : { - "name" : "linkId", - "type" : "OperandRef" - } - }, { - "type" : "Negate", - "operand" : { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "1", - "type" : "Literal" - } - } ] - } - }, { - "type" : "Not", - "operand" : { - "type" : "Equal", - "operand" : [ { - "type" : "PositionOf", - "pattern" : { - "name" : "linkId", - "type" : "OperandRef" - }, - "string" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "r", - "type" : "Property" - } - } - }, { - "type" : "Negate", - "operand" : { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "1", - "type" : "Literal" - } - } ] - } - } ] - } - } - } ], - "relationship" : [ ], - "return" : { - "expression" : { - "type" : "Case", - "caseItem" : [ { - "when" : { - "type" : "Not", - "operand" : { - "type" : "IsNull", - "operand" : { - "path" : "display", - "type" : "Property", - "source" : { - "path" : "value", - "type" : "Property", - "source" : { - "type" : "Indexer", - "operand" : [ { - "path" : "answer", - "scope" : "I", - "type" : "Property" - }, { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "0", - "type" : "Literal" - } ] - } - } - } - } - }, - "then" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "display", - "type" : "Property", - "source" : { - "path" : "value", - "type" : "Property", - "source" : { - "type" : "Indexer", - "operand" : [ { - "path" : "answer", - "scope" : "I", - "type" : "Property" - }, { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "0", - "type" : "Literal" - } ] - } - } - } - } - } ], - "else" : { - "asType" : "{urn:hl7-org:elm-types:r1}String", - "type" : "As", - "operand" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "value", - "type" : "Property", - "source" : { - "type" : "Indexer", - "operand" : [ { - "path" : "answer", - "scope" : "I", - "type" : "Property" - }, { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "0", - "type" : "Literal" - } ] - } - } - } - } - } - } - }, - "operand" : [ { - "name" : "linkId", - "operandTypeSpecifier" : { - "name" : "{urn:hl7-org:elm-types:r1}String", - "type" : "NamedTypeSpecifier" - } - }, { - "name" : "responses", - "operandTypeSpecifier" : { - "type" : "ListTypeSpecifier", - "elementType" : { - "name" : "{http://hl7.org/fhir}QuestionnaireResponse.Item", - "type" : "NamedTypeSpecifier" - } - } - } ] - }, { - "name" : "getResponsesByQuestionnaire", - "context" : "Patient", - "accessLevel" : "Public", - "type" : "FunctionDef", - "expression" : { - "type" : "Query", - "source" : [ { - "alias" : "I", - "expression" : { - "type" : "Query", - "source" : [ { - "alias" : "o", - "expression" : { - "path" : "item", - "type" : "Property", - "source" : { - "name" : "currentQuestionnaire", - "type" : "OperandRef" - } - } - } ], - "relationship" : [ ], - "where" : { - "type" : "And", - "operand" : [ { - "type" : "Not", - "operand" : { - "type" : "Equal", - "operand" : [ { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "o", - "type" : "Property" - } - }, { - "valueType" : "{urn:hl7-org:elm-types:r1}String", - "value" : "introduction", - "type" : "Literal" - } ] - } - }, { - "type" : "Or", - "operand" : [ { - "type" : "Equal", - "operand" : [ { - "type" : "PositionOf", - "pattern" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "o", - "type" : "Property" - } - }, - "string" : { - "name" : "scoringQuestionId", - "type" : "OperandRef" - } - }, { - "type" : "Negate", - "operand" : { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "1", - "type" : "Literal" - } - } ] - }, { - "type" : "Equal", - "operand" : [ { - "type" : "PositionOf", - "pattern" : { - "name" : "scoringQuestionId", - "type" : "OperandRef" - }, - "string" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "o", - "type" : "Property" - } - } - }, { - "type" : "Negate", - "operand" : { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "1", - "type" : "Literal" - } - } ] - } ] - } ] - } - } - } ], - "let" : [ { - "identifier" : "answer", - "expression" : { - "type" : "First", - "source" : { - "name" : "GetResponseAnswerByLinkId", - "type" : "FunctionRef", - "operand" : [ { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "I", - "type" : "Property" - } - }, { - "name" : "responses", - "type" : "OperandRef" - } ] - } - } - } ], - "relationship" : [ ], - "return" : { - "expression" : { - "type" : "Tuple", - "element" : [ { - "name" : "linkId", - "value" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "linkId", - "scope" : "I", - "type" : "Property" - } - } - }, { - "name" : "question", - "value" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "text", - "scope" : "I", - "type" : "Property" - } - } - }, { - "name" : "answer", - "value" : { - "name" : "answer", - "type" : "QueryLetRef" - } - }, { - "name" : "answerText", - "value" : { - "type" : "If", - "condition" : { - "type" : "Not", - "operand" : { - "type" : "IsNull", - "operand" : { - "path" : "display", - "type" : "Property", - "source" : { - "path" : "value", - "type" : "Property", - "source" : { - "type" : "Indexer", - "operand" : [ { - "path" : "answerOption", - "scope" : "I", - "type" : "Property" - }, { - "type" : "ToInteger", - "operand" : { - "name" : "answer", - "type" : "QueryLetRef" - } - } ] - } - } - } - } - }, - "then" : { - "path" : "value", - "type" : "Property", - "source" : { - "path" : "display", - "type" : "Property", - "source" : { - "path" : "value", - "type" : "Property", - "source" : { - "type" : "Indexer", - "operand" : [ { - "path" : "answerOption", - "scope" : "I", - "type" : "Property" - }, { - "type" : "ToInteger", - "operand" : { - "name" : "answer", - "type" : "QueryLetRef" - } - } ] - } - } - } - }, - "else" : { - "asType" : "{urn:hl7-org:elm-types:r1}String", - "type" : "As", - "operand" : { - "type" : "Null" - } - } - } - } ] - } - } - }, - "operand" : [ { - "name" : "currentQuestionnaire", - "operandTypeSpecifier" : { - "name" : "{http://hl7.org/fhir}Questionnaire", - "type" : "NamedTypeSpecifier" - } - }, { - "name" : "responses", - "operandTypeSpecifier" : { - "type" : "ListTypeSpecifier", - "elementType" : { - "name" : "{http://hl7.org/fhir}QuestionnaireResponse.Item", - "type" : "NamedTypeSpecifier" - } - } - }, { - "name" : "scoringQuestionId", - "operandTypeSpecifier" : { - "name" : "{urn:hl7-org:elm-types:r1}String", - "type" : "NamedTypeSpecifier" - } - } ] }, { "name" : "getAnswerOptionCodeValue", "context" : "Patient", @@ -1325,6 +899,186 @@ "type" : "NamedTypeSpecifier" } } ] + }, { + "name" : "GetResponseAnswerByLinkId", + "context" : "Patient", + "accessLevel" : "Public", + "type" : "FunctionDef", + "expression" : { + "type" : "Query", + "source" : [ { + "alias" : "I", + "expression" : { + "type" : "Query", + "source" : [ { + "alias" : "r", + "expression" : { + "name" : "responses", + "type" : "OperandRef" + } + } ], + "relationship" : [ ], + "where" : { + "type" : "Or", + "operand" : [ { + "type" : "Not", + "operand" : { + "type" : "Equal", + "operand" : [ { + "type" : "PositionOf", + "pattern" : { + "path" : "value", + "type" : "Property", + "source" : { + "path" : "linkId", + "scope" : "r", + "type" : "Property" + } + }, + "string" : { + "name" : "linkId", + "type" : "OperandRef" + } + }, { + "type" : "Negate", + "operand" : { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "1", + "type" : "Literal" + } + } ] + } + }, { + "type" : "Not", + "operand" : { + "type" : "Equal", + "operand" : [ { + "type" : "PositionOf", + "pattern" : { + "name" : "linkId", + "type" : "OperandRef" + }, + "string" : { + "path" : "value", + "type" : "Property", + "source" : { + "path" : "linkId", + "scope" : "r", + "type" : "Property" + } + } + }, { + "type" : "Negate", + "operand" : { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "1", + "type" : "Literal" + } + } ] + } + } ] + } + } + } ], + "relationship" : [ ], + "return" : { + "expression" : { + "type" : "Case", + "caseItem" : [ { + "when" : { + "type" : "Not", + "operand" : { + "type" : "IsNull", + "operand" : { + "path" : "display", + "type" : "Property", + "source" : { + "path" : "value", + "type" : "Property", + "source" : { + "type" : "Indexer", + "operand" : [ { + "path" : "answer", + "scope" : "I", + "type" : "Property" + }, { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "0", + "type" : "Literal" + } ] + } + } + } + } + }, + "then" : { + "path" : "value", + "type" : "Property", + "source" : { + "path" : "display", + "type" : "Property", + "source" : { + "path" : "value", + "type" : "Property", + "source" : { + "type" : "Indexer", + "operand" : [ { + "path" : "answer", + "scope" : "I", + "type" : "Property" + }, { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "0", + "type" : "Literal" + } ] + } + } + } + } + } ], + "else" : { + "asType" : "{urn:hl7-org:elm-types:r1}String", + "type" : "As", + "operand" : { + "path" : "value", + "type" : "Property", + "source" : { + "path" : "value", + "type" : "Property", + "source" : { + "type" : "Indexer", + "operand" : [ { + "path" : "answer", + "scope" : "I", + "type" : "Property" + }, { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "0", + "type" : "Literal" + } ] + } + } + } + } + } + } + }, + "operand" : [ { + "name" : "linkId", + "operandTypeSpecifier" : { + "name" : "{urn:hl7-org:elm-types:r1}String", + "type" : "NamedTypeSpecifier" + } + }, { + "name" : "responses", + "operandTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}QuestionnaireResponse.Item", + "type" : "NamedTypeSpecifier" + } + } + } ] }, { "name" : "GetArrayAnswerByLinkId", "context" : "Patient", @@ -2502,30 +2256,62 @@ "type" : "Case", "caseItem" : [ { "when" : { - "type" : "Not", - "operand" : { - "type" : "IsNull", + "type" : "And", + "operand" : [ { + "type" : "Not", "operand" : { - "path" : "display", - "type" : "Property", - "source" : { + "type" : "IsNull", + "operand" : { + "path" : "display", + "type" : "Property", + "source" : { + "path" : "value", + "type" : "Property", + "source" : { + "type" : "Indexer", + "operand" : [ { + "path" : "answer", + "scope" : "I", + "type" : "Property" + }, { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "0", + "type" : "Literal" + } ] + } + } + } + } + }, { + "type" : "Not", + "operand" : { + "type" : "IsNull", + "operand" : { "path" : "value", "type" : "Property", "source" : { - "type" : "Indexer", - "operand" : [ { - "path" : "answer", - "scope" : "I", - "type" : "Property" - }, { - "valueType" : "{urn:hl7-org:elm-types:r1}Integer", - "value" : "0", - "type" : "Literal" - } ] + "path" : "display", + "type" : "Property", + "source" : { + "path" : "value", + "type" : "Property", + "source" : { + "type" : "Indexer", + "operand" : [ { + "path" : "answer", + "scope" : "I", + "type" : "Property" + }, { + "valueType" : "{urn:hl7-org:elm-types:r1}Integer", + "value" : "0", + "type" : "Literal" + } ] + } + } } } } - } + } ] }, "then" : { "path" : "value",