Versions Compared

Key

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

Validate Diagnostic Report

  1. Validate diagnostic reports ids as primary keys

  2. Validate based_on as Reference

  3. Validate that service_request, referenced as based_on, is

    1. in status is active or program_processing_status=in_progress (any status is valid in case program_processing_status= in_progress)

      1. in case of error return 409 "Invalid service request status"

    2. if program is defined than used_by_legal_entity==token.client_id OR null

      1. in case of error return 409 "Service request is used by another legal_entity"

    3. if program is defined than program_processing_status == new, in_queue or in_progress

    4. check that service_request contains based_on parameter

      1. in case based_on present in service_request

        1. verify care_plan:

          1. It should be in active status

          2. Care plan's period end (if exist) should be greater than current date or equal.

        2. verify activity:

          1. It has activity.detail.kind=service_request; activity.detail.product_reference=service_id. 

          2. It has scheduled, in_progress status

      2. in case based_on not present in request skip previous validations.

    5. Check if service request quantity is not exhausted as described at related service request validation

  4. category

    1. Validate $.diagnostic_report[*].categories

      1. is an array with only one item

        1. in case of error return 422 "Expected a maximum of 1 items but got <number of elements>"

    2. Validate that $.diagnostic_report[*].category.coding.code is eHealth/diagnostic_report_categories dictionary, required

      1. in case of error return 422 "value is not allowed in enum"

    3. Validate that diagnostic reports category corresponds to service category, that is references as code in DR

      1. $.diagnostic_report[*].category=PRM.services.category where PRM.services.id=$.diagnostic_report[*].code.identifier.value

        1. in case of error return 422 "Diagnostic report category does not match with the service category"

  5. Validate code

    1. Validate code as Reference

    2. If service_requests.code.identifier.value is service, validate $diagnostic_report.code.identifier.value = service_requests.code.identifier.value

      1. in case error return 409, "Service in diagnostic_report differ from service in service request"

    3. if service_requests.code.identifier.value is service_group, validate $diagnostic_report.code.identifier.value in (SELECT service_id from service_inclusions where service_group_id='service_requests.code.identifier.value')

      1. in case error return 409, "Service in diagnostic_report differ from services in service request's service_group"

    4. Validate diagnostic_report.service.is_active = true

      1. in case error return 409, "Service should be active"

  6. Validate effective_period and effective_date_time:

    1. Check that only one of this parameters present

      1. in case error return 422 "Only one of the parameters must be present"

  7. Validate effective_period as a period

  8. Validate that issued is within acceptable limits

    1. $.diagnostic_reports[*].issued<= current date_time

      1. in case of error 422 "Asserted date  must be in past"

    2. $.diagnostic_reports[*].issued>=current_date-diagnostic_report_max_days_passed

      1. in case of error 422 "Issued must be greater than  {{current_date-diagnostic_report_max_days_passed}}" 

  9. Validate conclusion_code:

    1. $.diagnostic_reports[*].conclusion_code.coding[*].code validate that the code belongs to the dictionary system 'eHealth/ICD10_AM/condition_codes'

      1. in case of error return "Value is not allowed in enum"

    2. Check that there is only one code in conclusion_code.coding array

      1. if more - return error "Only one code from one dictionary is allowed"

  10. Validate recorded_by as Employee

  11. Validate encounter

    1. $.diagnostic_reports[*].encounter.identifier.value == $.encounter.id

      1. in case of error 409 "Invalid reference"

  12. Validate performer:

    1. as Employee

    2. according to logic Performer(asserter) validation

  13. Validate managing_organization is a current legal_entity

    1. $.managing_organization.identifier.value==token.client_id

      1. in case of error 409 "Managing organization does not correspond to user's legal entity."

  14. Validate result_interpreter.identifier as Employee

  15. Validate result_interpreter.identifier is an employee with employee_type = DOCTOR or SPECIALIST

  16. Validate only One of the fields is filled:

    1. $.diagnostic_report[*].results_interpreter.reference OR $.diagnostic_report[*].results_interpreter.text

    2. $.diagnostic_report[*].performer.reference OR $.diagnostic_report[*].performer.text

  17. Validate primary_source

    1. If primary_source==true, then

      1. Managing organization MUST be filled

      2. performer.reference MUST be filled

    2. If primary_source==false, then

      1. report_origin must be filled

      2. performer.reference must NOT be filled

      3. results_enterpreter.reference must NOT be filled

  18. Validate patient verification status:

    1. If diagnostic report has based_on with valid and active service request, then skip this validation.

    2. Else check patient's verification_status is not equal to NOT_VERIFIED.

      1. in case of error return 409, "Patient is not verified"

  19. Validate specimens, if submitted:

    1. Check field has array with elements of Reference type on specimen resource

      1. in case of error return 422 “not allowed in enum”

    2. For each specimen check:

      1. Check it exists in DB or within current package, and belongs to the same patient:

        1. in case of error return 422 "Specimen not found"

      2. Check it is present in the only one diagnostic report within the package.

        1. in case of error return 422 "Specimen is already used in another diagnostic report"

      3. Check status:

        1. is available if the specimen found in the DB

          1. in case of error return 422 "Specimen created before the current package should be available"

        2. is unavailable if the specimen not found in the DB, but in the package