Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published

Existing method: createComposition

Implemented changes:

Validation data request

  1. prechecks - Initial checks of request input data

    1. Check for “encounter.value” attribute:

      1. If another Composition with the same type and category in the "Final" status has the same encounter.value - return 1127 (FINAL_COMPOSITION_FOR_ENCOUNTER_ALREADY_EXISTS)

    2. If “relatesTo” isn’t null:

      1. For Newborn Composition:

        1. Validate that replacement is enabled

          1. In case of error (replacement isn’t enabled) - return 1181 (REPLACEMENT_FLOW_NOT_IMPLEMENTED_YET)

      2. For Temporary Disability Composition:

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

        2. If Composition.status in indicated composition in relatesTo.target.identifier is ENTERED_IN_ERROR and replacement is enabled, then the Raplacement process is initiated

          1. In case of error (replacement isn’t enabled) - return 1181 (REPLACEMENT_FLOW_NOT_IMPLEMENTED_YET)

        3. in other cases - return 1160 (INVALID_REPLACEMENT_ARGUMENT)

    3. For Newborn Composition:

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

        1. In case of existing appropriate Compositions - return 1002 (COMPOSITION_ALREADY_EXISTS_FOR_SUBJECT)

      2. If in item b. was initiated Replacement flow:

        1. Checking the Composition.type in current Composition and Composition.type indicated in relatesTo.target.identifier

          1. In case of difference - return 1146 (CANT_REPLACE_DIFFERENT_TYPE)

        2. Check if the indicated Composition is last in the chain:

          1. In case of error (indicated Composition isn’t last in the chain) - return 1153 (CANT_AMEND_IS_APPENDED)

        3. Check if the indicated Composition has ENTERED_IN_ERROR status:

          1. In case of error (indicated Composition hasn’t ENTERED_IN_ERROR status) - return 1148 (CANT_REPLACE_IS_APPENDED)

        4. Check if the indicated Composition was canceled with Replacement’s reason

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

          2. 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)

    4. For Temporary Disability Composition:

      1. If in item b. was initiated Replacement flow:

        1. Checking the Composition.type in current Composition and Composition.type indicated in relatesTo.target.identifier

          1. In case of difference - return 1146 (CANT_REPLACE_DIFFERENT_TYPE)

        2. Check if the indicated Composition is last in the chain:

          1. In case of error (indicated Composition isn’t last in the chain) - return 1153 (CANT_AMEND_IS_APPENDED)

        3. Check if the indicated Composition has ENTERED_IN_ERROR status:

          1. In case of error (indicated Composition hasn’t ENTERED_IN_ERROR status) - return 1148 (CANT_REPLACE_IS_APPENDED)

        4. Check if the indicated Composition was canceled with Replacement’s reason

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

          2. 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)

        5. Check “event.period.start” attribute for the possibility to specify in the future:

          1. If event.period.start is specified in the future and it's not PREGNANCY category - return 1039 (INVALID_PERIOD)

        6. Check the time difference between the start date (event.period.start) and the task creation date:

          1. If the difference is more than allowed - return 1040 (PERIOD_TOLERANCE_EXCEEDED)

        7. Check for TREATMENT_VIOLATION_DATE extension:
          -search for a compositions in mc.composition by subject, and dates and check relates_to:

          1. in case when relatesTo is absent take value from TREATMENT_VIOLATION_DATE from the payload and take event.period.start from the payload. Validate:

            1. event.period.start(payload) < TREATMENT_VIOLATION_DATE(payload) < now() OR event.period.end from current composition (payload) (choose the date that comes earlier). In case of error - return 1172 (Treatment violation date should be >= composition start && <= now)

          2. in case when value in relatesTo.code is appends or transforms take value from TREATMENT_VIOLATION_DATE from the payload and take event.period.start from the first composition in the chain (the oldest one, in which relatesTo is empty). Validate:

            1. event.period.start(related oldest composition1) < TREATMENT_VIOLATION_DATE(payload) < now() OR event.period.end from current composition (payload) (choose the date that comes earlier). In case of error - return 1172 (Treatment violation date should be >= composition start && <= now)

          3. in case when value in relatesTo.code is replaces+ optionally appends/transforms OR replaces1+ replaces2 + optionally appends/transforms take value from TREATMENT_VIOLATION_DATE from the payload and take event.period.start from the first composition with replaces in relatesTo.code in the chain (the oldest one, in which relatesTo is replaces)
            -in case if there are more than one composition with replaces in relatesTo.code – take event.period.start from the first oldest one in the chain with status=FINAL
            validate:

            1. event.period.start(related oldest composition with replaces type) < TREATMENT_VIOLATION_DATE(payload) < now() OR event.period.end from current composition (payload) (choose the date that comes earlier
              - If TREATMENT_VIOLATION_DATE is outside the period of incapacity (event.period.start - event.period.end) - return 1172 (Treatment violation date should be >= composition start && <= now)

      2. If in item a. wasn’t initiated Replacement flow:

        1. In case of IS_FORCE_RENEW=true - the function completes it's execution and does not perform further checks

        2. Check for IS_FOREIGN_TREATMENT extension:

          1. If extension IS_FOREIGN_TREATMENT= true - checks 3 and 4 don’t perform

        3. Check of maximum length of one link of a medical opinion (disabilitySingleSpanFilter)

          1. In case of error - return 1039 (INVALID_PERIOD), 1031 (DURATION_SINGLE_PERIOD_TOO_LONG)

        4. Check for event.period.start attribute (periodStartFilter)

          1. In case of error - return 1039 (INVALID_PERIOD), 1040 (PERIOD_TOLERANCE_EXCEEDED)

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

          1. If previous compositions wasn’t found - the function completes it's execution

          2. If previous compositions was found - check validity period of compositions

            1. In case of error - return 1143 (NEW_START_DATE_IS_BEFORE_PREVIOUS_START_DATE), 1103(SAME_END_DATE_FOR_NEW_AND_EXISTING_COMPOSITION)

        6. Check for the maximum total length of the validity period (disabilityTotalSpanFilter)

          1. In case of error - return 1039 (INVALID_PERIOD), 1032 (DURATION_TOTAL_PERIOD_TOO_LONG)

      3. Additional checks for PREGNANCY category:

        1. If event.period.start <= taskCreated - the procedure begins to create a New Pregnancy Composition

          1. Check for “relatesTo” attribute:

            1. If it’s not null - return 1218 (NEW_PREGNANCY_COMPOSITION_CANT_HAVE_RELATIONSHIPS)

          2. Check for the length of the period of incapacity:

            1. If it’s not match with value in EMAL_VALIDATION_PREGNANCY_NEW_COMPOSITION_ALLOWED_PERIODS - return 1219 (NEW_PREGNANCY_COMPOSITION_INVALID_PERIOD)

          3. Check for “event.period.start” attribute:

            1. If event.period.start > taskCreated - return 1220 (NEW_PREGNANCY_COMPOSITION_INVALID_PERIOD_STARTS_IN_FUTURE)

        2. If event.period.start > taskCreated - the procedure begins to create a Prolongation for Previous Pregnancy Composition (appendingPregnancyComposition)

          1. Check the connections between the first and second Compositions (in “relatesTo” attribute) and check for “event.period.start” attribute in second Composition:

            1. If event.period.start < taskCreated - return 1222 (PREGNANCY_COMPOSITION_CONTINUATION_INVALID_PERIOD_STARTS_IN_PAST)

          2. Check for “event.period.start” attribute:

            1. If Event.period.startTempDisabilityComposition2 isn’t equal to Event.period.endTemporaryDisabilityComposition1+1day - return 1223 (PREGNANCY_COMPOSITION_CONTINUATION_INVALID_PERIOD_WRT_PREVIOUS)

          3. Check for the length of the period of incapacity for Prolongation Pregnancy Composition (appendedPregnancyAllowedPeriod):

            1. If it’s not match with value in EMAL_VALIDATION_PREGNANCY_APPENDED_COMPOSITION_ALLOWED_PERIOD - return 1224 (PREGNANCY_COMPOSITION_CONTINUATION_INVALID_PERIOD_LENGTH)

          4. Check for “relatesTo” attribute:

            1. If relatesTo.code = appends and it’s not a first prolongation - return 1225 (PREGNANCY_COMPOSITION_DEPTH_EXCEEDED)

            2. If “relatesTo.code” it’s not “appends“ - return 1221 (PREGNANCY_COMPOSITION_INVALID_RELATIONSHIP).