API/LearningPlanInstance/GetOrCreate
Functionally equivalent to clicking the “Begin” button on the Learning Plan List page to start a new Learning Plan.
Overview
/API/LearningPlanInstance/GetOrCreate
can be used to locate an existing Incomplete LearningPlanInstance
for a specific Practitioner.
If no existing record exists, but the specified Practitioner is eligible to start a new instance of the relevant LearningPlan
, then the new instance is created and then returned.
Parameters
The following values should be specified in the querystring:
Parameter | Required? | Explanation |
---|---|---|
| Required | The ID of the |
| Required | The Title of the |
| Required | The This can be obtained using the /OData/Members API. |
| Optional | The title of the relevant |
1 You must provide either LearningPlanId
or LearningPlanTitle
, but not both.
For example:
/API/LearningPlanInstance/GetOrCreate?LearningPlanId=22&UniqueId=ABC123
Return value
If an error occurs, the return value is a JSON object like:
{ success = false, errors = string[] }
If a single pre-existing LearningPlanInstance
was located, or a new one was successfully created, the return value is a JSON object like:
{ success = true, LearningPlanInstanceId = <LPI_primary_key> }
Business rules
Errors are thrown if:
The system cannot locate a single, Granted
MemberRole
record matching the specifiedUniqueID
andRoleName
(if provided);Multiple Incomplete
LearningPlanInstances
exist that match the criteria;No existing LPIs exist, and the
LearningPlanId
orLearningPlanTitle
arguments do not uniquely identify a singleLearningPlan
to start;No existing LPIs exist, and the specified
MemberRole
is not eligible to begin a new instance of the specifiedLearningPlan
If a single MemberRole
is found, and it owns a single Incomplete LearningPlanInstance
that matches the criteria, then the ID of that record is returned. In this case, there are no side effects to calling the API.
If no existing Incomplete LearningPlanInstances
are found, and the specified MemberRole
is eligible to start a new instance, then a new one is created and the ID of that record is returned. Subsequent calls to the API will return the same ID value (they will locate the now-existing record).
To be started via this API, the following conditions must be met:
Condition | Explanation |
---|---|
The | This setting controls which Learning Plans are accessible via the Practitioner interface, and therefore which Learning Plans are “startable” by the Practitoner. |
The | The -OR- The This is the same logic that controls whether or not the “Begin” button shows up on the Learning Plan List page. It allows the LPI to be started if the owner has the necessary Role/Status, OR they are able to begin a Grant Role Workflow that would result in them having the necessary Role/Status. |
Error messages
Message | Reason | How to resolve |
---|---|---|
Member Role Unique Id <x> not found. Code | No granted Member Roles were found that match the provided | Make sure you’re passing a valid |
Member Role Unique Id <x> not found. Code | More than 1 granted Member Roles were found that match the provided | Pass a |
More than one {Glossary:LearningPlan} instance was found. | Multiple Learning Plan Instances in an Incomplete status were found that match the provided criteria. | Ensure that only one matching Learning Plan Instance is Incomplete. |
More than 1 {Glossary:LearningPlan} named “{title}” was found. | No incomplete Learning Plan Instance exists, and the system found multiple Learning Plan Definitions that could be started. | Pass the |
No {Glossary:LearningPlans} ID#<n> found. | No incomplete Learning Plan Instance exists, and no Learning Plan Definition matching the criteria was found. | Make sure you’re passing a valid |
No {Glossary:LearningPlans} titled ‘{title}’ found. |