Skip to content

Commit

Permalink
W-14105863: clone and set id after look for cached element when resol…
Browse files Browse the repository at this point in the history
…ving new inheritance after compute min shape
  • Loading branch information
pope1838 committed Sep 13, 2023
1 parent e3369c1 commit 0492005
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#%RAML 1.0
title: 'ce-platform-gateway-api-v1'
description: 'An Api gateway for symplr'
version: 'v1'
mediaType:
- application/json
uses:
FHIR_bundles: fragments/types/fhir/fhir_bundle_types.raml
FHIR_commons: fragments/types/fhir/fhir_commons.raml

types:

Practitioner:
type: FHIR_commons.DomainResource

/practitioner:
get:
responses:
200:
body:
application/json:
type: Practitioner

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#%RAML 1.0 DataType
displayName: 'MedicationRequest'

uses:
FHIR_commons: fhir_commons.raml

description: This resource contains a list of a patient’s current prescribed medications, as documented by one organization.
type: FHIR_commons.DomainResource
properties:
id:
identifier?:
description: External Ids for this item
type: FHIR_commons.Identifier[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#%RAML 1.0 Library

uses:
FHIR_entry_types: ./fhir_entry_types.raml
FHIR_commons: ./fhir_commons.raml

types:
Resource: FHIR_commons.Resource

Bundle:
type: Resource
properties:
resourceType: string

link?:
type: array
items:
properties:
relation: string
url: string


Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#%RAML 1.0 Library

types:

code:
type: string
description: |
Indicates that the value is taken from a set of controlled strings defined elsewhere (see Using codes for further discussion).
Technically, a code is restricted to a string which has at least one character and no leading or trailing whitespace, and where there is no whitespace other than single spaces in the contents.
pattern: ^[^\s]+([\s]+[^\s]+)*

id:
type: string
pattern: ^[A-Za-z0-9\-\.]{1,64}$
description: |
Any combination of upper or lower case ASCII letters ('A'..'Z', and 'a'..'z', numerals ('0'..'9'), '-' and '.', with a length limit of 64 characters.
(This might be an integer, an un-prefixed OID, UUID or any other identifier pattern that meets these constraints.)
Identifier:
description: |
A numeric or alphanumeric string that is associated with a single object or entity within a given system.
Typically, identifiers are used to connect content in resources to external content available in other frameworks or protocols.
Identifiers are associated with objects, and may be changed or retired due to human or system process and errors.
properties:
use?:
description: usual | official | temp | secondary (If known)
type: string
enum: [usual, official, temp, secondary]

Element:
type: object
properties:
id?:
description: Internal id
type: id
extension?:
description: |
Additional Content defined by implementations - from Element: extension (recursive)
type: array
items: Extension

Extension:
properties:
url:
description: Value of extension.
type: string

BackboneElement:
type: Element
properties:
modifierExtension?:
description: Modifier Extensions
type: Extension

Reference:
type: Element
description: Many of the defined elements in a resource are references to other resources.
Using these references, the resources combine to build a web of information about healthcare.
properties:
reference?:
description: Literal reference, Relative, internal or absolute URL
type: string
display?:
description: Text alternative for the resource
type: string

DomainResource:
type: Resource

Resource:
description: Base Resource
properties:
id?:
description: Logical id of this artifact
type: id
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#%RAML 1.0 Library
uses:
FHIR_commons: fhir_commons.raml

types:
Entry:
properties:
resource?:
type: FHIR_commons.DomainResource

MedicationRequestEntry:
type: Entry
properties:
resource?: !include MedicationRequest.raml


18 changes: 18 additions & 0 deletions amf-cli/shared/src/test/scala/amf/validation/ValidationTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,24 @@ class ValidationTest extends AsyncFunSuite with PlatformSecrets {
assert(report.conforms)
}
}

test("Test complex FHIR example with property overrided cross different files and inheritances") {
val source = productionPath + "ce-platform-gateway-api-v1/ce-platform-gateway-api-v1.raml"

val config = RAMLConfiguration.RAML10()
for {
report <- config.baseUnitClient().parse(source)
transform <- Future.successful(config.baseUnitClient().transform(report.baseUnit, PipelineId.Editing))
validation <- config.baseUnitClient().validate(transform.baseUnit)
} yield {
val parseReport = AMFValidationReport.unknownProfile(report)
val transformReport = AMFValidationReport.unknownProfile(transform)

assert(validation.merge(transformReport).merge(parseReport).conforms)

}

}
private def parseAndValidate(url: String, config: => AMFGraphConfiguration): Future[AMFValidationReport] = {
val client = config.baseUnitClient()
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,11 @@ private[resolution] class MinShapeAlgorithm()(implicit val resolver: ShapeNormal
} else {
val updatedChild = resolver.getCached(child).getOrElse(child)
if (updatedChild != parent && !areTheSame(updatedChild, parent)) {
resolver.remove(updatedChild)
val r = updatedChild.setArrayWithoutId(ShapeModel.Inherits, updatedChild.inherits :+ parent)
if (updatedChild.id == child.id) resolver.remove(updatedChild)
val r = updatedChild
.copyShape()
.withId(child.id)
.setArrayWithoutId(ShapeModel.Inherits, updatedChild.inherits :+ parent)
resolver.queue(r)
r
} else updatedChild
Expand Down

0 comments on commit 0492005

Please sign in to comment.