Repository navigation
Align device enableWhen with the pair rules for units, time zones, unknown sources and long chains - #180
Open
PSchmiedmayer wants to merge 6 commits into
Conversation
A response exported from the device is now decided by the pair rules as the device decided it while the participant answered. Quantity conditions carry the unit identity of a FHIR answerQuantity (system, code, unit text). The device records an answer's unit with the rule the response export uses (RecordedQuantityUnit), and orders it against the condition with the pair rules' unit rule. A unit code without a system takes the question's system or counts as text (qty-3), also in the exported response. A dateTime condition keeps its time zone and fractional seconds on import and is exported with its zone; one with a time and no zone is not exported. Time values keep their fraction of a second on import and export. The device places every task occurrence from the stored responses in document order, as the pair rules place items, and evaluates the occurrences a condition depends on with an explicit stack, so long condition chains do not depend on the thread stack. The placement and the cycle set are kept on the root for one revision. Cycles are decided from the questionnaire structure over conditions that can be evaluated, as in the pair rules. The answers of a question whose enablement is unknown count as absent, as the export omits it. A follow-up task's enablement includes its choice task's, so a condition on a follow-up of a choice task that is disabled for good is settled.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Conditions read occurrences through the readable index, so the flag on each occurrence was assigned and never read, which dead code analysis reports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♻️ Current situation & Problem
This PR builds on #175.
With #175, the form's enablement logic in
GroveQuestionnaireand the pair rules ofPairValidatorevaluateenableWhenby FHIR R4. A response exported from the device should be decided by the pair rules exactly as the device decided it. Otherwise the device hides a required question the server expects, or shows one the server rejects as disabled. Five cases still differed:Quantityrecords them (code and system, or unit text without a code). The form reduced the condition to oneunitCodestring and dropped the system. A coded unit without a system was also exported with a code and no system, which qty-3 forbids.dateTimecondition such as2024-03-05T10:00:00+05:00dropped the offset and fractional seconds, so the form compared 10:00 in the device's zone while the pair rules compared 05:00 UTC.⚙️ Release Notes
Condition.Value.quantitycarries the parts of a FHIRanswerQuantity. A code without a system takes the system the question gives that unit, or otherwise counts as unit text. The form records an answer's unit with the same rule as the export (RecordedQuantityUnit) and orders it against the condition by the pair rules' unit rule; every other combination leaves the comparison open.A
dateTimecondition keeps its time zone and fractional seconds on import, so the form compares the same instant as the pair rules. Time values keep fractional seconds on import and export. AdateTimecondition with a time and without a zone is not exported.The answers of a question whose enablement cannot be evaluated count as absent, as in the exported response:
Cycles are decided once per questionnaire from its structure, through conditions, enclosing groups and the choice task a follow-up belongs to. A condition that cannot be evaluated adds no dependency.
Evaluation places every task occurrence in document order and evaluates the dependencies with an explicit stack, so chain length no longer depends on the thread stack. The placement is cached on the root
QuestionnaireResponsesfor its current revision.A condition on a follow-up task is settled once the follow-up task is disabled for good.
Migration:
Condition.Value.quantity(value:unitCode:)is nowquantity(value:system:code:unit:), with defaults for everything but the value.📚 Documentation
The documentation of
Questionnaire.Condition.Value.quantitydescribes the unit rule. Code comments describe the occurrence placement, the cycle rule and the explicit evaluation stack.✅ Testing
EnableWhenTestsaddsquantityUnitIdentityAgreesWithThePairRules,dateTimeConditionsKeepTheirTimeZoneandsourcesWithUnknownEnablementAreDecidedAsThePairRulesDo, which answer each target where the form enables it and check the exported pair withPairValidator.followUpsOfAPermanentlyDisabledChoiceAreSettled,conditionsInAnUnselectedOptionReadTheOccurrenceWithoutAnswers,conditionsThatCannotBeEvaluatedCloseNoCycle,conditionsThatCannotBeEvaluatedAddNoDependencyandcustomKindsCompareEveryValueThemselves.longConditionChainsDoNotDependOnTheThreadStackreplacesmanyConditionalChoiceTasksEvaluateQuickly: 100 chained conditional choice tasks evaluated on a thread with a 128 KB stack, under a time limit.quantityQuestionOperatorsCompareInTheirUnitandFHIRConformanceTests.exportedQuantitiesCarryTheirUnitSystemuse the new quantity case.TestAppUITests.tap(_:)now lets an element settle before asking whether it is hittable, because an answer or a swipe scrolls the page a moment later.Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: