...
Check each value is valid Reference on another Specimen resource
Validate referenced Specimen:
Check it belongs to the same patient ($.subject)
in case of error - return 422 ('Specimen with such id is not found')
Check status is available
in case of error - return 422 ('Invalid specimen status')
...
Save signed content to media storage, in the bucket pointed in MEDIA_STORAGE_SPECIMEN_BUCKET chart parameter
Generate accession_identifier number:
Generate requisition number (see Human readable requisition number) based on the specimen id. Note: requisition number should be unique for each specimen and should not match with number of another entities. So, if generated number match to existing in DB - it should be regenerated
Encode and set it into $.accession_identifier attribute
Set display_value for:
registered_by attribute
managing_organization attribute
collection.collector attribute, only if type is employee (not patient)
Set context, received_time, status_reason, collection.procedure to null
Set subject with hashed mpi identifier
Save data to specimens collection in DB according to RC.__Specimen data model_EN https://e-health-ua.atlassian.net/wiki/spaces/EH/pages/17629118845
Save link from media storage to the $.signed_content_links field in specimens collection
Create job and return it’s id.
...
HTTP status code | Message | What caused the error |
400 | Invalid signed content | |
401 | Invalid access token | |
403 | Access denied. Party is not verified | |
403 | Access denied. Party is deceased | |
403 | Your scope does not allow to access this resource. Missing allowances: specimen:write | |
404 | not found | |
409 | Patient is not verified | |
409 | 'client_id refers to legal entity that is not active' | |
409 | 'Patient is not active' | |
422 | Service request expiration date must be greater than or equal to current date | |
422 | Service request is not active or in progress | |
422 | Identifier already exists in the specimen | |
422 | Legal entity with such id is not found | |
422 | Service request is used by another legal entity | |
422 | Service request not found | |
422 | Does not match the signer drfo | |
422 | Collected quantity must not be exceeded by the specimen quantity distributed among the containers | |
422 | Date must be greater than <current date - SPECIMEN_MAX_DAYS_PASSED> | |
422 | Does not match the code of the collected quantity | |
422 | Employee doesn't belong to your legal entity | |
422 | Employee not found | |
422 | End date must be greater than or equal the start date | |
422 | End date must be in past | |
422 | Invalid employee status | |
422 | Invalid specimen status | |
422 | Must be in past | |
422 | not allowed in enum | |
422 | Patient is not active | |
422 | Patient not found | |
422 | Specimen with such id is not found | |
422 | Start date must be in past | |
422 | User is not allowed to register a specimen for the employee | |
422 | value is not allowed in enum | |
422 | schema validation error | |
422 | Managing_organization does not correspond to user's legal_entity | |
422 | Specimen with id <id> already exists | |
422 | Only one of the parameters must be present | |
422 | In case collector is patient it must be the current patient |