SELECT opr.*
INTO :outcomePlanRecommendationID,
:caseParticipantRoleID,
:relatedType,
:relatedID,
:activityType,
:nameTextID,
:recordStatus,
:outcomePlanID,
:lapseDate,
:versionNo
FROM outcomePlanRecommendation opr
WHERE opr.outcomeplanid = :outcomePlanID
AND opr.recordstatus = :recordStatus
AND opr.relatedType = :relatedType
AND NOT EXISTS(
SELECT opeo.outcomePlanExpectedOutcomeID
FROM outcomePlanExpectedOutcome opeo,
expectedOutcomeClient eoc
WHERE opeo.outcomePlanID = :outcomePlanID
AND opr.relatedID = opeo.expectedOutcomeID
AND opeo.recordStatus = 'RST1'
AND opeo.outcome = 'EOA10101'
AND eoc.outcomePlanExpectedOutcomeID = opeo.outcomePlanExpectedOutcomeID
AND opr.caseParticipantRoleID = eoc.caseParticipantRoleID
AND opr.relatedType = 'RECT31001'
)
AND NOT EXISTS(
SELECT opa.outcomePlanActionID
FROM OutcomePlanAction opa,
OutcomePlanActionRole opar
WHERE opa.outcomePlanID = :outcomePlanID
AND opr.relatedID = opa.outcomePlanActionAdminID
AND opa.status != 'OPAS10004'
AND opar.outcomePlanActionID= opa.outcomePlanActionID
AND opr.caseParticipantRoleID = opar.caseParticipantRoleID
AND opr.relatedType = 'RECT31000'
)
AND NOT EXISTS(
SELECT sd.serviceDeliveryID
FROM ServiceDelivery sd,
ServiceDeliveryLink sdl
WHERE sd.caseID = :outcomePlanID
AND opr.relatedID = sd.serviceOfferingID
AND sd.status != 'SDST3005'
AND sd.serviceDeliveryID = sdl.serviceDeliveryID
AND opr.caseParticipantRoleID = sdl.relatedID
AND opr.relatedType = 'RECT31000'
)
AND NOT EXISTS(
SELECT r.referralID
FROM referral r,
referralrole rrService,
referralRole rrRole
WHERE r.relatedObjectID = :outcomePlanID
AND rrService.referralID = r.referralID
AND opr.relatedID = rrService.relatedObjectID
AND rrRole.referralID = r.referralID
AND r.recordStatus = 'RST1'
AND opr.caseParticipantRoleID = rrRole.relatedObjectID
AND opr.relatedType = 'RECT31000'
)
|