Giter Club home page Giter Club logo

typescript-fhir-types's People

Contributors

ahryman40k avatar bar-vim avatar dependabot[bot] avatar jwess avatar twonamejames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typescript-fhir-types's Issues

Fhir enums are a little bit annoying ...

When I generated enums for library, I took some ease.
So, In order to generate my code I've done things like this:

export enum ExpressionLanguageKind {
        textCql = 'textCql',
        textFhirpath = 'textFhirpath',
        applicationXFhirQuery = 'applicationXFhirQuery'
}

and create the adapted keyof type with io-ts.

but data in json are more like that:

 "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/cqf-expression",
            "valueExpression": {
              "language": "text/cql",
              "expression": "Now()"
            }
          }
        ]

See text/cql vs textCql ...
I need a better way to fix this !

Solve union issue with io-ts

PASS src/tests/account_coverage.spec.ts
PASS src/tests/tryout.spec.ts
PASS src/tests/account_guarantor.spec.ts (17.176s)
FAIL src/tests/account.spec.ts
● Test suite failed to run

TypeError: Cannot read property 'name' of undefined

  146 | import * as t from 'io-ts';
  147 | 
> 148 | export const RTTI_ResourceList = t.union([
      |                                    ^
  149 |     RTTI_Account,
  150 |     RTTI_ActivityDefinition,
  151 |     RTTI_AdverseEvent,

  at node_modules/io-ts/lib/index.js:764:59
      at Array.map (<anonymous>)
  at getUnionName (node_modules/io-ts/lib/index.js:764:25)
  at Object.<anonymous>.exports.union (node_modules/io-ts/lib/index.js:770:35)
  at Object.<anonymous> (src/Union/RTTI_ResourceList.ts:148:36)
  at Object.<anonymous> (src/Resource/RTTI_Account.ts:6:1)
  at Object.<anonymous> (src/__tests__/account.spec.ts:1:1)

Test Suites: 1 failed, 3 passed, 4 total
Tests: 5 passed, 5 total
Snapshots: 0 total
Time: 22.055s

Support for FHIR R4B (4.3.0)

Hi! Is it envisioned to release the library updated to recently released FHIR R4B (4.3.0)?

The library is best-in-class for FHIR support. Is there, by any chance, a way to (semi-)automatically ingest the newer standards?

Code handling for AuditEvent

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<IAuditEvent_Agent>, source: IAuditEvent_Source }/agent: Array<IAuditEvent_Agent>/0: IAuditEvent_Agent/network: IAuditEvent_Network/type: AuditEvent_NetworkTypeKind',
'Invalid value "1" supplied to : IAuditEvent/0: { resourceType: "AuditEvent", type: ICoding, agent: Array<IAuditEvent_Agent>, source: IAuditEvent_Source }/agent: Array<IAuditEvent_Agent>/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<IAuditEvent_Entity> }>/outcome: AuditEventOutcomeKind' ]

Including enums brings tons of unnecessary code into the bundle

If you do

import { IHumanName } from '@ahryman40k/ts-fhir-types/lib/R4'
import { HumanNameUseKind } from '@ahryman40k/ts-fhir-types/lib/R4/Resource/RTTI_HumanName'
let name: IHumanName = {
    use: HumanNameUseKind._maiden,
}
// […] use the `name` var in some way

and webpack it, it’ll bring ~75K of stuff from typescript-fhir-types and io. And if you include HumanNameUseKind from @ahryman40k/ts-fhir-types/lib/R4, it’ll bring the entire library into the bundle.

If only we could use string literal types instead of enums… This would allow type-only imports, with zero code actually require()d.

RTTI_Patient not decoding birthDate

I'm trying to decode birthDate with the RTTI_Patient class, and it is not working.

Given this input:
{ "resourceType": "DiagnosticReport", "id": "d9d19378-8f55-4641-8462-b8f35cbc9dd3", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Pulmonary nodule narrative</b></p><p>small masses of tissue seen in lung</p></div>" }, "contained": [{ "resourceType": "Patient", "id": "patient1", "birthDate" : "2020-01-01", "identifier": [{ "use": "usual", "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v2-0203", "code": "MR" }] }, "value": "anonymous" }] }, { "resourceType": "ImagingStudy", "id": "study1", "status": "available", "identifier": [{ "use": "usual", "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v2-0203", "code": "ACSN" }] }, "value": "758843" }], "subject": { "reference": "#patient1" }, "procedureCode": [{ "coding": [{ "system": "http://loinc.org", "code": "79068-3", "display": "CT Chest w IV Contrast Screening" }], "text": "CT Chest" }] }], "imagingStudy": [{ "reference": "#study1" }], "status": "final", "category": [{ "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v2-0074", "code": "RAD", "display": "Radiology" }] }], "code": { "coding": [{ "system": "http://loinc.org", "code": "68604-8", "display": "Radiology Diagnostic study note" }] }, "subject": { "reference": "#ai-algorithm-details" }, "effectiveDateTime": "2018-04-13T12:00:00-05:00", "conclusion": "lung nodule seen." }

I am getting this error:
Invalid value undefined supplied to : IPatient/0: { resourceType: "Patient" }/resourceType: "Patient".

If I remove birthDate from the Patient object, it decodes fine.

AuditEvent.recorded is not mandated

Current AuditEvent interface IAuditEvent has

recorded?: string;

This field has a 1:1 cardinality in the FHIR spec (STU3/ DSTU4) so is mandatory.

Why are the enum entries prefixed with underscores ?

Hi,

Thanks for your work on this library. It saves me quite some time.

I wonder why in the enums every entry is prefixed with an underscore, as I'm tempted to remove them.

export declare enum CarePlan_DetailStatusKind {
    _notStarted = "not-started",
    _scheduled = "scheduled",
    _inProgress = "in-progress",
    _onHold = "on-hold",
    _completed = "completed",
    _cancelled = "cancelled",
    _stopped = "stopped",
    _unknown = "unknown",
    _enteredInError = "entered-in-error"
}

Reject additional properties

Hi,
Is it possible for the library to reject additional properties not defined in the FHIR Schema?
For example, the following object is accepted by the decode api

{
    "resourceType": "Location",
    "AdditionalField": "IsNotAllowed"
}
const validationResult = R4.RTTI_Location.decode(obj);

    if (validationResult.isLeft()) {
      return {
        status: 400,
        body: validationResult
      }
    }

    return {
      status: 200,
      body: 'valid'
    }

Object creation

Hi

Is it somehow possible to generate a "prefilled" object with mandatory fields and fixed literals?

We use Profiles (TS interfaces) based on io-ts with e.g. already fixed meta information from external. We now don't want to recreate all the information in the interfaces again.

As far as I understand this is taking json objects and validates them.

Thanks for feedback

Help using the package.

Hi, I just started using this package, and I am running into some issues that I was hoping you could help me with. I am pulling a FHIR patient resource from an end point, and getting the patient structure back that I want to leverage

import { R4 } from '@ahryman40k/ts-fhir-types'
import * as either from "fp-ts/lib/Either";

const fhir_patient = R4.RTTI_Patient.decode(patient_data) // patient_data is coming from an end_point
// I now have a either.Validation<R4.IPatient>  for fhir_patient

The question I have is how do I now extract the R4.RTTI_Patient from it. The documentation on the site says that
we should do

const  obs: R4.IPatient = either.isRight(fhir_patient);

but as I understand it isRight returns a bool, so cannot be cast to R4.IPatient

Am I missing something ? Or is there a different way of doing this with the current version of the package.
Thanks for any help that you can provide.

How to check runtime type of an unknown resource

Say I wanted to make a function that does a runtime check of the provided type, like so

// what is the type of desiredType?
function isValidFHIRType(desiredType: any, resource: any) {
  const checkResult = desiredType.decode(resource);
  return checkResult.isRight();
}

I'm not sure what the type of the desiredType argument would be. I saw that there is a RTTI_ResourceList exported by this library, but this is not a Typescript Type or Interface

Is it possible to do RTTI when the desired RTTI is unknown when calling the decode function?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.