Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ac-fhir-models

Package Overview
Dependencies
Maintainers
0
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ac-fhir-models - npm Package Compare versions

Comparing version 7.6.3 to 7.6.4

2

package.json
{
"name": "ac-fhir-models",
"version": "7.6.3",
"version": "7.6.4",
"author": "Henrik Joreteg <henrik@anesthesiacharting.com>",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -6,2 +6,5 @@ // @ts-check

export const DELETED_REFERENCE_URL_PREFIX =
'https://ns.anesthesiacharting.com/deleted-reference/'
/**

@@ -296,6 +299,12 @@ * @typedef GetterSetter

* @param {string} resourceType The FHIR Resource type
* @param {{ deletable?: boolean }} [opts]
* @returns {GetterSetter}
*/
export const getReferenceProp = (propName, resourceType) => {
export const getReferenceProp = (
propName,
resourceType,
{ deletable = false } = {}
) => {
const predicate = entry => entry.reference.includes(`${resourceType}/`)
const deletedPrefixWithResourceType = `${DELETED_REFERENCE_URL_PREFIX}${resourceType}/`
return {

@@ -308,2 +317,9 @@ get: data => {

}
if (reference.startsWith(DELETED_REFERENCE_URL_PREFIX)) {
return {
deleted: reference.replace(deletedPrefixWithResourceType, ''),
}
}
return reference.replace(`${resourceType}/`, '')

@@ -317,4 +333,14 @@ },

if (value) {
let reference
if (value.deleted) {
if (!deletable) {
throw new Error('Cannot delete this reference')
}
reference = `${deletedPrefixWithResourceType}${value.deleted}`
} else {
reference = `${resourceType}/${value}`
}
return setValue(data, `${propName}.[${index}]`, {
reference: `${resourceType}/${value}`,
reference,
})

@@ -321,0 +347,0 @@ } else {

@@ -115,3 +115,5 @@ // @ts-check

}),
appointmentId: getReferenceProp('about', 'Appointment'),
appointmentId: getReferenceProp('partOf', 'Appointment', {
deletable: true,
}),
},

@@ -139,3 +141,3 @@ definition: buildDefinition(

'statusReason.coding.[].display': 'str',
'about.[].reference': 'str',
'partOf.[].reference': 'str',
},

@@ -142,0 +144,0 @@ fhirFieldTypes

@@ -5,2 +5,35 @@ // @ts-check

test('patientCommentDefinition supports deletable references', t => {
t.test('When not deleted, deals in string references', t => {
const startProps = {
appointmentId: 'abc',
}
const resource = patientCommentDefinition.create(startProps)
t.deepEqual(resource.partOf, [{ reference: 'Appointment/abc' }])
const values = patientCommentDefinition.getValues(resource)
t.equal(values.appointmentId, 'abc')
t.end()
})
t.test('When deleted, deals in { deleted: id } objects', t => {
const startProps = {
appointmentId: { deleted: 'abc' },
}
const resource = patientCommentDefinition.create(startProps)
t.deepEqual(resource.partOf, [
{
reference:
'https://ns.anesthesiacharting.com/deleted-reference/Appointment/abc',
},
])
const values = patientCommentDefinition.getValues(resource)
t.deepEqual(values.appointmentId, { deleted: 'abc' })
t.end()
})
t.end()
})
test('patientCommentDefinition supports external author types', t => {

@@ -110,3 +143,3 @@ const startProps = {

],
about: [{ reference: 'Appointment/abc' }],
partOf: [{ reference: 'Appointment/abc' }],
status: 'completed',

@@ -113,0 +146,0 @@ })

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc