New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.11.0 to 7.12.0-rc.1

2

package.json
{
"name": "ac-fhir-models",
"version": "7.11.0",
"version": "7.12.0-rc.1",
"author": "Henrik Joreteg <henrik@anesthesiacharting.com>",

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

@@ -1,5 +0,4 @@

import dlv from 'dlv'
// @ts-check
import { getDirectValueProp } from './prop-definitions'
const bracketsRE = /[[\]]/g
/**

@@ -24,2 +23,3 @@ * @typedef {{

* baseProps?: any
* defaultValues?: any
* fields?: any[]

@@ -43,7 +43,3 @@ * definition: any

if (typeof path === 'string') {
const cleaned = path.replace(bracketsRE, '')
combinedPropDefinition[key] = {
set: (obj, value) => definition.setValue(obj, path, value),
get: obj => dlv(obj, cleaned, null),
}
combinedPropDefinition[key] = getDirectValueProp(path)
} else {

@@ -50,0 +46,0 @@ combinedPropDefinition[key] = path

@@ -15,3 +15,21 @@ // @ts-check

const bracketsRE = /[[\]]/g
/**
* Just directly gets/sets a property on the definition with the given pathname
*
* @param {string} path
* @returns {GetterSetter}
*/
export const getDirectValueProp = path => {
const cleaned = path.replace(bracketsRE, '')
return {
set: (obj, value, definition) => {
return definition.setValue(obj, path, value)
},
get: obj => dlv(obj, cleaned, null),
}
}
/**
* @param {{

@@ -433,5 +451,11 @@ * propName: string

set: (data, value) =>
setValue(data, propName, {
reference: `${resourceType}/${value}`,
}),
setValue(
data,
propName,
value
? {
reference: `${resourceType}/${value}`,
}
: null
),
})

@@ -438,0 +462,0 @@

@@ -9,4 +9,6 @@ // @ts-check

getDirectReferenceProp,
getDirectValueProp,
getReferenceProp,
} from '../helpers/prop-definitions.js'
import dlv from 'dlv'

@@ -41,2 +43,4 @@ // const sectionCodes = {

const nsPatientDraftHhx = 'https://ns.anesthesiacharting.com/patient-draft-hhx'
const compositionFields = {

@@ -75,2 +79,4 @@ resourceType: 'str',

'section.[].code.coding.[].display': 'str',
'identifier.system': 'str',
'identifier.value': 'str',
}

@@ -186,2 +192,45 @@

// We set the identifier to the patientId when the status is preliminary
// Otherwise we set it to null
// To do this automatically we need to derive the identifier from the status
// and patient id props any time they are changed
// Create some raw props for patient and id
const rawHhxStatusProp = getDirectValueProp('status')
const rawHhxPatientProp = getDirectReferenceProp('subject', 'Patient')
// Create a derived prop for the identifier
const hhxIdentifierProp = {
get: obj => dlv(obj, 'identifier', null),
set: (data, value, definition) => {
const patientId = rawHhxPatientProp.get(data)
const status = rawHhxStatusProp.get(data)
let newValue = null
if (status === 'preliminary' && patientId) {
newValue = {
system: nsPatientDraftHhx,
value: patientId,
}
}
const result = definition.setValue(data, 'identifier', newValue)
return result
},
}
// Create a derived prop that calls the set callback after setting the raw prop
// We can use this to update the hhx identifier prop after status/patient have
// changed
const getPropWithSetCallback = (rawProp, setCallback) => {
return {
get: rawProp.get,
set: (data, value, definition) => {
data = rawProp.set(data, value, definition)
data = setCallback(data, value, definition)
return data
},
}
}
export const hhxDefinition = createFHIRModelDefinition({

@@ -192,5 +241,5 @@ resourceType: 'Composition',

title: 'title',
status: 'status',
status: getPropWithSetCallback(rawHhxStatusProp, hhxIdentifierProp.set),
patientId: getPropWithSetCallback(rawHhxPatientProp, hhxIdentifierProp.set),
authorId: getReferenceProp('author', 'Practitioner'),
patientId: getDirectReferenceProp('subject', 'Patient'),
date: 'date',

@@ -209,2 +258,3 @@ caseData: getContainedObjectProp('caseData', {

}),
identifier: hhxIdentifierProp,
},

@@ -211,0 +261,0 @@ definition: buildDefinition(compositionFields, fhirFieldTypes),

@@ -42,2 +42,84 @@ // @ts-check

t.test('identifer is automatically handled', t => {
const composition = hhxDefinition.create({})
t.notOk(
composition.identifier,
'no identifier as no preliminary status and patient'
)
const composition2 = hhxDefinition.set(composition, {
patientId: '12345',
})
t.notOk(composition2.identifier, 'no identifier as no preliminary status')
t.equal(
composition2.subject.reference,
'Patient/12345',
'but patient is set'
)
const composition3 = hhxDefinition.set(composition2, {
status: 'preliminary',
})
t.deepEqual(
composition3.identifier,
{
system: 'https://ns.anesthesiacharting.com/patient-draft-hhx',
value: '12345',
},
'identifier set as have preliminary status and patient'
)
t.equal(
composition3.subject.reference,
'Patient/12345',
'patient still set'
)
t.equal(composition3.status, 'preliminary', 'status set also')
t.notOk(
hhxDefinition.set(composition3, {
patientId: null,
}).identifier,
'no identifier as patient unset'
)
t.notOk(
hhxDefinition.set(composition3, {
status: null,
}).identifier,
'no identifier as status unset'
)
t.notOk(
hhxDefinition.set(composition3, {
status: 'final',
}).identifier,
'no identifier as status is final'
)
t.deepEqual(
hhxDefinition.set(composition3, {
identifier: { system: 'http://foo', value: 'bar' },
}).identifier,
{
system: 'https://ns.anesthesiacharting.com/patient-draft-hhx',
value: '12345',
},
'cannot set identifier directly'
)
t.deepEqual(
hhxDefinition.getValues(composition3).identifier,
{
system: 'https://ns.anesthesiacharting.com/patient-draft-hhx',
value: '12345',
},
'can get identifier'
)
t.end()
})
t.test('caseData is empty object if undefined', t => {

@@ -44,0 +126,0 @@ const composition = hhxDefinition.create({})

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