Skip to content

Commit

Permalink
✨ feat(FhirApiValidator): Include resource identifier along with ID i…
Browse files Browse the repository at this point in the history
…n error description.
  • Loading branch information
Okanmercan99 committed Oct 15, 2024
1 parent 9fe3311 commit dd80f1a
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ object FHIRApiValidator {
batchOrTransactionRequest
.childRequests
.filter(rq => rq.resourceId.isDefined && Seq(FHIR_INTERACTIONS.UPDATE, FHIR_INTERACTIONS.DELETE, FHIR_INTERACTIONS.PATCH).contains(rq.interaction))
.map(rq => rq.resourceType.get + "/" + rq.resourceId.get)
.map(rq => {
// Extracting the identifier field from the resource
val identifier = (rq.resource.get \ "identifier") match {
case JString(id) => id
case _ => ""
}

// Constructing resource type and id string with identifier (ResourceType/ResourceId, Identifier)
(s"${rq.resourceType.get}/${rq.resourceId.get}" -> identifier)
})
val resourcesReferredMultipleTimes = resourcesToBeChanged.groupBy(identity).filter(_._2.length > 1).keys.toSeq
if (resourcesReferredMultipleTimes.nonEmpty)
throw new BadRequestException(Seq(OutcomeIssue(
Expand Down

0 comments on commit dd80f1a

Please sign in to comment.