[Power Automate] Repeat Group Data Flow Configuration
This flow is critical for migrating complex repeat group data structures from a SQL database into CommCare. It ensures that each piece of data is correctly formatted, transferred, and linked within the CommCare system, maintaining data integrity and accuracy.
Flow Components
Trigger: The flow is manually triggered, allowing users to start the process on demand.
The following actions are part of the flow:
Initialization and Variable Handling: Initializes and manages variables like prefixCounter, prefixCounter_parent, and combinedxmlstring for counting and concatenating XML data blocks.
Get Rows from SQL Database (Visits): Retrieves visit-related data from the SQL database.
Filter Array: Filters data based on parent_case_id to ensure only relevant entries are processed.
Individual Case XML Blocks for Parent Case: Constructs XML blocks for each individual case, including details like visit_count, Visit_Date, Health_Score, Weight, and Vaccinated status.
Repeat Group Block: Compiles current repeat group data into a structured XML format.
Paste the Raw XML copied previously for the visits registration form submission in the input of the Compose action. Select only the <medication> block.
Here's a table format for the XML structure, breaking down each element and its details:
Element | Attribute | Description | Value/Example |
---|---|---|---|
|
| Root element for medication details |
|
|
| Name of the medication |
|
|
| Dosage of the medication |
|
These values are dynamically filled into the XML structure using the placeholders @{items('Individual_Row_Transformation')?['FieldName']} where FieldName corresponds to the columns from the SQL database.
Medication_Name
Used for:
<medicine_name>: The name of the medication.
Example Placeholder: @{body('Parse_JSON_for_Generating_List')?['Medication_Name']}
Dosage
Used for:
<dosage>: The dosage of the medication.
Example Placeholder: @{body('Parse_JSON_for_Generating_List')?['Dosage']}
Current Case Block: Compiles current case data into a structured XML format.
Paste the Raw XML copied previously for the visits registration form submission in the input of the Compose action. Select only the form content and <subcase> block.
Here's a table format for the XML structure, breaking down each element and its details:
Element | Attribute | Description | Value/Example |
---|---|---|---|
|
| Counter for the number of visits |
|
|
| Date of the visit |
|
|
| Health score of the individual |
|
|
| Weight of the individual |
|
|
| Vaccination status of the individual |
|
|
| Container for subcase details |
|
|
| Namespace for CommCare case transaction |
|
|
| Unique identifier for the visit case |
|
|
| Date and time when the case was last modified |
|
|
| User ID responsible for the case |
|
|
| Section defining the creation of a new visit case |
|
|
| Name of the visit case |
|
|
| ID of the case owner |
|
|
| Type of the case |
|
|
| Section including updates to the visit case |
|
|
| Updated health score |
|
|
| Updated date of the visit |
|
|
| Updated weight |
|
|
| Section defining the index relationship |
|
|
| Type of the parent case |
|
|
| Parent case ID |
|
Parent Case Block: Updates parent case information with relevant visit data.
Here's a table format for the XML structure, breaking down each element and its details:
Element | Attribute | Description | Value/Example |
---|---|---|---|
|
| Namespace for CommCare case transaction |
|
|
| Unique identifier for the parent case |
|
|
| Date and time when the case was last modified |
|
|
| User ID responsible for the case |
|
|
| Section including updates to the parent case |
|
|
| Updated counter for the number of visits |
|
XML Header and Footer Blocks: Constructs the header and footer for the XML submission, including metadata such as device ID, timestamps, username, user ID, instance ID, and application version.
XML Footer Block
Element | Attribute | Description | Value/Example |
---|---|---|---|
|
| Namespace for form metadata |
|
|
| ID of the device used for form submission |
|
|
| Start time of form entry |
|
|
| End time of form entry |
|
|
| Username of the person submitting the form |
|
|
| User ID associated with the form submission |
|
|
| Unique identifier for the form instance |
|
|
| Namespace for application version |
|
|
| Application version used for the form submission |
|
|
| Time drift indicator |
|
XML Header Block
Element | Attribute | Description | Value/Example |
---|---|---|---|
|
| Namespace for CommCare XForms |
|
|
| Namespace for the form designer |
|
|
| User interface version |
|
|
| Version of the form |
|
|
| Name of the form |
|
Final XML for Submission: Combines the XML header, case data, and footer into a final XML string for submission.
This action concatenates the value of each of the above XML blocks to create the final XML body for submission to CommCare.
Form Submission to CommCare: Submits the final XML data to CommCare via an HTTP POST request, including Authorization headers.
This action submits the XML data to CommCare via an HTTP POST request. The request includes an Authorization key and a predefined URI for the CommCare receiver endpoint. This ensures the data is securely transferred and integrated into the CommCare system.