Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This WS allows to create Specimen entity by employees without submitting Encounter Data Package.

Specification

Link

 Apiary

Resource

 api/patients/patient_id/specimens

Scope

 specimen:write

Components

 Specimen

Microservices

 

Protocol type

 REST

Request type

 POST

Sync/Async

 Async

Public/Private/Internal

 Public

...

Validate each value in $.request, array of Reference type, if submitted

  • Array item has type of {Reference} to Service Request resource

    • in case of error - return 422 ('not allowed in enum')

  • Service Request exists in the DB and relates to the patient ($.subject)

    • in case of error - return 422 ("Service request not found")

  • Service Request’s status is active or program_processing_status is in_progress (any status is valid in case program_processing_status= in_progress)

    1. in case of error - return 422 ("Service request is not active or in progress")

  • If used_by_legal_entity is set in the Service request (program_processing_status=in_progress), then check it matches the client_id from token

    • in case of error - return 422 ("Service request is used by another legal entity")

  • Check if Service Request’s expiration date is less then or equal to current date

    1. in case of error - return 422 ("Service request expiration date must be greater than or equal to current date")

...

  • Validate value with schema of the {Period} type

    • in case of error - return 422 schema validation error

  • Check if period start is greater then (current_date - SPECIMEN_MAX_DAYS_PASSED) date

    • in case of error - return 422 ('Date must be greater than <current date - SPECIMEN_MAX_DAYS_PASSED>')

  • Check if period start is less then or equal to current datetime

    • in case of error - return 422 ('Start date must be in past')

  • Check end >= start

    • in case of error - return 422 ('End date must be greater than or equal the start date')

  • Check end <= current datetime (is not in the future)

    • in case of error - return 422 ('End date must be in past')

...

  1. Save signed content to media storage, in the bucket pointed in MEDIA_STORAGE_SPECIMEN_BUCKET chart parameter

  2. Generate accession_identifier number:

    1. 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

    2. Encode and set it into $.accession_identifier attribute

  3. Set display_value for:

    1. registered_by attribute

    2. managing_organization attribute

    3. collection.collector attribute, only if type is employee (not patient)

  4. Set context, received_time, status_reason, collection.procedure to null

  5. Set subject with hashed mpi identifier

  6. Save data to specimens collection in DB according to /wiki/spaces/SPECIMEN/pages/17548214286 RC.__Specimen data model_EN

  7. Save link from media storage to the $.signed_content_links field in specimens collection

  8. Create job and return it’s id.

Response structure

See on Apiary

Example:

Expand
titleResponse example
Code Block
{
  "data": {
    "status": "pending",
    "eta": "2018-08-02T10:45:16.000Z",
    "links": [
      {
        "entity": "job",
        "href": "/Jobs/NBXk9EyErUZv1RhXgyvgg"
      }
    ]
  },
  "meta": {
    "code": 202,
    "url": "http://example.com/resource",
    "type": "object",
    "request_id": "req-adasdoijasdojsda"
  }
}

...