# 9 Internal Workflows

{% hint style="success" %}
This section describes standard *internal* workflows that a building block should support. Each internal workflow must be linked to one of the Functional Requirements defined in section 6.

An internal workflow describes the internal processes that a Building Block needs to execute to complete a request from an external application or Building Block to fulfull the functional requirement
{% endhint %}

*\<Example Internal Workflows>*

### 9.1 Start a workflow process via API.

This internal workflow is used by the Workflow Building Block to initiate a workflow process. An external application (Building Block) calls an API in the Workflow Building Block which will launch a workflow process. This functional requirement must also support submission of data payload through variables in the same API call.

Examples:

* [PostPartum and Infant Care Use Case, Payment Step](https://govstack-global.atlassian.net/wiki/spaces/GH/pages/49381394/PostPartum-01-Example+Implementation+Original+-+multiple+steps): Validate the mother has completed all steps (visited a pediatrician, procured medicine and nutrition supplies, and visited the therapy center) by connecting to MCTS registry
* [Unconditional Social Cash Transfer, Elibility Determination](https://govstack.gitbook.io/product-use-cases/product-use-case/inst-1-unconditional-social-cash-transfer): Send beneficiary data from Registration BB to Workflow BB

{% @mermaid/diagram content="sequenceDiagram

External BB-->>Workflow BB: Call API to start workflow process
Workflow BB-->>Workflow BB: Launch process
Workflow BB-->>External BB: Return Process ID
" %}

### 9.2 Booking an appointment

The first and somewhat unique use-case is related to the need for consent when the Individual is not yet provisioned in the System processing the data. In such cases, the workflow requires the creation of a valid and trusted Foundational ID to be linked with the Consent Record. Below is shown how a pre-registration use of consent workflow works.

Examples:

* Postpartum Use Case, Appointment scheduling step: In this case, a health care worker will book an appointment into a specific slot. The Scheduler Building Block will leverage the Messaging Building Block to send a message to the patient with an appointment confirmation.

{% @mermaid/diagram content="sequenceDiagram

HCworker->>PPCP\_APP: Request appointment<br />for consultation session<br /> with preferences<br />(date-time range,\nclinics, doctors,etc)
PPCP\_APP->>Scheduler \[planner]: Find unbooked session<br />slots in consultation event<br />for given preferrences
Scheduler \[planner]->>PPCP\_APP: Report available<br />session slots\n with terms of service
opt:
HCworker ->>PPCP\_APP:Pay fee, if any
PPCP\_APP->HCworker:payment receipt
end
HCworker->>PPCP\_APP:Confirm slot
PPCP\_APP->>Scheduler \[planner]: Book appointment<br />for consultation session
Scheduler \[planner]->>Scheduler \[Worklist]: Update in<br />consultant's worklist
Scheduler \[planner]->>PPCP\_APP:Confirm booking of \n appointment
PPCP\_APP->>HCworker:Publish booking details
Scheduler \[planner]->>Messaging BB: Appointment confirmation message
Messaging BB->>Subscriber: Deliver message \n to Subscriber
Messaging BB->>Scheduler \[planner]: delivery confirmation" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://specs.govstack.global/content-management-system/9-workflows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
