Ahryman40k / typescript-fhir-types

Typescript / Javascript object model for FHIR standard
MIT License
126 stars 27 forks source link

Code handling for AuditEvent #14

Closed matthewdenobrega closed 2 years ago

matthewdenobrega commented 4 years ago

I just checked out the library, so this is probably a misunderstanding:

When I decode this example AuditEvent the result doesn't validate because the example has numbers for outcome and agent.network.type. I see from the code that you have defined enums, and the library is expecting values like 'Success' for outcome, and 'MachineName' for agent.network.type.

The possible values for outcome are defined here. Network type is defined here. My understanding is that the code (ie the number) should be included in the resource.

Could you clarify what the expected behaviour for decode is, wrt these code fields?

const validationResult = R4.RTTI_AuditEvent.decode(auditEventJSON)
console.log(PathReporter.report(validationResult))

[ 'Invalid value "2" supplied to : IAuditEvent/0: { resourceType: "AuditEvent", type: ICoding, agent: Array, source: IAuditEvent_Source }/agent: Array/0: IAuditEvent_Agent/network: IAuditEvent_Network/type: AuditEvent_NetworkTypeKind', 'Invalid value "1" supplied to : IAuditEvent/0: { resourceType: "AuditEvent", type: ICoding, agent: Array, source: IAuditEvent_Source }/agent: Array/1: IAuditEvent_Agent/network: IAuditEvent_Network/type: AuditEvent_NetworkTypeKind', 'Invalid value "0" supplied to : IAuditEvent/1: Partial<{ id: RTTI_idType, meta: IMeta, implicitRules: RTTI_uriType, _implicitRules: IElement, language: RTTI_codeType, _language: IElement, text: INarrative, contained: Array, extension: Array, modifierExtension: Array, subtype: Array, action: AuditEventActionKind, _action: IElement, period: IPeriod, recorded: RTTI_instantType, _recorded: IElement, outcome: AuditEventOutcomeKind, _outcome: IElement, outcomeDesc: string, _outcomeDesc: IElement, purposeOfEvent: Array, entity: Array }>/outcome: AuditEventOutcomeKind' ]

Ahryman40k commented 4 years ago

Hi @matthewdenobrega,

Please let me few days to analyse the sample. What I first say is the FHIR model used was in version 4.0.0 and we are now in version 4.0.1. I mean some properties may have changed. We also use AuditEvent at work and I didn't notice any issue yet. I'll check how people are using it.

Thank you for you interest Geoffrey.

Ahryman40k commented 4 years ago

Hi @matthewdenobrega,

Finally, it's easier as I thought, the provided value for the network type is '2' and in my library, in file RTTI_AuditEvent_Network.ts, you can see 'type' is type of AuditEvent_NetworkTypeKind define as

export enum AuditEvent_NetworkTypeKind {
    _machineName = 'MachineName',
    _ipAddress = 'IPAddress',
    _telephoneNumber = 'TelephoneNumber',
    _emailAddress = 'EmailAddress',
    _uri = 'Uri'
}

So it means '2' is an invalid value. I may have made a mistake there ...

I'm rewriting the generator, but I'm really busy. So please be patient or don't hesitate to fork the repository to fix the code.

Best regards

vetlevo commented 2 years ago

I ran into the same issue when starting to use this library for creating audit events, basically the values defined in enum: https://github.com/Ahryman40k/typescript-fhir-types/blob/9bb375d63bd7730a530718dc9138f2caf73f7104/src/R4/Resource/RTTI_AuditEvent_Network.ts#L4 should be numerical codes from 1 through 5 and not the display names as mentioned previously. This has been the same since FHIR version 3.0.0 https://hl7.org/fhir/STU3/codesystem-network-type.html

There is also an issue as mentioned above with the AuditEventOutcomeKind.

Proposed changes:

export enum AuditEvent_NetworkTypeKind {
    _machineName = '1',
    _ipAddress = '2',
    _telephoneNumber = '3',
    _emailAddress = '4',
    _uri = '5'
}
export enum AuditEventOutcomeKind {
    _success = '0',
    _minorFailure = '4',
    _seriousFailure = '8',
    _majorFailure = '12'
}

Apart from this single issue we've had great use of this package! 😊

Ahryman40k commented 2 years ago

I really lack of free time, do you think you could create a PR for that part at least ?

bar-vim commented 2 years ago

@Ahryman40k I came across this issue as well. can you take a look at my fix? thanks!

Ahryman40k commented 2 years ago

fixed with PR #45

Ahryman40k commented 2 years ago

Hi Bar,

I merged your Pull request and published the update. Thank you for your help !

Le mer. 9 févr. 2022, à 05 h 12, Bar Molot @.***> a écrit :

@Ahryman40k https://github.com/Ahryman40k I came across this issue as well. can you take a look at my fix? thanks!

— Reply to this email directly, view it on GitHub https://github.com/Ahryman40k/typescript-fhir-types/issues/14#issuecomment-1033590586, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSIXTKCUD4S6WWTHRFQ3ALU2I4XPANCNFSM4KLX6ICQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>