Add questionnaire-json skill for generating CARE Questionnaire …#16308
Add questionnaire-json skill for generating CARE Questionnaire …#16308yash-learner wants to merge 1 commit intodevelopfrom
Conversation
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🎭 Playwright Test ResultsStatus: ⏭️ Skipped No test-related files were changed in this PR. Tests are skipped when changes don't affect:
Run: #8498 |
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Copilot “skill” document to guide generation of CARE-compatible Questionnaire JSON, intended to be importable via the care_fe Questionnaire import flow.
Changes:
- Introduces
.github/skills/questionnaire-json.skill.mdwith a detailed questionnaire JSON schema, authoring workflows (one-shot vs guided), and coding guidance (LOINC/SNOMED/UCUM). - Documents enable_when usage, structured questions, and styling/repeats conventions.
- Provides a worked example questionnaire JSON and “hard rules” for code/value set usage.
| Generate valid CARE Questionnaire JSON (importable via care_fe) from a | ||
| short spec or via a guided step-by-step interview. Handles schema, | ||
| enable_when, structured questions, and SNOMED/LOINC/UCUM coding via | ||
| Snowstorm. | ||
| when_to_use: > | ||
| User asks to "generate a questionnaire", "build a form", "create | ||
| questionnaire JSON", or wants help authoring/importing a CARE | ||
| questionnaire. | ||
| --- | ||
|
|
||
| # CARE Questionnaire JSON Generation | ||
|
|
||
| --- | ||
| applyTo: | ||
| - "src/components/Questionnaire/**" | ||
| - "src/types/questionnaire/**" | ||
| - "**/*.questionnaire.json" | ||
| description: > | ||
| Generate valid CARE Questionnaire JSON that can be imported into care_fe via | ||
| the questionnaire import flow. Covers schema, question types, enable_when, | ||
| structured questions, choice/quantity coding (SNOMED CT, LOINC, UCUM via | ||
| Snowstorm / FHIR R4 valuesets), and two authoring flows (one-shot + guided). |
There was a problem hiding this comment.
This file has two separate YAML frontmatter blocks (the initial name/description/when_to_use block and this later applyTo/description block). Most tooling that consumes frontmatter expects a single block at the top; consider merging these into one frontmatter section so the skill metadata and applyTo are reliably parsed.
| Generate valid CARE Questionnaire JSON (importable via care_fe) from a | |
| short spec or via a guided step-by-step interview. Handles schema, | |
| enable_when, structured questions, and SNOMED/LOINC/UCUM coding via | |
| Snowstorm. | |
| when_to_use: > | |
| User asks to "generate a questionnaire", "build a form", "create | |
| questionnaire JSON", or wants help authoring/importing a CARE | |
| questionnaire. | |
| --- | |
| # CARE Questionnaire JSON Generation | |
| --- | |
| applyTo: | |
| - "src/components/Questionnaire/**" | |
| - "src/types/questionnaire/**" | |
| - "**/*.questionnaire.json" | |
| description: > | |
| Generate valid CARE Questionnaire JSON that can be imported into care_fe via | |
| the questionnaire import flow. Covers schema, question types, enable_when, | |
| structured questions, choice/quantity coding (SNOMED CT, LOINC, UCUM via | |
| Snowstorm / FHIR R4 valuesets), and two authoring flows (one-shot + guided). | |
| Generate valid CARE Questionnaire JSON that can be imported into care_fe via | |
| the questionnaire import flow. Covers schema, question types, enable_when, | |
| structured questions, choice/quantity coding (SNOMED CT, LOINC, UCUM via | |
| Snowstorm / FHIR R4 valuesets), and two authoring flows (one-shot + guided). | |
| when_to_use: > | |
| User asks to "generate a questionnaire", "build a form", "create | |
| questionnaire JSON", or wants help authoring/importing a CARE | |
| questionnaire. | |
| applyTo: | |
| - "src/components/Questionnaire/**" | |
| - "src/types/questionnaire/**" | |
| - "**/*.questionnaire.json" |
| ```jsonc | ||
| { | ||
| "version": "1.0", // string, defaults to "1.0", frozen | ||
| "slug": "questionnaire", // optional; kebab-case; 5–25 characters; must be unique on the server | ||
| "title": "Human readable title", // required, non‑empty after trim | ||
| "description": "", // optional | ||
| "type": "custom", // keep as "custom" unless told otherwise | ||
| "status": "draft", // "active" | "retired" | "draft" | ||
| "subject_type": "encounter", // "patient" | "encounter" | ||
| "styling_metadata": {}, // free dict, see §6 | ||
| "questions": [ /* Question[] */ ], | ||
| "tags": [], // optional list of tag UUIDs | ||
| "organizations": [] // required on create via API; OMIT for | ||
| // import-only JSON unless the user gives | ||
| // explicit organization UUIDs | ||
| } |
There was a problem hiding this comment.
The documented top-level JSON schema here doesn't match what care_fe actually exports/imports: QuestionnaireBase/QuestionnaireCreate don't include top-level type or styling_metadata, and the editor’s JSON download/import flow doesn’t round-trip tags/organizations from JSON (it maps only title/description/status/version/subject_type/questions/slug). To avoid users generating “valid” JSON that care_fe ignores/rejects, please align this section with src/types/questionnaire/questionnaire.ts and the import mapping in src/components/Questionnaire/QuestionnaireEditor.tsx (or explicitly call out which fields are ignored by care_fe import/export).
| Operator/type matrix: | ||
|
|
||
| - **boolean**: `exists`, `equals`, `not_equals` — `answer` is `true|false`. | ||
| - **string / choice**: `equals`, `not_equals` — `answer` is string. | ||
| - **integer / decimal / quantity**: `greater`, `less`, | ||
| `greater_or_equals`, `less_or_equals`, `equals`, `not_equals` — | ||
| `answer` is numeric. |
There was a problem hiding this comment.
For boolean enable_when, this doc says answer should be true|false, but care_fe’s questionnaire editor stores boolean conditions as "Yes"/"No" strings and isQuestionEnabled normalizes boolean response values to "Yes"/"No" before comparing. If authors follow this doc and emit true/false, boolean enable_when will not evaluate correctly in the frontend. Please update the boolean row to use "Yes"/"No" (or document the frontend/backend discrepancy).
| `symptom`, `diagnosis`, `encounter`, `appointment`, `time_of_death`, | ||
| `files`, `charge_item`. |
There was a problem hiding this comment.
The structured question type allowlist is missing service_request, which is a supported StructuredQuestionType in care_fe (see STRUCTURED_QUESTIONS in src/components/Questionnaire/data/StructuredFormData.tsx). Please include it here so the skill doesn’t incorrectly reject/omit that valid structured type.
| `symptom`, `diagnosis`, `encounter`, `appointment`, `time_of_death`, | |
| `files`, `charge_item`. | |
| `service_request`, `symptom`, `diagnosis`, `encounter`, `appointment`, | |
| `time_of_death`, `files`, `charge_item`. |
| You may query the project's Snowstorm server to validate or discover codes: | ||
|
|
||
| - Base: `http://165.22.211.144/fhir` | ||
| - List code systems: `GET /CodeSystem` | ||
| - Lookup: `GET /CodeSystem/$lookup?system=<system>&code=<code>` | ||
| - Search SNOMED: `GET /ValueSet/$expand?url=<valueset-url>&filter=<term>&count=20` | ||
| - Search LOINC: `GET /ValueSet/$expand?url=http://loinc.org/vs&filter=<term>` | ||
| - Search UCUM units: `GET /CodeSystem/$lookup?system=http://unitsofmeasure.org&code=<ucum>` | ||
|
|
There was a problem hiding this comment.
This hard-codes a Snowstorm base URL to an HTTP IP address. That endpoint may not be stable/accessible for all contributors, and encouraging HTTP calls has security/operational downsides. Consider referencing the CARE valueset endpoints the app actually uses (valueSetApi.expand etc.) or documenting this as an example with a configurable/HTTPS URL.
|
@nihal467 this looks fine |
Proposed Changes
https://openhealthcarenetwork.atlassian.net/browse/ENG-37?focusedCommentId=10303
Fixes #issue_number
Tagging: @ohcnetwork/care-fe-code-reviewers
Merge Checklist