<?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</id>
	<title>References/Questionnaire Response - 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"/>
	<link rel="alternate" type="text/html" href="https://ohcnwiki.tellmey.fyi/index.php?title=References/Questionnaire_Response&amp;action=history"/>
	<updated>2026-07-06T05:18:50Z</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&amp;diff=424&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&amp;diff=424&amp;oldid=prev"/>
		<updated>2026-07-06T04:05:59Z</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:35, 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 194:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 194:&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;FormSubmission&amp;lt;/code&amp;gt; runs a draft→submitted lifecycle. Its &amp;lt;code&amp;gt;response_dump&amp;lt;/code&amp;gt; is opaque JSON — the questionnaire definition validates it, the model does not.&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;FormSubmission&amp;lt;/code&amp;gt; runs a draft→submitted lifecycle. Its &amp;lt;code&amp;gt;response_dump&amp;lt;/code&amp;gt; is opaque JSON — the questionnaire definition validates it, the model does not.&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;* The server maintains the audit users (&amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;); don&#039;t set them on write.&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;* The server maintains the audit users (&amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;); don&#039;t set them on write.&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 clinical}}&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;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;Wiki: ohcnwiki.tellmey.fyi&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&amp;diff=145&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&amp;diff=145&amp;oldid=prev"/>
		<updated>2026-07-04T22:44:31Z</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=clinical&lt;br /&gt;
|title=Questionnaire Response&lt;br /&gt;
|order=14&lt;br /&gt;
|introduced=3.0&lt;br /&gt;
|fhir=QuestionnaireResponse&lt;br /&gt;
|model=QuestionnaireResponse&lt;br /&gt;
|concept=Concepts/Patient&lt;br /&gt;
|reference=References/Encounter&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;QuestionnaireResponse&amp;lt;/code&amp;gt; is the set of answers a patient gives to a [[References/Questionnaire|questionnaire]]; a &amp;lt;code&amp;gt;FormSubmission&amp;lt;/code&amp;gt; is the envelope that carries that payload through a draft-to-finalised lifecycle. You touch these when reading back what was answered or when submitting new answers.&lt;br /&gt;
&lt;br /&gt;
The Django models are the storage; the Pydantic resource specs define the submit payload, answer structure, status enums, and 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;
* Specs: [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/questionnaire_response/spec.py &amp;lt;code&amp;gt;resources/questionnaire_response/spec.py&amp;lt;/code&amp;gt;] · [&amp;lt;nowiki/&amp;gt;https://github.com/ohcnetwork/care/blob/develop/care/emr/resources/form_submission/spec.py &amp;lt;code&amp;gt;resources/form_submission/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;QuestionnaireResponse&amp;lt;/code&amp;gt;&lt;br /&gt;
| A completed set of answers to a &amp;lt;code&amp;gt;Questionnaire&amp;lt;/code&amp;gt; for a subject (patient/encounter)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FormSubmission&amp;lt;/code&amp;gt;&lt;br /&gt;
| A submission envelope (draft → submitted) holding a raw response dump for a questionnaire&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Both extend [[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 via &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;, 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;QuestionnaireResponse&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=QuestionnaireResponse|section=QuestionnaireResponse fields|name=questionnaire|type=FK → Questionnaire|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, nullable. The questionnaire that was answered}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=subject_id|type=UUIDField|notes=The subject the response is about (e.g. patient external id)}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=responses|type=JSONField|notes=&amp;lt;code&amp;gt;default=list&amp;lt;/code&amp;gt;. The raw answers — a list of &amp;lt;code&amp;gt;{ &amp;amp;quot;question_id&amp;amp;quot;: UUID, ... }&amp;lt;/code&amp;gt; entries}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=structured_responses|type=JSONField|notes=&amp;lt;code&amp;gt;default=dict&amp;lt;/code&amp;gt;. Extracted/structured representation of the answers}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=structured_response_type|type=CharField|notes=Nullable. Discriminator for the structured payload}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=patient|type=FK → Patient|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;. The patient}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=encounter|type=FK → Encounter|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, nullable. Set when the response is captured in a visit context}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=form_submission|type=FK → FormSubmission|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, nullable. The submission this response came from}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=QuestionnaireResponse fields|name=status|type=CharField(255)|notes=&amp;lt;code&amp;gt;default=&amp;amp;quot;completed&amp;amp;quot;&amp;lt;/code&amp;gt;. One of &amp;lt;code&amp;gt;QuestionnaireResponseStatusChoices&amp;lt;/code&amp;gt; (see [[#questionnaire-response-status}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;render_responses()&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
Joins each entry in &amp;lt;code&amp;gt;responses&amp;lt;/code&amp;gt; with its matching question definition from &amp;lt;code&amp;gt;questionnaire.get_questions_by_id()&amp;lt;/code&amp;gt;, returning a list of &amp;lt;code&amp;gt;{ &amp;amp;quot;answer&amp;amp;quot;: &amp;amp;lt;response&amp;amp;gt;, &amp;amp;quot;question&amp;amp;quot;: &amp;amp;lt;question&amp;amp;gt; }&amp;lt;/code&amp;gt; for display. Returns &amp;lt;code&amp;gt;[]&amp;lt;/code&amp;gt; when &amp;lt;code&amp;gt;responses&amp;lt;/code&amp;gt; is empty or no questionnaire is linked.&lt;br /&gt;
&lt;br /&gt;
== &amp;lt;code&amp;gt;FormSubmission&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=QuestionnaireResponse|section=FormSubmission fields|name=questionnaire|type=FK → Questionnaire|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;. The questionnaire being submitted}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=FormSubmission fields|name=patient|type=FK → Patient|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;. The patient}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=FormSubmission fields|name=encounter|type=FK → Encounter|notes=&amp;lt;code&amp;gt;CASCADE&amp;lt;/code&amp;gt;, nullable. Encounter context, if any}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=FormSubmission fields|name=status|type=CharField(255)|notes=One of &amp;lt;code&amp;gt;FormSubmissionStatusChoices&amp;lt;/code&amp;gt; (see [[#form-submission-status}}&lt;br /&gt;
{{Field|model=QuestionnaireResponse|section=FormSubmission fields|name=response_dump|type=JSONField|notes=&amp;lt;code&amp;gt;default=dict&amp;lt;/code&amp;gt;. Raw submitted payload}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Enums ==&lt;br /&gt;
&lt;br /&gt;
=== Questionnaire response status ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;QuestionnaireResponseStatusChoices&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;resources/questionnaire_response/spec.py&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt; values.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;completed&amp;lt;/code&amp;gt;&lt;br /&gt;
| The response is finalised (default)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;&lt;br /&gt;
| The response was recorded in error&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Form submission status ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;FormSubmissionStatusChoices&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;resources/form_submission/spec.py&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;str&amp;lt;/code&amp;gt; values.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value&lt;br /&gt;
! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;draft&amp;lt;/code&amp;gt;&lt;br /&gt;
| Saved but not finalised&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;submitted&amp;lt;/code&amp;gt;&lt;br /&gt;
| Finalised submission&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;&lt;br /&gt;
| Recorded in error&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Submit payload (nested shapes) ==&lt;br /&gt;
&lt;br /&gt;
Answers go through the questionnaire submit endpoint, whose body is &amp;lt;code&amp;gt;QuestionnaireSubmitRequest&amp;lt;/code&amp;gt;. Group questions nest via &amp;lt;code&amp;gt;sub_results&amp;lt;/code&amp;gt;, and each answer can carry multiple values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;QuestionnaireSubmitRequest {&lt;br /&gt;
  resource_id:     UUID4                          # questionnaire being answered&lt;br /&gt;
  patient:         UUID4                           (required)&lt;br /&gt;
  encounter:       UUID4 | None&lt;br /&gt;
  form_submission: UUID4 | None&lt;br /&gt;
  results:         list[QuestionnaireSubmitResult]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
QuestionnaireSubmitResult {&lt;br /&gt;
  question_id: UUID4 | UUID5                        (required)&lt;br /&gt;
  body_site:   Coding | None&lt;br /&gt;
  method:      Coding | None&lt;br /&gt;
  taken_at:    datetime | None&lt;br /&gt;
  values:      list[QuestionnaireSubmitResultValue]&lt;br /&gt;
  note:        str | None&lt;br /&gt;
  sub_results: list[list[QuestionnaireSubmitResult]]   # nested, for group questions&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
QuestionnaireSubmitResultValue {&lt;br /&gt;
  value:  str | None&lt;br /&gt;
  unit:   Coding | None      # for Quantity answers&lt;br /&gt;
  coding: Coding | None      # for coded answers&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;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;
=== &amp;lt;code&amp;gt;QuestionnaireResponse&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;resources/questionnaire_response/spec.py&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
&lt;br /&gt;
There is no generic create spec — new responses come from the questionnaire submit flow (&amp;lt;code&amp;gt;QuestionnaireSubmitRequest&amp;lt;/code&amp;gt;). The update spec carries &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; only, so the one write you make directly is flagging a response &amp;lt;code&amp;gt;entered_in_error&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;EMRQuestionnaireResponseBase&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;__model__ = QuestionnaireResponse&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseUpdate&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| Only &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;QuestionnaireResponseStatusChoices&amp;lt;/code&amp;gt;, default &amp;lt;code&amp;gt;completed&amp;lt;/code&amp;gt;) — used to mark a response &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuestionnaireResponseReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read&lt;br /&gt;
| &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questionnaire&amp;lt;/code&amp;gt; (nested &amp;lt;code&amp;gt;QuestionnaireReadSpec&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;subject_id&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;responses&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; (external id or &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;structured_responses&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;structured_response_type&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UserSpec&amp;lt;/code&amp;gt;), &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;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;FormSubmission&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;resources/form_submission/spec.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;BaseFormSubmissionSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| shared&lt;br /&gt;
| &amp;lt;code&amp;gt;__model__ = FormSubmission&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;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FormSubmissionUpdateSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| write · update&lt;br /&gt;
| &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;FormSubmissionStatusChoices&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;response_dump&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;dict&amp;lt;/code&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FormSubmissionWriteSpec&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;patient&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UUID4&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;encounter&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UUID4?&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;perform_extra_deserialization&amp;lt;/code&amp;gt; resolves the questionnaire by slug and the patient/encounter by external id; when an encounter is given, the patient is taken from it&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;FormSubmissionReadSpec&amp;lt;/code&amp;gt;&lt;br /&gt;
| read&lt;br /&gt;
| &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;response_dump&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_date&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;modified_date&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;UserSpec?&amp;lt;/code&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== API integration notes ==&lt;br /&gt;
&lt;br /&gt;
* Both map loosely onto the FHIR &amp;lt;code&amp;gt;QuestionnaireResponse&amp;lt;/code&amp;gt; resource: &amp;lt;code&amp;gt;responses&amp;lt;/code&amp;gt; holds the raw answers, and &amp;lt;code&amp;gt;structured_responses&amp;lt;/code&amp;gt; is the extracted, query-friendly form.&lt;br /&gt;
* Create a &amp;lt;code&amp;gt;QuestionnaireResponse&amp;lt;/code&amp;gt; by submitting a &amp;lt;code&amp;gt;QuestionnaireSubmitRequest&amp;lt;/code&amp;gt;. The update spec exists to flag responses &amp;lt;code&amp;gt;entered_in_error&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;FormSubmission&amp;lt;/code&amp;gt; runs a draft→submitted lifecycle. Its &amp;lt;code&amp;gt;response_dump&amp;lt;/code&amp;gt; is opaque JSON — the questionnaire definition validates it, the model does not.&lt;br /&gt;
* The server maintains the audit users (&amp;lt;code&amp;gt;created_by&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;updated_by&amp;lt;/code&amp;gt;); don&amp;#039;t set them on write.&lt;br /&gt;
&lt;br /&gt;
{{Related}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>