Skip to content

Commit

Permalink
:bugs: fix: Fix the unnecessary reference restriction in CodeableRefe…
Browse files Browse the repository at this point in the history
…rence data type
  • Loading branch information
Tuncay Namli committed Jan 22, 2025
1 parent 740865b commit b8096f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class StructureDefinitionParser(fhirComplexTypes: Set[String], fhirPrimitiveType
Set(FHIR_DATA_TYPES.REFERENCE, FHIR_DATA_TYPES.CODEABLE_REFERENCE, FHIR_DATA_TYPES.CANONICAL)
.contains(dtp._1)
)
.filter(dtp => dtp._3.nonEmpty || dtp._4.nonEmpty || dtp._5.nonEmpty)
.map(dt => ReferenceRestrictions(Set(dt._1), dt._3.toSet, dt._4, dt._5.toSet))
)
.filter(_._2.isDefined).map(r => r._1 -> r._2.get)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ case class ReferenceRestrictions(referenceDataTypes:Set[String],
case _ =>
}


//Try to find out resource type that each target profile is based on
val targetDataTypeAndProfiles = findResourceTypesForProfiles(fhirContentValidator)
//Target referenced resource type checking
checkReferencedResourceType(rtype, targetDataTypeAndProfiles)
.foreach(cf => issues = issues :+ cf)
if(targetProfiles.nonEmpty)
//Target referenced resource type checking
checkReferencedResourceType(rtype, targetDataTypeAndProfiles)
.foreach(cf => issues = issues :+ cf)

if(issues.exists(!_.isWarning))
issues
Expand All @@ -107,7 +109,7 @@ case class ReferenceRestrictions(referenceDataTypes:Set[String],
if (resourceConf.referencePolicies.contains("local") && url.exists(!_.startsWith(OnfhirConfig.fhirRootUrl)))
issues = issues :+ ConstraintFailure(s"Element uses referencing to a resource in a remote repository (with Reference.reference) while it is not allowed for resource '$resourceType'! ")
//If enforced, add it to list to check together with related target profiles
if (resourceConf.referencePolicies.contains("enforced")) {
if (resourceConf.referencePolicies.contains("enforced") && targetProfiles.nonEmpty) {
//Find target profiles specified for given referenced resource type
val targetProfiles = targetDataTypeAndProfiles.filter(_._2.contains(rtype)).map(_._1)
fhirContentValidator
Expand Down

0 comments on commit b8096f0

Please sign in to comment.