-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EM-1575 add blockreplace script for spec
- Loading branch information
Showing
5 changed files
with
189 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API. | ||
# See https://redoc.ly/docs/cli/ for more information. | ||
# See https://redocly.com/docs/cli/ for more information. | ||
specification/multicast-notification-service.yaml: | ||
info-license: | ||
- '#/info' | ||
specification/requestBody/create-or-update-subscription-body.yaml: | ||
struct: | ||
- '#/content/blockReplace/action' | ||
- '#/content/blockReplace/actioning' | ||
- '#/content/blockReplace/actioned' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
import json | ||
|
||
|
||
def apply_nested_replacements(data, replacements=None): | ||
if isinstance(data, dict): | ||
if "blockReplace" in data: | ||
replacements = data["blockReplace"] | ||
del data["blockReplace"] | ||
|
||
for key, value in data.items(): | ||
if isinstance(value, str) and replacements: | ||
for placeholder, replacement in replacements.items(): | ||
value = value.replace(f"[[{placeholder}]]", replacement) | ||
data[key] = value | ||
else: | ||
apply_nested_replacements(value, replacements) # recurse | ||
|
||
elif isinstance(data, list): | ||
for index, item in enumerate(data): | ||
apply_nested_replacements(item, replacements) # recurse | ||
|
||
|
||
input_data = sys.stdin.read() | ||
json_data = json.loads(input_data) | ||
apply_nested_replacements(json_data) | ||
# send to stdout | ||
print(json.dumps(json_data, indent=2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
specification/requestBody/create-or-update-subscription-body.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
required: true | ||
content: | ||
blockReplace: | ||
action: "Create" | ||
actioning: "creating" | ||
actioned: "created" | ||
application/fhir+json: | ||
schema: | ||
type: "object" | ||
required: | ||
- "resourceType" | ||
- "status" | ||
- "reason" | ||
- "criteria" | ||
- "channel" | ||
properties: | ||
resourceType: | ||
type: "string" | ||
description: "The subscription FHIR Resource: https://hl7.org/fhir/R4/subscription.html" | ||
status: | ||
type: "string" | ||
description: "The status of the subscription. When [[actioning]] a subscription, the value must be `requested`." | ||
end: | ||
type: "string" | ||
format: "date-time" | ||
description: | | ||
Optional expiry date/time for the subscription. As per the [FHIR R4 instant data type](https://hl7.org/fhir/R4/datatypes.html#instant) time shall be specified to at least the second and include a time zone. | ||
For example: YYYY-MM-DDThh:mm:ss.sss+zz:zz (e.g. 2015-02-07T13:28:17.239+02:00 or 2017-01-01T00:00:00Z) | ||
reason: | ||
type: "string" | ||
description: "A description of why this subscription is required. You may provide an empty string." | ||
criteria: | ||
type: "string" | ||
description: | | ||
Criteria for the subscription. Provide your criteria with each condition separated by `&;`. If you are requesting a generic subscription to all signals of a certain type the separator is not required. For example, `eventType=gpreg-change-gp-req-1&;generalpractitioner=XY11` | ||
or `eventType=gpreg-change-gp-req-1`. A valid criteria must contain a permitted value for `eventType`. Additional criteria depends on the event and are documentated on our [Signal Catalogue page](https://digital.nhs.uk/developer/api-catalogue?query=mns+event+publish-subscribe). | ||
channel: | ||
type: "object" | ||
required: | ||
- "type" | ||
- "endpoint" | ||
- "payload" | ||
description: "The channel on which to report matches to the criteria. SQS Endpoints must be unique per event type; attempts to add a subscription with an endpoint which is already in-use will fail with a HTTP 409 (Conflict)" | ||
properties: | ||
type: | ||
type: "string" | ||
description: "The type of channel to send notifications on. Of the options within [FHIR](https://hl7.org/fhir/R4/valueset-subscription-channel-type.html), MNS currently only supports `message`." | ||
endpoint: | ||
type: "string" | ||
description: "The endpoint which signals will be delivered to. MNS currently only supports delivery to [MESH](https://digital.nhs.uk/services/message-exchange-for-social-care-and-health-mesh) mailboxes and [AWS SQS](https://aws.amazon.com/sqs/) endpoints. Note: for MESH delivery you must provide the full mailbox ID and for SQS delivery you must provide the full SQS ARN of your desired queue." | ||
payload: | ||
type: "string" | ||
description: "The mime type to send the payload in. MNS supports `application/json` and `application/fhir+json` (FHIR R4 Bundle)." | ||
hydration: | ||
type: "object" | ||
required: | ||
- "enabled" | ||
description: "Optional block to configure hydration properties - hydration is disabled by default." | ||
properties: | ||
enabled: | ||
type: "boolean" | ||
description: "A flag to enable (true) or disable (false) signal hydration." | ||
headers: | ||
type: object | ||
description: "An optional dictionary of HTTP headers that will be sent in the request to the API endpoint specified in the signal." | ||
additionalProperties: | ||
type: string | ||
description: "HTTP header that will be sent in the request to the API endpoint specified in the signal." | ||
examples: | ||
pdsChangeofGPSubscription: | ||
description: "[[action]] a pds change of GP subscription" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=pds-change-of-gp-1" | ||
channel: | ||
type: "message" | ||
endpoint: "arn:aws:sqs:eu-west-2:123456789012:queue1" | ||
payload: "application/json" | ||
pdsChangeofGPSubscriptionMeshDelivery: | ||
description: "[[action]] a pds change of GP subscription with MESH delivery" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=pds-change-of-gp-1" | ||
channel: | ||
type: "message" | ||
endpoint: "mesh://MYMAILBOXOT101?workflow_id=myWorkflow101" | ||
payload: "application/json" | ||
nhsNumberChangeSubscription: | ||
description: "[[action]] an NHS number change subscription" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=nhs-number-change-1" | ||
channel: | ||
type: "message" | ||
endpoint: "arn:aws:sqs:eu-west-2:123456789012:queue2" | ||
payload: "application/json" | ||
pdsDeathNotificationSubscription: | ||
description: "[[action]] a pds death notification subscription" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=pds-death-notification-1" | ||
channel: | ||
type: "message" | ||
endpoint: "arn:aws:sqs:eu-west-2:123456789012:queue2" | ||
payload: "application/fhir+json" | ||
immunisationVaccinationSubscription: | ||
description: "[[action]] an immunisation vaccination subscription" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=imms-vaccinations-1" | ||
channel: | ||
type: "message" | ||
endpoint: "arn:aws:sqs:eu-west-2:123456789012:queue2" | ||
payload: "application/json" | ||
validatedGPRegistrationRequestSubscription: | ||
description: "[[action]] a validated GP registration request event subscription" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=gpreg-change-gp-req-1&;supplierNACS=Y12345&;registrationencountercode=3" | ||
channel: | ||
type: "message" | ||
endpoint: "arn:aws:sqs:eu-west-2:123456789012:queue2" | ||
payload: "application/fhir+json" | ||
patientflagsChangeSubscription: | ||
description: "[[action]] a Patient Flags Change subscription" | ||
value: | ||
resourceType: "Subscription" | ||
status: "requested" | ||
end: "2022-04-05T17:31:00.000Z" | ||
reason: "A description of why this subscription should be [[actioned]]." | ||
criteria: "eventType=patientflags-change-1&;flagtype=NRAF&;generalpractitioner=XY11" | ||
channel: | ||
type: "message" | ||
endpoint: "arn:aws:sqs:eu-west-2:123456789012:queue2" | ||
payload: "application/fhir+json" |