Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

...

  1. Validate diagnostic_report _id is unique for MongoDB.Diagnostic_reports

  2. Validate that one of diagnostic reports categories 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 "None of the diagnostic report categories matches with the service category"

  3. Validate that service, referenced as a code in DR, is active
    Note. For diagnostic_report.code pass only "service", and the "service_group" does not pass

    1. PRM.services.is_active = true where PRM.services.id=$.diagnostic_report.code.identifier.value

      1. in case of errror return 422 "Service is not active"

    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 referrals

    1. As a referral it can be referenced electronic (registered in the system) OR paper service request

    2. Validate ($.diagnostic_report.based_on OR $.diagnostic_report.paper_referral) or none in request

    3. Validate based on as Reference(Referencevalidation)

    4. Validate paper referral as Object (paper_referral)

    5. 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. 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 used_by_legal_entity==token.client_id or NULL

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

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

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

            3. For an old activities (has no units in quantity) validate remaining_quantity as described at Submit Encounter Data Package#Relatedcareplanvalidation

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

      6. Check if service request quantity is not exhausted as described atSubmit Encounter Data Package: Related service request validation

  5. Validate effective_period as a period (PeriodValidation)

  6. Validate that issued is within acceptable limits

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

      1. in case of error 422 "Issued 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}}" 

  7. Validate primary_source==true

    1. If !=true - return 422 ('value is not allowed in enum' [ true ])

  8. Validate recorded_by as Employee:

    1. recorded_by employee_types allowed: DOCTOR, SPECIALIST, ASSISTANT, LABORANT

      1. in case of error 422 "Invalid employee type"

  9. Validate performer.identifier as Employee:

    1. check that performer.identifier field is mandatory and employee_types allowed: DOCTOR, SPECIALIST, ASSISTANT, LABORANT

      1. in case of error 422 "Invalid employee type"

  10. 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."

  11. Validate results_interpreter.identifier as Employee:

    1. if the category.coding.code is in (imagingdiagnostic_procedure) check that results_interpreter.identifier is an employee with employee_type = DOCTOR or SPECIALIST

      1. in case of error 422 "Invalid employee type"

    2. if the category.coding.code is in (diagnostic_curativelaboratory_procedure) - results_interpreter field is optional and the results_interpreter.identifier validation skipped

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

  13. Validate division

    1. Validate division as Reference(Referencevalidation)

    2. $division is an existing ID in PRM.divisions

      1. in case return 422, "Division with such id is not found"

    3. division.status=ACTIVE and is_active=true

      1. in case error return 409, "Division is not active"

    4. division.legal_entity_id = $client_id

      1. in case error return 409, "Division is not in current legal_entity"

  14. Patient must be active

    1. check that patients.status == active

      1. in case patients.status == inactive

        1. check mpi.persons(or mpi.prepersons if patients.preperson == true).updated_at and validate that now() - updated_at<=SUBMIT_DIAGNOSTIC_REPORT_PACKAGE_ALLOWED_PERIOD configuration (in minutes)

          1. in case of error return 409 (Person is not active more that the allowed time for data submitting)

  15. If patient is person - validate verification status:

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

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

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

  16. Validate for each element in specimens array, if submitted:

    1. Check the element is a Reference on a specimen resource

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

    2. Check it exists in DB and belongs to the same patient:

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

    3. Check status is available

      1. in case of error return 422 "Specimen should be in available status"

Observation validation

  1. Validate observations ids as  primary keys (Primarykeyvalidation)

  2. Validate that diagnostic_report of ALL observation is a current DR

    $.observations[*].diagnostic_report.identifier.value==$.diagnostic_report.id

    in case

    Validate used_references

    1. Validate used_reference.identifier.type.coding.[0].code is 'equipment'

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

    2. Validate used_reference.identifier.type.coding.[0].code is status is 'ACTIVE' and is_active=true

      1. in case error return 422 ('Equipment is not active')

    3. Validate used_reference.identifier.type.coding.[0].code is availability_status is 'Available' 

      1. in case error return 422 ('Equipment is not available')

    4. Validate used_reference.identifier.type.coding.[0].code is legal_entity_id is Legal entity for performer in Diagnostic report

      1. in case error return 422 ('Equipment does not belong to Legal entity')

    5. If Equipment and Diagnostic report has a division, then validate it is the same Division

      1. in case error return 422 ('Equipment does not belong to division from diagnostic report')

Observation validation

  1. Validate observations ids as  primary keys (Primarykeyvalidation)

  2. Validate that diagnostic_report of ALL observation is a current DR

    1. $.observations[*].diagnostic_report.identifier.value==$.diagnostic_report.id

      1. in case of error return "Submitted diagnostic report is not allowed for the observation"

  3. $.observations[*].effective_period validate as Period PeriodValidation

  4. Validate that the date is within acceptable limits

    1. $.observations[*].issued <= current_time

      1. in case of error return "Issued date must be in past"

    2. $.observations[*].issued>=current_date-observation_max_days_passed

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

  5. Validate performer as Employee:

    1. performer employee_types allowed: DOCTOR, SPECIALIST, ASSISTANT, LABORANT

      1. in case of error 422 "Invalid employee type"

  6. Validate $.observations[*].value_period as a Period

  7. Validate components

    1. if $.observations[*].code.coding[*].system is "eHealth/ICF/classifiers":

      1. Check number of component items with $.observations[*].components[*].code.coding[*].system = "eHealth/ICF/qualifiers": 

        1. if $.observations[*].code.coding[*].code starts from "b" letter, then components must contain exact 1 item with:

          1. $.observations[*].components[*].code.coding[*].code = "extent_or_magnitude_of_impairment" 

            1. in case of missing qualifier - return 422 "Missing components with qualifiers <list of missing qualifiers>"

            2. in case of incorrect number of qualifiers - return 422 "Required 1 component, but got <number of items>"

            3. in case value is not active in dictionary - return 422 "Value is not active"

        2. if $.observations[*].code.coding[*].code starts from "s" letter, then components must contain exact 3 items with:

          1. $.observations[*].components[*].code.coding[*].code = "extent_or_magnitude_of_impairment"

          2. $.observations[*].components[*].code.coding[*].code = "nature_of_change_in_body_structure"

          3. $.observations[*].components[*].code.coding[*].code = "anatomical_localization"

            1. in case of missing qualifier - return 422 "Missing components with qualifiers <list of missing qualifiers>"

            2. in case of incorrect number of qualifiers - return 422 "Required 3 components, but got <number of items>"

            3. in case value is not active in dictionary - return 422 "Value is not active"

        3. if $.observations[*].code.coding[*].code starts from "d" letter, then components must contain exact 2 items with:

          1. $.observations[*].components[*].code.coding[*].code = "performance"

          2. $.observations[*].components[*].code.coding[*].code = "capacity"

            1. in case of missing qualifier - return 422 "Missing components with qualifiers <list of missing qualifiers>"

            2. in case of incorrect number of qualifiers - return 422 "Required 2 components, but got <number of items>"

            3. in case value is not active in dictionary - return 422 "Value is not active"

        4. if $.observations[*].code.coding[*].code starts from "e" letter, then components must contain exact 1 item with:

          1. $.observations[*].components[*].code.coding[*].code = "barrier_or_facilitator"

            1. in case of missing qualifier - return 422 "Missing components with qualifiers <list of missing qualifiers>"

            2. in case of incorrect number of qualifiers - return 422 "Required 1 component, but got <number of items>"

            3. in case value is not active in dictionary - return 422 "Value is not active"

      2. Check $.observations[*].components[*].value_codeable_concept is present in each item with $.observations[*].components[*].code.coding[*].system = "eHealth/ICF/qualifiers" and  $.observations[*].components[*].value_codeable_concept.coding[*].system corresponds to $.observations[*].components[*].code.coding[*].code

        1. in case not present or doesn't correspond -  return 422 "Doesn't correspond to $.observations[i].components[i].code"

        2. in case code value is not active in dictionary - return 422 "Value is not active"

  8. if observations[*].categories[0].coding[0].system == "eHealth/ICF/observation_categories" - skip validation of observations[*].value and make this fields optional

    1. else - check that one off this fields present:

      1. Validate$.observations[*].components[*].value_period as a Period

      2. Validate $.observations[*].value_quantity

        1. $.observations[*].value must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

        2. $.observations[*].comparator can take the following values : [">", ">=", "=", "<=", "<"]

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

        3. $.observations[*].unit can take values from dictionary eHealth/ucum/units 

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

      3. Validate $.observations[*].value_codeable_concept

        1. $.observations[*].code validate that the code belongs to the dictionary system

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

      4. Validate $.observations[*].value_boolean

        1. $.observations[*].value_boolean must be boolean type

          1. in case of error return "type mismatch. Expected boolean but got {entered type}"

      5. Validate $.observations[*].value_string

        1. $.observations[*].value_string must be string type

          1. in case of error return "type mismatch. Expected string but got {entered type}"

      6. Validate $.observations[*].value_sampled_data

        1. $.observations[*].data must be string type

          1. in case of error return "type mismatch. Expected string but got {entered type}"

        2. $.observations[*].origin must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

        3. $.observations[*].period must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

        4. $.observations[*].factor must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

        5. $.observations[*].lower_limit must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

        6. $.observations[*].upper_limit must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

        7. $.observations[*].dimensions must be with number type

          1. in case of error return "type mismatch. Expected number but got {entered type}"

      7. Validate $.observations[*].value_range

        1. $.observations[*].low must be with object type

          1. in case of error return "type mismatch. Expected object but got {entered type}"

        2. $.observations[*].high must be with object type

          1. in case of error return "type mismatch. Expected object but got {entered type}"

      8. Validate $.observations[*].value_ratio

        1. $.observations[*].numerator must be with object type

          1. in case of error return "type mismatch. Expected object but got {entered type}"

        2. $.observations[*].denominator must be with object type

          1. in case of error return "type mismatch. Expected object but got {entered type}"

      9. Validate $.observations[*].value_time

        1. $.observations[*].value_time must be with string type

          1. in case of error return "type mismatch. Expected string but got {entered type}"

      10. Validate $.observations[*].value_date_time

        1. $.observations[*].value_date_time must be with string type

          1. in case of error return "type mismatch. Expected string but got {entered type}"

  9. Validate $.observations.code

    1. if observations.code.coding[*].code value is included in chart variables 'OBSERVATION_CODES_WITH_<VALUE_TYPE>_REQUIRED', <value_type> field is mandatory

      1.  in case of error return 422 “This field is required for code = <code>“

    2. if observations[*].code.coding[*].system is "eHealth/ICF/classifiers", then:

      1. Check observations[*].categories[*].coding[*].system should contain "eHealth/ICF/observation_categories"

        1. in case of error return 422 “Code doesn't match observation category“

      2. Check observations[*].components are presented

        1. in case of error return 422 “Components required“

  10. Validate $.observations[*].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. $.observations[*].categories[*].coding[*].system is "eHealth/observation_categories" or "eHealth/ICF/observation_categories" 

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

    3. $.observations[*].categories[*].coding[*].code corresponds to the system

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

    4. If $.observations[*].categories[*].coding[*].system = "eHealth/ICF/observation_categories", then $.observations[*].code should be filled from "eHealth/ICF/classifiers" dictionary. Also, check $.observations[*].categories[*].coding[*].code value match following $.observations[*].code.coding[*].code value:

      1. if category code is functions, then code value should start with "b" letter

      2. if category code is structures, then code value should start with "s" letter

      3. if category code is activities, then code value should start with "d" letter

      4. if category code is environmental, then code value should start with "e" letter 

        1. in case of error return 422 “Code doesn't match observation category“

  11. Validate specimen, if submitted:

    1. Check the field is a Reference on a specimen resource

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

    2. Check it exists in DB and belongs to the same patient:

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

    3. Check status is available

      1. in case of error return 422 "Specimen should be in available status"

    Validate device:

    1. Check the field is a Reference on a equipment on a specimen resource

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

    2. Validate status is 'ACTIVE' and is_active=trueCheck it exists in DB and belongs to the same patient:

      1. in case of error return 422 “Equipment is "Specimen not active“found"

    3. Validate availability_Check status is 'Available' available

      1. in case of error return 422 ('Equipment is not available')

    4. Validate  is legal_entity_id is Legal entity for performer for Diagnostic report

      1. in case error return 422 ('Equipment does not belong to Legal entity')

    Validate used_references

    1. Validate used_reference.identifier.type.coding.[0].code is 'equipment'

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

    2. Validate used_reference.identifier.type.coding.[0].code is status
      1. "Specimen should be in available status"

  12. Validate device:

    1. Check the field is a Reference on a equipment resource

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

    2. Validate status is 'ACTIVE' and is_active=true

      1. in case error return 422 ('Equipment is not active')

      Validate used_reference.identifier.type.coding.[0].code is availability_
      1. “Equipment is not active“

    3. Validate availability_status is 'Available' 

      1. in case error return 422 ('Equipment is not available')

    4. Validate used_reference.identifier.type.coding.[0].code Validate  is legal_entity_id is Legal entity for performer in for performer for Diagnostic report

      1. in case error return 422 ('Equipment does not belong to Legal entity')

      If Equipment and Diagnostic report has a division, then validate it is the same Division

      1. in case error return 422 ('Equipment does not belong to division from diagnostic report')

Postprocessing

  1. Set managing_organization for submitted observations

    1. ME.observations{observ_id}.managing_organization=token.client_id

  2. In case diagnostic report.based_on was filled set $.diagnostic_report.id to related to $.service_request $.activity[].outcome_reference

    1. Update $ .activity.status to in_progress if previous activity status was scheduled

    2. Update the $ .activity.remaining_quantity parameter by the value achieved at Submit Encounter Data Package#Relatedcareplanvalidation(for an old activities only that has no quantity units)

    3. Update remaining_quantity in the service request with a value that was calculated in the Related service request validation