@ian.mcnicoll motivated me to start working on a TypeScript generator.
Here are the TypeScript classes for RM 1.0.3 (rename the extension .md
to .zip
):
openehr_typescript_models_rm103.md (140.2 KB)
AM classes are also generated. I still need to port JSON serialization code (all generated) to TypeScript. This will add reading/writing JSON data instances and archetypes/templates.
Would something like this be useful for frontend implementation?
This is the first WIP version. I’ll update the attached file with new code.
Preview of the OperationalTemplate
:
/**
* Root object of an operational template. An operational template is derived from a TEMPLATE definition and the ARCHETYPEs and/or TEMPLATE_OVERLAYs mentioned by that template by a process of flattening, and potentially removal of unneeded languages and terminologies.
*
* An operational template is used for generating and validating RM-canonical instance data, and also as a source artefact for generating other downstream technical artefacts, including XML schemas, APIs and UI form definitions.
* BMM name: OPERATIONAL_TEMPLATE
* BMM ancestors: AUTHORED_ARCHETYPE
* isAbstract: false | isPrimitiveType: false | isOverride: false
*/
export class OperationalTemplate extends AuthoredArchetype {
/**
* Compendium of flattened terminologies of archetypes externally referenced from this archetype, keyed by archetype identifier. This will almost always be present in a template.
* BMM name: component_terminologies | BMM type: Hash<String,ARCHETYPE_TERMINOLOGY>
* isMandatory: false | isComputed: false | isImRuntime: false | isImInfrastructure: false | existence: 0..1
*/
componentTerminologies?: Map<string, ArchetypeTerminology>;
/**
* Directory of term definitions as a two-level table. The outer hash keys are term codes, e.g. "at4", and the inner hash key are term attribute names, e.g. "text", "description" etc.
* BMM name: terminology_extracts | BMM type: Hash<String,ARCHETYPE_TERMINOLOGY>
* isMandatory: false | isComputed: false | isImRuntime: false | isImInfrastructure: false | existence: 0..1
*/
terminologyExtracts?: Map<string, ArchetypeTerminology>;
constructor(rmRelease: string, isGenerated: boolean, originalLanguage: TerminologyCode, archetypeId: ArchetypeHrid, isDifferential: boolean, terminology: ArchetypeTerminology, definition: CComplexObject) {
super(rmRelease, isGenerated, originalLanguage, archetypeId, isDifferential, terminology, definition);
}
equals(other: any): boolean {
if (this === other) return true;
if (!this || !other || (typeof this !== "object" && typeof other !== "object")) return this === other;
let otherAsOperationalTemplate: OperationalTemplate = other as OperationalTemplate;
return this.adlVersion === otherAsOperationalTemplate.adlVersion &&
this.rmRelease === otherAsOperationalTemplate.rmRelease &&
this.isGenerated === otherAsOperationalTemplate.isGenerated &&
this.buildUid?.equals(otherAsOperationalTemplate.buildUid) &&