Stream: javascript
Topic: type definitions for DSTU3
Andreas Keil (Jan 16 2017 at 16:17):
Hi, is anyone already working on typescript type definitions for DSTU3 ?
Patrick Werner (Jan 16 2017 at 16:18):
This would be awesome to have.
Emre Avsar (Mar 02 2017 at 09:33):
any update on this?
Emre Avsar (Mar 02 2017 at 09:39):
@Patrick Werner do you know whether @Andreas Keil already started on this, or just was interested in ts?
Patrick Werner (Mar 02 2017 at 09:46):
he already started the TS typings file and is using fhir actively with angular2 / ionic2
Emre Avsar (Mar 02 2017 at 09:48):
alright. thx. let's see what he got already. in the meanwhile, this could be also a option: https://github.com/bobby-brennan/fhir-swagger/issues/2
1. generating a swagger definition for the fhir resources via fhir-swagger
2. use swagger to generate TS
*but* for dstu3 it does not work atm
Andreas Keil (Mar 02 2017 at 10:19):
Hi @Emre Avsar you can find the stu3 typings here: https://github.com/t4deon/FHIR-STU3-TS-Typings/blob/master/typings.d.ts I haven't had the time yet to write some unit tests and documentation but as soon as this is done I will submit a pull request to DefinitelyTyped so you can use the typings via npm.
Emre Avsar (Mar 02 2017 at 10:20):
yay. commited 9 minutes ago :-D
Emre Avsar (Mar 02 2017 at 10:20):
have you generated the stuff here?
Andreas Keil (Mar 02 2017 at 10:23):
yes. They are generated from the StructureDefinitions. I'm not sure if all interfaces are correct so far as I'm using just a few currently. Tell me if you find any bugs there so I can correct them.
Emre Avsar (Mar 02 2017 at 10:24):
cool. and have you also thought about custom extenions?
Andreas Keil (Mar 02 2017 at 10:29):
There are also interfaces for extensions but I haven't used them so far. You are very welcome to contribute :)
Emre Avsar (Mar 02 2017 at 10:33):
def. when i have some examples. this means that i have two places where i have to adjust my 'models' -> FHIR server and my angular app using the fhir server's api
Emre Avsar (Mar 02 2017 at 10:52):
btw @Andreas Keil regarding your repo. i tried to get it as a node module by using it via https://github.com/shama/napa, this works fine. but you didn't do any exports in the typings.d.ts file. how can I use the typings?
Emre Avsar (Mar 02 2017 at 10:58):
ok got it, poor visual studio code showed a wrong warning.
Emre Avsar (Mar 02 2017 at 13:01):
hey @Andreas Keil i'm still struggling to use your typing.d.ts file in my angular2 app. how can I import it right away?
Andreas Keil (Mar 02 2017 at 13:22):
You need to add the .d.ts file to your project and then install it: typings install file:./path/to/typings.d.ts --save --global
Emre Avsar (Mar 02 2017 at 14:28):
no imports needed then?
Emre Avsar (Mar 02 2017 at 15:00):
ok i got it in the meanwhile.
Emre Avsar (Mar 02 2017 at 15:00):
but you don't combine it with the fhir.js lib, do you?
Emre Avsar (Mar 02 2017 at 15:24):
the problem i'm facing at the moment is, when I create a fhir resource, lets say Observation like this:
const observation: fhir.Observation = { status: 'final', code: { id: '1234', text: 'codeable concept test', coding: null } };
I don't have the mandatory fields like resourceType: 'Observation',
Emre Avsar (Mar 02 2017 at 16:04):
i tried to make this resourceType thing automatically filled out, by trying to get the interfacename which is also the resourceType and add it to the instance of the interface. but unfortunatelly the interface is not enough, i need a class. do you have any idea whether it is possible to get the typings as classes instead of interfaces?
Abbie Watson (Mar 02 2017 at 17:49):
When you start discussing how to specify mandatory fields and default values, you're no longer talking about type definitions, but about schema definitions. You'll need a library like node-simple-schema
.
https://github.com/aldeed/node-simple-schema
Abbie Watson (Mar 02 2017 at 17:55):
We've implemented schema definitions for ~40 of the DSTU2 resources. They take longer to implement than type definitions, so slower going.
https://github.com/clinical-meteor?utf8=%E2%9C%93&q=hl7-resource&type=&language=
They're currently implemented as Atmosphere packages and require a Meteor data infrastructure, but that supports Angular2 and TypeScript. If you want to pull them out and use them in an express or webpack app, just copy the Schema definition and include node-simple-schema
and you should be able to selectively use them on the server or client as needed, with the .clean()
, .validate()
and other schema validation functions.
Pull requests to bring them up from DTSU2 to DTSU3 happily accepted.
Emre Avsar (Mar 03 2017 at 06:42):
hi @Abigail Watson i'm not directly interested into schema validation, but the resourceType
look very clear for me. at least this field I'd like to have automatically filled out.
Emre Avsar (Mar 03 2017 at 06:45):
are these schemas generated or do you have to adjust it to changes?
Emre Avsar (Mar 03 2017 at 08:33):
btw I just pushed a forked version of bunyaminsg's ng-fhir-example for angular2 which uses the typings of @Andreas Keil . you can find the example project here. https://github.com/emreavsar/ng-fhir-example
nicola (RIO/SS) (Mar 03 2017 at 08:47):
We have good json schemata for FHIR if you are interested we could share it with community
Emre Avsar (Mar 03 2017 at 08:48):
@nicola (RIO) aren't there there already json schema available from the official fhir site? for stu3 https://hl7.org/fhir/2017Jan/downloads.html
Emre Avsar (Mar 03 2017 at 09:12):
but of course the more we have in the community, the more we profit anyway.
nicola (RIO/SS) (Mar 03 2017 at 10:53):
Yes, but it does not validate a lot of things :)
nicola (RIO/SS) (Mar 03 2017 at 10:56):
Current JSON representation in FHIR is logically impcompatible with JSON schema - we fixed it by extending JSON schema, but also i'm working on new JSON format proposal for FHIR.
Bünyamin Sarıgül (Mar 03 2017 at 12:24):
@Emre Avsar I would be happy to accept if you can send a pull request to ng-fhir-example
repository.
Abbie Watson (Mar 03 2017 at 20:11):
With node-simple-schema
you would do something like ObservationSchema.validate(fhir.Observation)
, and it would fill in the resourceType
on your fhir.Observation
object. And any other default values, missing fields, etc. We've got it all configured with Meteor so that's triggered on Collection.insert(), and can be called isomorphically from the server, client, or database.
Grahame Grieve (Mar 06 2017 at 08:36):
what is logically incompatible?
Abbie Watson (Mar 06 2017 at 09:13):
If I understand nicola correctly, there is a library called JSON Schema (it happens to be the top match when you search npmjs.com for 'json schema'); and the current FHIR resources don't match its conception of how a JSON object should be structured.
http://json-schema.org/
Abbie Watson (Mar 06 2017 at 09:13):
And his team extended that library, and would like to recommend some changes to the FHIR schemas, to better align with that library.
Grahame Grieve (Mar 06 2017 at 09:30):
well, I'll wait to hear. I did agree to do a new set of json schemas for swagger restrictions, but I haven't got to that yet
Emre Avsar (Mar 06 2017 at 11:41):
@nicola (RIO) so where can I find the code?
nicola (RIO/SS) (Mar 06 2017 at 12:31):
@Emre Avsar do you mean our extension to JSON schema to support FHIR?
nicola (RIO/SS) (Mar 06 2017 at 12:38):
@Abigail Watson JSON schema and swagger is kinda standards, like FHIR, but for any REST API. It has many implementations in different languages, good adoption and a lot of tooling on top, also supported by many API management services etc.
Emre Avsar (Mar 06 2017 at 13:20):
@nicola (RIO) i think so. atm i'm only working wiht @Andreas Keil 's typings.d.ts file
nicola (RIO/SS) (Mar 06 2017 at 14:46):
Here is the tests with our extensions - https://github.com/niquola/json-schema.clj/blob/master/test/json_schema/custom_extensions_test.clj. We introduced 3 new keywords - descriminator (from swagger), exclusiveProperties and oneOfRequired (to support polymorphic elements and primitive extensions).
Abbie Watson (Mar 06 2017 at 16:19):
It's an Informational standard, is all. I could point out that Meteor is the most popular web framework on GitHub, having surpassed Rails, Express, and Django, which makes it something of a standard too with good adoption, tooling, etc. And we managed to mostly solve those problems you mentioned with the current existing FHIR schemas. What you're suggesting potentially represents a lot of unnecessary work for the Meteor community.
Abbie Watson (Mar 06 2017 at 16:20):
I did log an issue with the simple-schema maintainers to get their take on IETF Json Schema support though. They may find it easy to implement; or have alternate standards that they recommend, or other thoughts. Waiting to find out what they say.
Emre Avsar (Mar 08 2017 at 06:48):
hey @Andreas Keil i'm right now at the point where I have to extend a fhir resource, like i already did on the fhir server. (i'm using the typings client-side in my ng2 app). so I could of course do a local extension manually, but then i have to sync always, when the fhir server has changed the extensions. so any suggestions for this?
may i ask you also how you generated the typings file from the structure definitions?
anyone else having something like that at the moment? (again fhir swagger would solve this problem..)
Andreas Keil (Mar 09 2017 at 10:54):
I haven't used extensions yet with the typings but you can provide extensions to a resource as follows:
let pat : fhir.Patient = { extension: [ { url: "some url", valueCode: "some code" } ] };
I developed a little program to generate the typings. I will publish it soon.
Emre Avsar (Mar 10 2017 at 15:01):
can you maybe share this tool, so that I can also use it for my extensions to generate the typings based on my structure definitions? that would be cool @Andreas Keil !
Bünyamin Sarıgül (Mar 15 2017 at 12:01):
@Andreas Keil this would be very helpful in our work as well. We would appreciate if you can share it.
Brian Postlethwaite (Aug 25 2017 at 04:22):
How are folks going with typescript templates? I'd love to do the ground work for generating the entire model if someone has a sample for one or 2 I can follor for code generation (total TS/Angular noob here)
Andrew Patterson (Aug 25 2017 at 07:07):
Yes please.. typescript templates would be awesome especially in an Angular 2+ world (spoken as a possible downstream user, not as anyone who can actually help create them though)
Andrew Patterson (Aug 25 2017 at 07:08):
https://github.com/t4deon/FHIR-STU3-TS-Typings
Brian Postlethwaite (Aug 27 2017 at 08:59):
Thanks for the link Andrew
Emre Avsar (Aug 28 2017 at 12:36):
@Brian Postlethwaite be aware of these typings, since they were generated 6 months ago, and some fhir resources has changed in the meanwhile.
Emre Avsar (Aug 28 2017 at 12:37):
but maybe @Andreas Keil can update the repo by regenerating the dstu typings?
Emre Avsar (Aug 28 2017 at 12:37):
i'd really appreciate that!
Andreas Keil (Aug 28 2017 at 19:14):
I just updated them :)
Emre Avsar (Aug 31 2017 at 11:40):
thanks @Andreas Keil , but can you give it another try? see my comment: https://github.com/t4deon/FHIR-STU3-TS-Typings/issues/1#issuecomment-325453381
Andreas Keil (Aug 31 2017 at 11:50):
I didn't see this, sorry. DomainResource is in now!
Emre Avsar (Aug 31 2017 at 11:52):
no worries. i will test it later, and hopefully i don't have to ping you again with some other missing stuff :-)
Last updated: Apr 12 2022 at 19:14 UTC