Table of Contents | ||||
---|---|---|---|---|
|
Purpose
This WS allows to add activity to the specified Care plan.
Specification
...
Link
...
...
Resource
...
/api/patients/{{patient_id}}/care_plans/{{care_plan_id}}/activities
...
Scope
...
care_plan:write
...
Components
...
Care plan
...
Microservices
...
me/api-medical-events
me/event-consumer
me/kafka-consumer
il/api(rpc)
...
Protocol type
...
REST
...
Request type
...
POST
...
Sync/Async
...
Async
...
Public/Private/Internal
...
Public
Logic
This method adds activity to an existing patient's Care Plan. Method receives signed message (pkcs7) that consists of signed content, digital signature and signer public key. All signature fields will be validated (including signer certificate authority). Service will store signed copy of Care Plan activity in Media Content Storage if all checks is passed.
It can be processed in both sync and async methods depends on Server decision.
Key points
One request can add only one activity to the Care plan
Activity can be added by the employee who has Approval granted by the patient on write Care plan resource
Activity adds in async way. The result of the activity addition job should be link on the created activity (look at Get Care plan activity by ID).
Activity should be signed with DS. Signed content stores in the media storage.
Global and configurable parameters
Input parameters
...
Input parameter
...
Values
...
Type
...
Description
...
Example
...
patient_id
...
String
...
MPI identifier of the person.
Required
...
7c3da506-804d-4550-8993-bf17f9ee0402
...
care_plan_id
...
String
...
Unique Care Plan identifier.
Required
...
7c3da506-804d-4550-8993-bf17f9ee0403
Filters
No
Dictionaries
eHealth/care_plan_activity_outcomes
eHealth/ICPC2/condition_codes
eHealth/ICD10_AM/condition_codes
eHealth/care_plan_activity_goals
eHealth/care_plan_activity_cancel_reasons
eHealth/care_plan_activity_complete_reasons
eHealth/ucum/units
MEDICATION_UNIT
DAYS_OF_WEEK
EVENT_TIMING
SPECIALITY_TYPES_ALLOWED
PROVIDING_CONDITIONS_ALLOWED
INNM_DOSAGE
Request structure
See on Apiary
Example:
Expand | ||
---|---|---|
| ||
|
Authorize
Verify the validity of access token
Return (401, 'Invalid access token') in case of validation fails
Verify that token is not expired
in case of error - return (401, 'Invalid access token')
Check user scopes in order to perform this action (scope = 'care_plan:write')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: care_plan:write') in case of invalid scope(s)
Headers
Наприклад:
Content-Type:application/json
Authorization:Bearer F3GF124Df565FDS234SDF34
api-key:aDGFDFGT46S5gFGD
Request data validation
Validate legal entity
Extract client_id from token
Check legal entity status is ACTIVE
In case of error - return 409 ('client_id refers to legal entity that is not active')
Check legal entity type in ME_ALLOWED_TRANSACTIONS_LE_TYPES config parameter
in case of error - return 409 ('client_id refers to legal entity with type that is not allowed to create medical events transactions')
Validate Care plan
...
Get Care plan identifier from the URL
Check Care plan:
...
belongs to patient (from url)
in case of error - return 422 ('Care plan with such id is not found')
...
is not in final status
in case of error - return 422 ('Invalid care plan status')
...
Table of Contents | ||||
---|---|---|---|---|
|
Purpose
This WS allows to add activity to the specified Care plan.
Specification
Page Properties | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Logic
This method adds activity to an existing patient's Care Plan. Method receives signed message (pkcs7) that consists of signed content, digital signature and signer public key. All signature fields will be validated (including signer certificate authority). Service will store signed copy of Care Plan activity in Media Content Storage if all checks is passed.
It can be processed in both sync and async methods depends on Server decision.
Key points
One request can add only one activity to the Care plan
Activity can be added by the employee who has Approval granted by the patient on write Care plan resource
Activity adds in async way. The result of the activity addition job should be link on the created activity (look at Get Care plan activity by ID).
Activity should be signed with DS. Signed content stores in the media storage.
Global and configurable parameters
Input parameters
Input parameter | Values | Type | Description | Example |
---|---|---|---|---|
patient_id | String | MPI identifier of the person. Required |
| |
care_plan_id | String | Unique Care Plan identifier. Required |
|
Filters
No
Dictionaries
eHealth/care_plan_activity_outcomes
eHealth/ICPC2/condition_codes
eHealth/ICD10_AM/condition_codes
eHealth/care_plan_activity_goals
eHealth/care_plan_activity_cancel_reasons
eHealth/care_plan_activity_complete_reasons
eHealth/ucum/units
MEDICATION_UNIT
DAYS_OF_WEEK
EVENT_TIMING
SPECIALITY_TYPES_ALLOWED
PROVIDING_CONDITIONS_ALLOWED
INNM_DOSAGE
eHealth/activity_remaining_quantity_types
Request structure
See on Apiary
Example:
Expand | ||
---|---|---|
| ||
|
Authorize
Verify the validity of access token
Return (401, 'Invalid access token') in case of validation fails
Verify that token is not expired
in case of error - return (401, 'Invalid access token')
Check user scopes in order to perform this action (scope = 'care_plan:write')
Return (403, 'Your scope does not allow to access this resource. Missing allowances: care_plan:write') in case of invalid scope(s)
If BLOCK_UNVERIFIED_PARTY_USERS is true, then check party's data match following condition: verification_status != NOT_VERIFIED or (verification_status = NOT_VERIFIED and updated_at <= current_date - UNVERIFIED_PARTY_PERIOD_DAYS_ALLOWED):
in case not match - return 403 ("Access denied. Party is not verified")
Headers
Наприклад:
Content-Type:application/json
Authorization:Bearer {{access_token}}
API-key:{{mis_client_secret}}
Request data validation
Validate legal entity
Extract client_id from token
Check legal entity status is ACTIVE
In case of error - return 409 ('client_id refers to legal entity that is not active')
Check legal entity type in ME_ALLOWED_TRANSACTIONS_LE_TYPES config parameter
in case of error - return 409 ('client_id refers to legal entity with type that is not allowed to create medical events transactions')
Validate Care plan
Get Care plan identifier from the URL
Check Care plan:
belongs to patient (from url)
in case of error - return 422 ('Care plan with such id is not found')
is not in final status
in case of error - return 422 ('Invalid care plan status')
Care plan’s period.end >= current date.
in case of error - return 422 ('Care Plan end date is expired')
Validate Patient
Get person_id from URL
Validate patient status is active
in case of error - return 409 ('Person is not active')
If patient is a person - validate patient'sverification_status is not equal to NOT_VERIFIED.
in case NOT_VERIFIED - return error 409, "Patient is not verified"
Validate User
Extract user_id from token.
Check user has an active and approved employee from legal entity (token) that:
has an active Approval granted by the Patient on write the Care plan resource (care plan id from URL)
Return 403 ('Access denied') in case employee has no Approval on write
Check user's employee is from the same legal entity (token) as managing_organisation from the care_plan:
Return 422 ('User is not allowed to create care plan activity for this care plan') in case employee’s legal_entity do not match managing_organisation of related care_plan
Validate Digital Sign
Validate request is signed
in case of error - return 422 (“document must be signed by 1 signer but contains 0 signatures”)
Check DS is valid and not expired
Validate that DS belongs to the author of the activity
Check that DRFO from DS and user's party.tax_id matches
in case of error - return 409 (“Signer DRFO doesn't match with requester tax_id“)
Validate activity
Activity should be validated. User fills following fields in the activity:
Validate activity identifier
Validate value in the field $.id, required
Check it is unique within Care plan and has UUID format
Return 422 ("Activity with such id already exists")
Validate care plan identifier
As care plan identifier should be contained in signed content, $.care_plan required in the request body.
Check value matches with care plan identifier from URL
in case of error - return 409 ('Care Plan from url does not match to Care Plan ID specified in body')
Validate activity author
Validate value in the field $.author, required
Check employee belongs to the user and legal entity (from token)
Employee is:
an employee who has active Approval on write the Care plan
belongs to user
in case of error - return 422 ('User is not allowed to create care plan activity for the employee')
Check employee_type is value from list of employee_types in configuration: ACTIVITY_AUTHOR_EMPLOYEE_TYPES_ALLOWED
in case of error - return 422 ('Invalid employee type')
Validate activity detail
1. Kind
Validate value in the field $.detail.kind, required
Check value in enum: medication_request, service_request
Return 422 ('value is not allowed in enum')
2. Product
Check there is one of the required $.detail.product_[x] field is set: product_reference or product_codeable_concept.
Return 422 ('Only one of the parameters must be present') in case more then one submitted
If $detail.kind=medication_request:
Check $.detail.product_reference field is submitted and has Reference type
in case it isn’t submitted - return 422 ('can't be blank')
in case of wrong type - return 422 ('type mismatch')
Check the value is valid reference on medication resource.
Return 422 ('Cannot refer to <resource>for kind = medication_request')
Check medication:
is active
in case of error - return 422 ('Medication should be active')
type is INNM_DOSAGE
in case of error - return 422 ('Medication does not exist')
Check there is no duplicated activities (status=scheduled, in_progress) with the same medication in the Care plan
Return 422 (“Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan”)
If $.detail.kind=service_request:
Check $.detail.product_reference field is submitted and has Reference type
in case it isn’t submitted - return 422 ('can't be blank')
in case of wrong type - return 422 ('type mismatch')
Check that value is a reference on service or service_group
Return 422 ('Cannot refer to <resource> for kind = service_request')
Check service or service_group is active
Return 422 ('<Service/Service group> should be active')
If $.detail.kind=device_request:
Validate product_reference:
Check there is no activities (status=scheduled, in_progress) with the same service or service_group in the Care plan
value is valid Reference on device_definition resource
Return 422 ('Cannot refer to <resource> for kind = device_request')
Check the device_definition is active
Return 422 ('Device definition is not active')
Validate product_codeable_concept:
Check that value matches with active values in
device_definition_classification_type
dictionary.Return 422 ('value is not allowed in enum')
Check there is no another activities (status=scheduled, in_progress) in the Care plan with the same product_reference or product_codeable_concept, and program = $.detail.program (including the equality of program absence/null value)
Return 422 (“Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan within current program value“)
3. Reason code
Validate value in the field $.detail.reason_code, if submitted
Check that value matches with values in
eHealth/ICD10_AM/condition_codes
dictionaryin case of error - return 422 ('value is not allowed in enum')
4. Reason reference
Validate value in the field $.detail.reason_reference, if submitted
Check that value is an array with references of condition, observation, diagnostic report or clinical impression types.
in case of error - return 422 ('
...
value is not allowed in enum')
Validate Patient
...
Get person_id from URL
...
Check that each reference:
is valid ME
belongs to the patient ($.subject)
in case of error - return
...
422 ('
...
<medical event type> with such ID is not
...
found')
If
...
in case NOT_VERIFIED - return error 409, "Patient is not verified"
Validate User
Extract user_id from token.
Check user has an active and approved employee from legal entity (token) that:
has an active Approval granted by the Patient on write the Care plan resource (care plan id from URL)
Return 403 ('Access denied') in case employee has no Approval on write
Validate Digital Sign
...
$.detail.reason_reference=clinical_impression:
Check that clinical impression is valid based on clinical_impression.code.coding.code and CLINICAL_IMPRESSION_PATIENT_CATEGORIES_<CODE.VALUE>_VALIDITY_PERIOD chart parameter: difference between now() and $.clinical_impression.effective_date_time OR $.clinical_impression.effective_period.end date must be less than a value in chart parameter (pointed in config for a corresponding care plan category) for clinical impression code
in case of error - return 422 (
...
Check DS is valid and not expired
Validate that DS belongs to the author of the activity
...
"Clinical impression with patient category exceeds validity period")
Check that clinical impression is based on active rule engine rule (exists record in rule_engine_rules collection with is_active=true, code.code=clinical_impression.code.coding.code, code.system=clinical_impression.code.coding.system)
if true - check that clinical impression still corresponds to configured rule
in case of error - return
...
Validate activity
Activity should be validated. User fills following fields in the activity:
Validate activity identifier
Validate value in the field $.id, required
Check it is unique within Care plan and has UUID format
Return 422 ("Activity with such id already exists")
Validate care plan identifier
As care plan identifier should be contained in signed content, $.care_plan required in the request body.
...
422 (“Clinical impression with patient category does not correspond to rule engine rule“)
if false - skip rule validation
5. Goal
Validate value in the field $.detail.goal, if submitted
Check that value matches with values in
eHealth/care_plan_activity_goals
dictionaryin case of error - return
...
422 ('
...
value is not allowed in enum')
...
6. Quantity
Validate value in the field $.detail.authorquantity, required
Check employee belongs to the user and legal entity (from token)
Employee is:
an employee who has active Approval on write the Care plan
belongs to user
in case of error - return 422 ('User is not allowed to create care plan activity for the employee')
Validate activity detail
1. Kind
Validate value in the field $.detail.kind, required
...
if submitted
Check it is submitted if $.detail.kind=device_request and $.detail.program is set
Return 422 ('required property quantity was not present')
Check $.detail.quantity.value is not empty, is fractional, greater than zero
Return 422 schema validation error
Validate $.detail.quantity.system, $.detail.quantity.code fields and their values in the object $.detail.quantity
If $.detail.kind=medication_request:
Check (by schemata) the $.detail.quantity.system field’s value is MEDICATION_UNIT.
Return 422 ('value is not allowed in enum')
2. Product
...
Check the $.detail.
...
quantity.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = true
Return 422 ('Code field of quantity object should be equal to denumerator_unit of one of medication’s innms')
If $.detail.kind is other than medication_request:Check the
...
$.detail.quantity.system field is not present.Return 422 ('
...
System field ofquantityobject is not allowed for kind
...
other than medication_request')
Check
...
is active
in case of error - return 422 ('Medication should be active')
type is INNM_DOSAGE
in case of error - return 422 ('Medication does not exist')
...
Check there is no duplicated activities (status=scheduled, in_progress) with the same medication in the Care plan
Return 422 (“Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan”)
...
the $.detail.quantity.code field is not present.Return 422 ('Code field ofquantityobject is not allowed for kind other than medication_request')
If $.detail.kind=service_request:
Check that $.detail.quantity.system field’s value is SERVICE_UNIT, if submitted.
Return 422 ('value is not allowed in enum')
If care plan category is class_23, class_24 or class_25:Check $.detail.quantity.system and $.detail.quantity.code are set, $.detail.quantity.code = MINUTEReturn 422 ('Code field of quantity object should be in MINUTE for care plan’s category <category code>')
if $.detail.kind=
...
device_request:
Check
...
Return 422 ('Cannot refer to medication for kind = service_request')
...
Check service or service_group is active
Return 422 ('<Service/Service group> should be active')
...
Check there is no activities (status=scheduled, in_progress) with the same service or service_group in the Care plan
Return 422 (“Another activity with status ‘scheduled' or ‘in_progress' already exists in the current Care plan“)
3. Reason code
Validate value in the field $.detail.reason_code, if submitted
Check that value matches with values in eHealth/ICD10_AM/condition_codes
dictionary
...
$.detail.quantity.value is not empty, is integer, greater than zero
Return 422 schema validation error
Check the $.detail.quantity.system is
device_unit
dictionary.Return 422 ('value is not allowed in enum')
4. Reason reference
...
Check that $.detail.quantity.code matches to active values from $.detail
...
Check that value is an array with references of condition, observation, diagnostic report or clinical impression types.
...
5. Goal
Validate value in the field $.detail.goal, if submitted
Check that value matches with values in
eHealth/care_plan_activity_goals
dictionaryin case of error - return 422 ('value is not allowed in enum')
6. Quantity
Validate value in the field $.detail.quantity, if submitted
Check $.detail.quantity.value is not empty, is integer, greater than zero
Return 422 schema validation error
Validate $.detail.quantity.system, $.detail.quantity.code fields and their values in the object $.detail.quantity
If $.detail.kind=medication_request:
Check (by schemata) the $.detail.quantity.system field’s value is MEDICATION_UNIT.
Return 422 ('value is not allowed in enum')
Check the $.detail.quantity.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = true
Return 422 ('Code field of quantity object should be equal to denumerator_unit of one of medication’s innms')
If $.detail.kind is other than medication_request:
Check the $.detail.quantity.system field is not present.
Return 422 ('System field of quantity object is not allowed for kind other than medication_request')
Check the $.detail.quantity.code field is not present.
Return 422 ('Code field of quantity object is not allowed for kind other than medication_request')
Set remaining_quantity.value = $.detail.quantity.value, and use for remaining_quantity.system, remaining_quantity.code, remaining_quantity.unit fields, which were specified in $.detail.quantity object.
7. Scheduled
If submitted, validate there is one of the $.detail.scheduled_[x] field: scheduled_timing, scheduled_period or scheduled_string.
Return 422 ('Only one of the parameters must be present') in case more then one submitted
Validate value in scheduled_timing, if submitted:
...
.quantity.system.
Return 422 ('value is not allowed in enum')
Validate Device Definitions in case $.detail.product_codeable_concept and $.detail.program was set:
...
Check that each reference:
is valid ME
belongs to the patient ($.subject)
in case of error - return 422 ('<medical event type> with such ID is not found')
...
If $.detail.reason_reference=clinical_impression:
Check that clinical impression is valid based on clinical_impression.code.coding.code and CLINICAL_IMPRESSION_PATIENT_CATEGORIES_<CODE.VALUE>_VALIDITY_PERIOD chart parameter: difference between now() and $.clinical_impression.effective_date_time OR $.clinical_impression.effective_period.end date must be less than a value in chart parameter (pointed in config for a corresponding care plan category) for clinical impression code
in case of error - return 422 ("Clinical impression with patient category exceeds validity period")
Check that clinical impression is based on active rule engine rule (exists record in rule_engine_rules collection with is_active=true, code.code=clinical_impression.code.coding.code, code.system=clinical_impression.code.coding.system)
if true - check that clinical impression still corresponds to configured rule
in case of error - return 422 (“Clinical impression with patient category does not correspond to rule engine rule“)
if false - skip rule validation
Find all active Device Definitions with packaging_unit that matches to $.detail.quantity.code
Check that there is at least one device definition where the remainder of division $.detail.quantity.value/packaging_count is equal to zero
Return 422 ('Not found any appropriate Device Definition')
Validate Device Definition in case $.detail.product_reference was set:
Get Device Definition in the $.detail.product_reference (depends on what was set)
Check it has packaging_unit that matches to $.quantity.code of the Activity
Return 422 ('Device Definition must have the same units of measure as pointed in the quantity of the Activity')
Check the remainder of division $.detail.quantity.value / device_definition.packaging_count is equal to zero
Return 422 ('The amount of devices in device request must be divisible to device package quantity')
Set remaining_quantity.value = $.detail.quantity.value, and use for remaining_quantity.system, remaining_quantity.code, remaining_quantity.unit fields, which were specified in $.detail.quantity object.
7. Scheduled
If submitted, validate there is one of the $.detail.scheduled_[x] field: scheduled_timing, scheduled_period or scheduled_string.
Return 422 ('Only one of the parameters must be present') in case more then one submitted
Validate value in scheduled_timing, if submitted:
Validate value with schema of Timing type
in case of error - return 422 schema validation error
If submitted, check values of the
event
within $.CarePlan.Period valuein case of error - return 422 ('event is not within care plan period range')
If submitted, check
bounds_period
within $.CarePlan.Period valuein case of bounds_period.end validation error - return 422 ('Period end time must be within care plan period range, after period start date')
in case of bounds_period.start validation error - return 422 ('Period start time must be within care plan period range')
If submitted, check
bounds_duration
within $.CarePlan.Period value. Calculate bounds start date as care plan period start date if activity creates before care plan has started, else if activity creates during care plan performing - bound start date calculates as activity creation date. Bounds end date as bounds start date plus count of days specified in bounds_duration.If
comparator
field in bounds_duration - use it to compare bounds_duration value and care plan duration (possible values>
,>=
,=
,<=
,<
)in case of error - return 422 ('Bounds duration must be within care plan period range')
If submitted, check
when
field values are inEVENT_TIMING
dictionaryin case of error - return 422 ('value is not allowed in enum')
If submitted, check
bounds_range
within $.CarePlan.Period value: calculate bounds start - end date for bounds_range.low and bounds_range.high as described for bounds_duration (but w/o comparator field). Also, validate low.code = high.code, high.value > low.valuein case bounds_range.low validation error - return 422 ('low must be within care plan period range, less than high, have the same code as high')
in case bounds_range.high validation error - return 422 ('high must be within care plan period range')
if submitted, check
day_of_week
field values are inDAYS_OF_WEEK
dictionaryin case of error - return 422 ('value is not allowed in enum')
if submitted, check
time_of_day
match regex^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?$
in case of error - return 422 ('string does not match pattern')
Validate value in scheduled_period. Required if medical program is set.
Validate value with schema of the Period type
in case of error - return 422 schema validation error
...
Validate $.
...
scheduled_period.end is present:
in case
...
it isn’t submitted - return 422 (
...
'can't be blank')
...
Check values within $.CarePlan.Period
...
in case
...
period.end validation error - return 422 ('Period end time must be within care plan period range, after period start date')
in case
...
period.start validation error - return 422 ('Period start time must be within care plan period range')
8. Location
Validate value in the field $.detail.location, if submitted
Check the value is valid reference on division resource
Check the division is active and division’s legal entity has active status
Return 422 ('Division is not active')
9. Performer
Validate value in the field $.detail.performer, if submitted
Check the value is valid reference o employee resource
Check employee is active and approved
Return 422 ('Invalid employee status')
10. Daily amount
If submitted, check
...
$.
...
If
comparator
field in bounds_duration - use it to compare bounds_duration value and care plan duration (possible values>
,>=
,=
,<=
,<
)in case of error - return 422 ('Bounds duration must be within care plan period range')
...
If submitted, check when
field values are in EVENT_TIMING
dictionary
in case of error - return 422 ('value is not allowed in enum')
...
If submitted, check bounds_range
within $.CarePlan.Period value: calculate bounds start - end date for bounds_range.low and bounds_range.high as described for bounds_duration (but w/o comparator field). Also, validate low.code = high.code, high.value > low.value
in case bounds_range.low validation error - return 422 ('low must be within care plan period range, less than high, have the same code as high')
in case bounds_range.high validation error - return 422 ('high must be within care plan period range')
...
if submitted, check day_of_week
field values are in DAYS_OF_WEEK
dictionary
in case of error - return 422 ('value is not allowed in enum')
...
if submitted, check time_of_day
match regex ^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?$
in case of error - return 422 ('string does not match pattern')
Validate value in scheduled_period, if submitted:
Validate value with schema of the Period type
in case of error - return 422 schema validation error
Check values within $.CarePlan.Period
in case period.end validation error - return 422 ('Period end time must be within care plan period range, after period start date')
in case period.start validation error - return 422 ('Period start time must be within care plan period range')
...
detail.daily_amount has the same code and system as quantity field.
Return 422 ('Units of daily_amount field should be equal to units of quantity field')
Validate value in the field $.detail.daily_amount, if submitted.Check activity kind is medication_requestReturn 422 ('Field is allowed for medication request activities only') in case kind is not medication_request
Validate $.detail.daily_amount.system, $.detail.daily_amount.code fields and their values in the object $.detail.daily_amountIf $.detail.kind=medication_request:Check (by schemata) the $.detail.daily_amount.system field’s value is MEDICATION_UNIT.Return 422 ('value is not allowed in enum')
Check the $.detail.daily_amount.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = trueReturn 422 ('Code field ofdaily_amountobject should be equal to denumerator_unit of one of medication’s innms')
If $.detail.kind is other than medication_request:Check the $.detail.daily_amount.system field is not present.Return 422 ('System field ofdaily_amountobject is not allowed for kind other than medication_request')
Check the $.detail.daily_amount.code field is not present.Return 422 ('Code field ofdaily_amountobject is not allowed for kind other than medication_request')
11. Medical program
Validate field exists for kind = medication_request
If $.detail.kind=medication_request, check that $.program is submitted
in case of error - return 422 ("Medical program must be submitted for kind = medication_request")
Validate value in the field $.detail.locationprogram, if submitted
Check the value is valid reference on division resource
Check the division is active and division’s legal entity has active status
Return 422 ('Division is not active')
9. Performer
Validate value in the field $.detail.performer, if submitted
Check the value is valid reference o employee resource
Check employee is active and approved
Return 422 ('Invalid employee status')
10. Daily amount
Validate value in the field $.detail.daily_amount, if submitted.
Check activity kind is medication_request
Return 422 ('Field is allowed for medication request activities only') in case kind is not medication_request
Validate $.detail.daily_amount.system, $.detail.daily_amount.code fields and their values in the object $.detail.daily_amount
If $.detail.kind=medication_request:
Check (by schemata) the $.detail.daily_amount.system field’s value is MEDICATION_UNIT.
Return 422 ('value is not allowed in enum')
Check the $.detail.daily_amount.code field’s value equals to dosage.denumerator_unit of one of INNMs of a INNM_DOSAGE where innms with is_primary = true
Return 422 ('Code field of daily_amount object should be equal to denumerator_unit of one of medication’s innms')
If $.detail.kind is other than medication_request:
Check the $.detail.daily_amount.system field is not present.
Return 422 ('System field of daily_amount object is not allowed for kind other than medication_request')
Check the $.detail.daily_amount.code field is not present.
Return 422 ('Code field of daily_amount object is not allowed for kind other than medication_request')
11. Medical program
Validate field exists for kind = medication_request
If $.detail.kind=medication_request, check that $.program is submitted
in case of error - return 422 ("Medical program must be submitted for kind = medication_request")
Validate value in the field $.program, if submitted
Сheck program exists and active
in case not found or is_active==false return 404 "Program not found"
Validate product is program participant:
If product is medication - validate:
that medication has brand that is an active member of the program (program_medications table)
in case not found or is_active==false return 422 "Medication is not included in the program"
that care_plan_activity_allowed for program medication == true
in case ==false return 422 "Forbidden to create care plan activity for this medication!"
If product is service - validate that service is an active member of the program
in case not found or is_active==false return 422 "Service is not included in the program"
if product is service_group - validate that service group is an active member of the program
in case not found or is_active==false return 422 "Service group is not included in the program"
Validate medical program settings (prm.medical_programs table):
if there is a parameter SPECIALITY_TYPES_ALLOWED:
Check author’s speciality is present in SPECIALITY_TYPES_ALLOWED
in case of error - return 422 “Author’s specialty doesn't allow to create activity with medical program from request”
if there is a parameter CONDITIONS_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED:
Check related Care plan has condition codes in
addresses
field that correspond to codes pointed in CONDITIONS_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED (depending on dictionary - eHealth/ICD10_AM/condition_codes or eHealth/ICPC2/condition_codes)in case of error - return 422 “Care plan diagnosis is not allowed for the medical program“
If there is a parameter PROVIDING_CONDITIONS_ALLOWED:
Check related Care plan has a value in
terms_of_service
field that is included in the list of PROVIDING_CONDITIONS_ALLOWED parameterin case of error - return 422 “Care plan’s terms of service are not allowed for the medical program“
if there is a parameter patient_categories_allowed:
check that patient_categories_allowed has codes in $.detail.reason_reference.[].clinical_impression.code.[].code that correspond to codes pointed in patient_categories_allowed
in case of error - return 422 "Clinical impression with patient category should be present in request for this medical program".
12. Do not perform flag
Validate value in the field $.do_not_perform
Check it is
false
in case of error - return 422 ('not allowed in enum')
13. Status
Validate value in the field $.status
Check it has value = scheduled
in case of error - return 422 ('value is not allowed in enum')
Processing
...
Save signed content to media storage
...
Save data to care_plan_activities collection in DB according to Care plan data model
for kind = medication_request
add
unit
(and its value) field intoquantity
,daily_amount
, objects based onsystem
,code
out of MEDICATION_UNIT dictionary.add
system
,code
,unit
fields intoremaining_quantity
based onquantity
object
...
Save link from media storage to the $.signed_content_links field in care plan activities collection
If Care plan has status = new:
...
Set care plan status = active
Check if patient has another active or/and new Care plans with such condition code in the addresses field and the same terms of service:
...
Сheck program exists and active
in case not found or is_active==false return 404 "Program not found"
Validate product is program participant:
If product is medication - validate:
that medication has brand that is an active member of the program (program_medications table) or medication itself is an active member of the program
in case not found or is_active==false return 422 "Medication is not included in the program"
that care_plan_activity_allowed for program medication == true
in case ==false return 422 "Forbidden to create care plan activity for this medication!"
If product is service - validate that service is an active member of the program
in case not found or is_active==false return 422 "Service is not included in the program"
if product is service_group - validate that service group is an active member of the program
in case not found or is_active==false return 422 "Service group is not included in the program"
If product is code from
device_definition_classification_type
dictionary (product_codeable_concept was set) or product is device_definition (product_reference was set):Find all program devices with:
is_active=true
care_plan_activity_allowed = true
period (start_date and end_date) that includes current date
max_daily_count >= $.quantity.value/($.detail.scheduled_period.end - $.detail.scheduled_period.start + 1). Count scheduled_period length in days, without taking into account time
related to the Device Definitions that has successfully passed Quantity and Product validations before
in case not found return 422 ('No appropriate participants found for this medical program')
Validate medical program settings (prm.medical_programs table):
if there is a parameter SPECIALITY_TYPES_ALLOWED:
Check author’s speciality is present in SPECIALITY_TYPES_ALLOWED
in case of error - return 422 “Author’s specialty doesn't allow to create activity with medical program from request”
if there is a parameter CONDITIONS_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED:
Check related Care plan has condition codes in
addresses
field that correspond to codes pointed in CONDITIONS_ICD10_AM_ALLOWED or/and CONDITIONS_ICPC2_ALLOWED (depending on dictionary - eHealth/ICD10_AM/condition_codes or eHealth/ICPC2/condition_codes)in case of error - return 422 “Care plan diagnosis is not allowed for the medical program“
If there is a parameter PROVIDING_CONDITIONS_ALLOWED:
Check related Care plan has a value in
terms_of_service
field that is included in the list of PROVIDING_CONDITIONS_ALLOWED parameterin case of error - return 422 “Care plan’s terms of service are not allowed for the medical program“
if there is a parameter patient_categories_allowed:
check that patient_categories_allowed has codes in $.detail.reason_reference.[].clinical_impression.code.[].code that correspond to codes pointed in patient_categories_allowed
in case of error - return 422 "Clinical impression with patient category should be present in request for this medical program".
if there is parameter device_request_allowed_code_types and activity kind=device_request, then check values in the array of values:
if it includes
CLASSIFICATION_TYPE
- it is allowed to set $.detail.product_codeable_concept in the activityif it includes
DEVICE_DEFINITION
- it is allowed to set $.detail.product_reference in the activityin case of a mismatch between the filled field and the config values - return 422 ("<Device definition/Device classification type> is not allowed to set for this medical program").
12. Do not perform flag
Validate value in the field $.do_not_perform
Check it is
false
in case of error - return 422 ('not allowed in enum')
13. Status
Validate value in the field $.status
Check it has value = scheduled
in case of error - return 422 ('value is not allowed in enum')
Processing
Save signed content to media storage
Save data to care_plan_activities collection in DB according to Care plan data model
for kind = medication_requestadd
unit
(and its value) field intoquantity
,daily_amount
, objects based onsystem
,code
out of MEDICATION_UNIT or SERVICE_UNIT dictionary.add
system
,code
,unit
fields intoremaining_quantity
based onquantity
object
Save link from media storage to the $.signed_content_links field in care plan activities collection
If Care plan has status = new:
Set care plan status = active
Check if patient has another active or/and new Care plans with such condition code in the addresses field and the same terms of service:
If such Care plans found - set these Care plans statuses to TERMINATED (related activities doesn`t change their status)
Set $.details.remaining_quantity_type:
If $.details.kind = medication_request or device_request, then check $.details.quantity:
if $.details.quantity = null then set $.details.remaining_quantity_type = null
if $.details.quantity is not null then:
set $.details.remaining_quantity_type = for_request
If $.details.kind = service_request check $.details.quantity:
if $.details.quantity = null then set $.details.remaining_quantity_type = null
if $.details.quantity is not null then check $.details.quantity.code:
if $.details.quantity.code is not null then set $.details.remaining_quantity_type = for_request
if $.details.quantity.code = null then set $.details.remaining_quantity_type = for_use
Create job and return it’s id.
...
Expand | ||
---|---|---|
| ||
|
Post-processing processes
API paragraph not found
HTTP status codes
Page Properties | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|