<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ohcnwiki.tellmey.fyi/index.php?action=history&amp;feed=atom&amp;title=References%2FQuestionnaire_Response_Template</id>
	<title>References/Questionnaire Response Template - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ohcnwiki.tellmey.fyi/index.php?action=history&amp;feed=atom&amp;title=References%2FQuestionnaire_Response_Template"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Questionnaire_Response_Template&amp;action=history"/>
	<updated>2026-07-06T05:19:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.4</generator>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Questionnaire_Response_Template&amp;diff=394&amp;oldid=prev</id>
		<title>Admin: Automated edit (via update-page on MediaWiki MCP Server)</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Questionnaire_Response_Template&amp;diff=394&amp;oldid=prev"/>
		<updated>2026-07-06T04:01:50Z</updated>

		<summary type="html">&lt;p&gt;Automated edit (via update-page on MediaWiki MCP Server)&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:31, 6 July 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 112:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 112:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; control sharing. Leave &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; null for instance-wide templates.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; control sharing. Leave &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; null for instance-wide templates.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt; to learn which sections a template carries without parsing &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Read &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt; to learn which sections a template carries without parsing &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Navbox definitions}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Related}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://ohcnwiki.tellmey.fyi/index.php?title=References/Questionnaire_Response_Template&amp;diff=152&amp;oldid=prev</id>
		<title>Admin: OHC identity seed</title>
		<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Questionnaire_Response_Template&amp;diff=152&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:47Z</updated>

		<summary type="html">&lt;p&gt;OHC identity seed&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Doc header&lt;br /&gt;
|type=reference&lt;br /&gt;
|domain=definitions&lt;br /&gt;
|title=Questionnaire Response Template&lt;br /&gt;
|order=2&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|model=QuestionnaireResponseTemplate&lt;br /&gt;
|reference=References/Service Request&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;QuestionnaireResponseTemplate&amp;lt;/code&amp;gt; is a clinician&amp;#039;s saved &amp;amp;quot;favourite&amp;amp;quot; or order set: a reusable, shareable bundle that pre-fills a [[References/Questionnaire Response|questionnaire response]] along with its medication requests and activity definitions. Reach for it when building authoring shortcuts that seed several clinical resources from one named template.&lt;br /&gt;
&lt;br /&gt;
The Django model stores the template; the Pydantic resource specs define the &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt; payload, its validation, and the read/write API schemas.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Source:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* Model: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/models/questionnaire.py &amp;lt;code&amp;gt;care/emr/models/questionnaire.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
* Spec: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/questionnaire_response_template/spec.py &amp;lt;code&amp;gt;resources/questionnaire_response_template/spec.py&amp;lt;/code&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Model&lt;br /&gt;
! Purpose&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseTemplate&amp;lt;/code&amp;gt;&lt;br /&gt;
| A named template bundling pre-filled questionnaire answers, medication requests, and activity definitions, scoped to a facility/users/organizations&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;QuestionnaireResponseTemplate&amp;lt;/code&amp;gt; extends [[References/Base models &amp;amp;amp; conventions|&amp;lt;code&amp;gt;EMRBaseModel&amp;lt;/code&amp;gt;]], the shared Care EMR base that provides &amp;lt;code&amp;gt;external_id&amp;lt;/code&amp;gt;, audit fields, soft-delete, and &amp;lt;code&amp;gt;history&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;meta&amp;lt;/code&amp;gt; JSON.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;QuestionnaireResponseTemplate&amp;lt;/code&amp;gt; fields ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Type&lt;br /&gt;
! Notes&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=name|type=CharField(255)|notes=Display name shown when picking a template}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=description|type=TextField|notes=&amp;lt;code&amp;gt;default=&amp;amp;quot;&amp;amp;quot;&amp;lt;/code&amp;gt;}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=template_data|type=JSONField|notes=&amp;lt;code&amp;gt;default=dict&amp;lt;/code&amp;gt;. The structured payload; shape defined by &amp;lt;code&amp;gt;TemplateData&amp;lt;/code&amp;gt; (see [[#templatedata-shape}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=facility|type=FK → Facility|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, nullable. Owning facility; instance-wide when null}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=questionnaire|type=FK → Questionnaire|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, nullable, &amp;lt;code&amp;gt;default=None&amp;lt;/code&amp;gt;. The questionnaire the template targets, if any}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=facility_organizations|type=ArrayField[int]|notes=&amp;lt;code&amp;gt;default=list&amp;lt;/code&amp;gt;. Facility-organization ids the template is shared with}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=users|type=ArrayField[int]|notes=&amp;lt;code&amp;gt;default=list&amp;lt;/code&amp;gt;. User ids the template is shared with}}&lt;br /&gt;
{{Field|model=QuestionnaireResponseTemplate|section=QuestionnaireResponseTemplate fields|name=available_keys|type=ArrayField[CharField(255)]|notes=&amp;lt;code&amp;gt;default=list&amp;lt;/code&amp;gt;. Platform-maintained: the populated top-level keys of &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt;, recomputed on every write. Don&amp;#039;t set it directly}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;TemplateData&amp;lt;/code&amp;gt; shape ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt; is an opaque &amp;lt;code&amp;gt;JSONField&amp;lt;/code&amp;gt; on the model; the spec (&amp;lt;code&amp;gt;resources/questionnaire_response_template/spec.py&amp;lt;/code&amp;gt;) gives it this structure. Every section is optional, and &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt; records which ones a given template carries.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;TemplateData {&lt;br /&gt;
  medication_request:  list[MedicationRequestTemplateSpec] | None&lt;br /&gt;
  questionnaire:       list[QuestionnaireAnswer] | None&lt;br /&gt;
  activity_definition: list[ActivityDefinitionTemplateSpec] | None&lt;br /&gt;
  meta:                dict | None&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
QuestionnaireAnswer { question_id: str, answer: dict, meta: dict }&lt;br /&gt;
&lt;br /&gt;
MedicationRequestTemplateSpec   # extends the medication request write spec&lt;br /&gt;
  + requested_product: str | None     # validated against ProductKnowledge.slug&lt;br /&gt;
&lt;br /&gt;
ActivityDefinitionTemplateSpec {&lt;br /&gt;
  slug:            str                 # validated against ActivityDefinition.slug&lt;br /&gt;
  service_request: ServiceRequestUpdateSpec&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
See [[References/Medication Request]], [[References/Activity Definition]], and [[References/Service Request]] for the embedded specs.&lt;br /&gt;
&lt;br /&gt;
== Resource specs (API schema) ==&lt;br /&gt;
&lt;br /&gt;
All specs extend &amp;lt;code&amp;gt;EMRResource&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;resources/base.py&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Spec class&lt;br /&gt;
! Role&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseTemplateBaseSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;__model__ = QuestionnaireResponseTemplate&amp;lt;/code&amp;gt;; &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UUID4?&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;TemplateData&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;description&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;= &amp;amp;quot;&amp;amp;quot;&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseTemplateCreateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · create&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;questionnaire&amp;lt;/code&amp;gt; (slug &amp;lt;code&amp;gt;str?&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UUID4?&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;list[str]&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;list[UUID4]&amp;lt;/code&amp;gt;). Requires a &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; whenever &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt; are given; resolves the questionnaire by slug and the facility by external id; recomputes &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseTemplateUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt;; recomputes &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt;. Cannot change &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;questionnaire&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseTemplateReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · list&lt;br /&gt;
| Adds &amp;lt;code&amp;gt;created_date&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;modified_date&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseTemplateRetrieveSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read · detail&lt;br /&gt;
| Expands &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt; via cache) and &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;FacilityOrganizationReadSpec&amp;lt;/code&amp;gt;), plus &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Validation and server-maintained behaviour ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;validate_facility&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;model_validator(after)&amp;lt;/code&amp;gt; on create) rejects facility organizations that have no facility.&lt;br /&gt;
* &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; derives &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt; on every create and update from the &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt; keys whose value is non-empty. Clients don&amp;#039;t set it.&lt;br /&gt;
* Before save, the embedded &amp;lt;code&amp;gt;requested_product&amp;lt;/code&amp;gt; and activity-definition &amp;lt;code&amp;gt;slug&amp;lt;/code&amp;gt; are checked to exist against &amp;lt;code&amp;gt;ProductKnowledge&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ActivityDefinition&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* This is a Care-specific authoring convenience, not a FHIR resource, so it has no FHIR mapping.&lt;br /&gt;
* &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;facility_organizations&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; control sharing. Leave &amp;lt;code&amp;gt;facility&amp;lt;/code&amp;gt; null for instance-wide templates.&lt;br /&gt;
* Read &amp;lt;code&amp;gt;available_keys&amp;lt;/code&amp;gt; to learn which sections a template carries without parsing &amp;lt;code&amp;gt;template_data&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>