Purpose
This method allows to create Composition of all types and categories for a person/pre-person in eHealth.
Used in processes:
Specification
Link | https://app.swaggerhub.com/apis/ehealthua/compositions/2.32.2#/main/createComposition |
Resource | /patients/composition |
Scope | composition:create |
Components | |
Using Dictionaries | API paragraph not found |
Using Microservices | API paragraph not found |
Protocol type | REST |
Request type | POST |
Sync/Async | Async |
Public/Private/Internal | Public |
Logic
Sequence:
MIS/Medical employee->Compositions: Create Composition POST/patients/composition
Compositions->Compositions: Check user scopes authorization composition:create
Compositions-->MIS/Medical employee: In case of error HTTP/401
Compositions->Compositions: Async job planning
Compositions->MIS/Medical employee: Async job details
Compositions<->eHealth:data clarification and verification about author, custodsan, diagnosis etc
Compositions->Compositions:Create and save Composition according to the XML template
Compositions->Compositions:Async job Completed
MIS/Medical employee->Compositions: GET/patients/composition/job/{asyncJobId}
Compositions->MIS/Medical employee:Async job completed (conclusionAsyncJobListItem.href)
MIS/Medical employee->Compositions:GET/patients/{patientId}/composition/{compositionId}/episode/{episodeId}/encounter/{encounterId}
Compositions->MIS/Medical employee: Composition in PRELIMINARY status
MIS/Medical employee->MIS/Medical employee:Signs document and gives to patient
MIS/Medical employee->Compositions:Sign Composition PATCH /patients/composition/{compositionId}/sign
Compositions->Compositions:Check user scopes authorization composition:sign
Compositions-->MIS/Medical employee: In case of error HTTP/401
Compositions->MIS/Medical employee: HTTP/200 Async job Created
Compositions<->eHealth:Signature and author validation
Compositions->Compositions:Save object on SWIFT/S3
Compositions->Compositions:Schedule of trigger interactions (DIIA,MJU_DRACZ,ERLN,MPI,Closure)
MIS/Medical employee->Compositions:GET /patients/composition/job/{asyncJobId}
Compositions->MIS/Medical employee:Async job completed (conclusionAsyncJobListItem.href)
MIS/Medical employee->Compositions:GET/patients/{patientId}/composition/{compositionId}/episode/{episodeId}/encounter/{encounterId}
Compositions->MIS/Medical employee:Composition in FINAL status
Request structure
Example
Authorize
Check user scopes in order to perform this action (scope = 'composition:create')
return 401 (Unauthorized) in case of invalid scope(s)
Headers
API paragraph not found
Validation data request
prechecks - Initial checks of request input data
If “relatesTo” isn’t null:
For Newborn Composition:
Validate that replacement is enabled
In case of error (replacement isn’t enabled) - return 1181 (REPLACEMENT_FLOW_NOT_IMPLEMENTED_YET)
For Temporary Disability Composition:
If Composition.subject=person in current composition, Composition.subject = preperson in indicated composition in relatesTo.target.identifier and composition.status is FINAL, then the Refinement process is initiated
If Composition.status in indicated composition in relatesTo.target.identifier is ENTERED_IN_ERROR and replacement is enabled, then the Raplacement process is initiated
In case of error (replacement isn’t enabled) - return 1181 (REPLACEMENT_FLOW_NOT_IMPLEMENTED_YET)
in other cases - return 1160 (INVALID_REPLACEMENT_ARGUMENT)
For Newborn Composition:
Checking for an already created Composition for preperson (“subject” attribute) which are according such requirements: Composition.type is Newborn and Composition.status isn’t ENTERED_IN_ERROR:
In case of existing appropriate Compositions - return 1002 (COMPOSITION_ALREADY_EXISTS_FOR_SUBJECT)
If in item a. was initiated Replacement flow:
Checking the Composition.type in current Composition and Composition.type indicated in relatesTo.target.identifier
In case of difference - return 1146 (CANT_REPLACE_DIFFERENT_TYPE)
Check if the indicated Composition is last in the chain:
In case of error (indicated Composition isn’t last in the chain) - return 1153 (CANT_AMEND_IS_APPENDED)
Check if the indicated Composition has ENTERED_IN_ERROR status:
In case of error (indicated Composition hasn’t ENTERED_IN_ERROR status) - return 1148 (CANT_REPLACE_IS_APPENDED)
Check if the indicated Composition was canceled with Replacement’s reason
In case of right Replacement’s reason - check validity period of Composition according to the configuration parameter EMAL_FILTER_REPLACEMENT_CANCEL_TIMEOUT_NEWBORN. In case of error - return 1039 (INVALID_PERIOD)
In case of common cancelation reason - check validity period of Composition according to the configuration parameter EMAL_FILTER_PERIOD_START_NEWBORN. In case of error - return 1039 (INVALID_PERIOD)
For Temporary Disability Composition:
If in item a. was initiated Replacement flow:
Checking the Composition.type in current Composition and Composition.type indicated in relatesTo.target.identifier
In case of difference - return 1146 (CANT_REPLACE_DIFFERENT_TYPE)
Check if the indicated Composition is last in the chain:
In case of error (indicated Composition isn’t last in the chain) - return 1153 (CANT_AMEND_IS_APPENDED)
Check if the indicated Composition has ENTERED_IN_ERROR status:
In case of error (indicated Composition hasn’t ENTERED_IN_ERROR status) - return 1148 (CANT_REPLACE_IS_APPENDED)
Check if the indicated Composition was canceled with Replacement’s reason
In case of right Replacement’s reason - check validity period of Composition according to the configuration parameter EMAL_FILTER_REPLACEMENT_CANCEL_TIMEOUT_DISABILITY. In case of error - return 1039 (INVALID_PERIOD)
In case of common cancelation reason - check validity period of Composition according to the configuration parameter EMAL_FILTER_PERIOD_START_DISABILITY. In case of error - return 1039 (INVALID_PERIOD)
f in item a. wasn’t initiated Replacement flow:
In case of IS_FORCE_RENEW=true - the function completes it's execution and does not perform further checks
Check of maximum length of one link of a medical opinion (disabilitySingleSpanFilter)
In case of error - return 1039 (INVALID_PERIOD), 1031 (DURATION_SINGLE_PERIOD_TOO_LONG)
Check for event.period.start attribute (periodStartFilter)
In case of error - return 1039 (INVALID_PERIOD), 1040 (PERIOD_TOLERANCE_EXCEEDED)
Search for previous compositions with the same type and category as in the request, overlapping with the period of validity for this composition for at least 1 day
If previous compositions wasn’t found - the function completes it's execution
If previous compositions was found - check validity period of compositions
In case of error - return 1143 (NEW_START_DATE_IS_BEFORE_PREVIOUS_START_DATE), 1103(SAME_END_DATE_FOR_NEW_AND_EXISTING_COMPOSITION)
Check for the maximum total length of the validity period (disabilityTotalSpanFilter)
In case of error - return 1039 (INVALID_PERIOD), 1032 (DURATION_TOTAL_PERIOD_TOO_LONG)
Encounter Processing - Receiving and processing medical records (Encounter)
Employee Processing - Receiving and processing Employee record (Composition.author)
Division Processing - Receiving and processing Devision record (Employee Devision)
Legal Entity Processing - Receiving and processing Legal Entity record (Employee Legal Entity)
Subject Processing - Receiving and processing Subject record
Focus Processing - Receiving and processing Focus record
getSmsPhoneNumber - Receiving phone number for sending SMS about creation of composition
Saving the record of the Сomposition into database
Task status updating in DONE
Processing
prechecks - Initial checks of request input data
Encounter Processing - Receiving and processing medical records (Encounter)
Employee Processing - Receiving and processing Employee record (Composition.author)
Division Processing - Receiving and processing Devision record (Employee Devision)
Legal Entity Processing - Receiving and processing Legal Entity record (Employee Legal Entity)
Subject Processing - Receiving and processing Subject record
Focus Processing - Receiving and processing Focus record
getSmsPhoneNumber - Receiving phone number for sending SMS about creation of composition
Saving the record of the Сomposition into database
Task status updating in DONE
Response structure
Example:
Post-processing processes
None
HTTP status codes
HTTP status code | Message | What caused the error |
---|---|---|
200 | In case of successful creation of the task for creation Composition creation |
|
400 | Invalid request format | Validation failed |