Getting 422 No legitimate relationship on DEP

Hi,

We are getting 422 No legitimate relationship on DEP environment while calling Referral Request. Below are the details used.

https://dep.api.service.nhs.uk/referrals-dep/FHIR/STU3/ReferralRequest/000049534757

ers.url - https://dep.api.service.nhs.uk/referrals-dep

ers.token.url - https://dep.api.service.nhs.uk/oauth2/token

ers.client.id - 8hkMin0IGNYwD5VzVxvfxI0lhjsluMLV

Response - Response Code HTTP/1.1 422

{“meta”:{“profile”:[“https://fhir.nhs.uk/STU3/StructureDefinition/eRS-OperationOutcome-1”]},“resourceType”:“OperationOutcome”,“issue”:[{“severity”:“error”,“code”:“business-rule”,“details”:{“coding”:[{“code”:“NO_RELATIONSHIP”,“system”:“https://fhir.nhs.uk/STU3/CodeSystem/eRS-APIErrorCode-1”,“display”:“No relationship”}]},“diagnostics”:“No legitimate relationship with referral (000049534757).”}]}

Any pointers would be very helpful.

Thanks

Devendra

Hi Devendra, thanks for your query. Looking into this now

Hi Devendra,

The “No legitimate relationship” error indicates that the user/organisation/role in the request does not currently have a valid workflow relationship with the referral in e‑RS.

This is typically caused by one of the following:

  • The business function is not appropriate for the organisation (e.g. using REFERRING_CLINICIAN for provider retrieval)

  • The referral is not currently associated with the organisation making the request (e.g. not yet booked or on the provider worklist)

  • A mismatch between organisation, business function, and referral workflow state

To progress this, please confirm:

  • The nhsd-end-user-organisation-ods used

  • The nhsd-ers-business-function used

  • Whether the referral is visible to the user via the A008 worklist using the same context

Once we have this, we can pinpoint the exact cause.

Kind regards,

Lucy

Hi Devendra,

I’ve looked into the logs for ubrn 000049534757,I can see the referral was created at 14:03 on 14 May and had a booking confirmed at 14:06. API calls came in at 15:17 and 15:23.

The logs showed that the 422 is being caused by eRS failing to find a patient record for the NHS number on that referral in the DEP environment:

422 exceptionMessage=“Patient data not available”

Could you check whether the NHS number on the referral is a valid patient for DEP?

Thanks,

Rob

Thanks Rob,

I will ask our team to have a look and correct the details if needed. I will then try again and come back.