Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple fixes #51

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
- name: Setup Java and Maven
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'

- name: Setup Ballerina
uses: ballerina-platform/[email protected]
with:
version: 2201.7.0
version: 2201.8.1

- name: Create settings.xml
run: echo '<settings>
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
- name: Setup Maven
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'

- name: Setup Ballerina
uses: ballerina-platform/[email protected]
with:
version: 2201.7.0
version: 2201.8.1

- name: Create settings.xml
run: echo '<settings>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Building form Source
### Prerequisites
- [Java 11](https://openjdk.org/projects/jdk/11/) (v11.0.19)
- [Ballerina Swan Lake Update 7](https://ballerina.io/downloads/) (v2201.7.0)
- [Java 17](https://openjdk.org/projects/jdk/17/)
- [Ballerina Swan Lake Update 8](https://ballerina.io/downloads/) (v2201.8.1)
- Add your Github Personal Access Token to the `.m2/settings.xml` to get access the `ballerina-lang` dependencies.
(Make sure to have the id as `ballerina-language-repo`)
```xml
Expand Down
2 changes: 1 addition & 1 deletion ballerina/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<properties>
<version.health.cli>${project.version}</version.health.cli>
<version.ballerina>2201.6.0</version.ballerina>
<version.ballerina>2201.8.1</version.ballerina>
</properties>

<build>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class ToolConstants {
public static final String TOML_EXTENSION = ".toml";
public static final String MD_EXTENSION = ".md";
public static final String CONSTRAINTS_LIB_IMPORT = "ballerina/constraint";
public static final String ELEMENT = "Element";

public enum TokenPosition {
BEGIN,
MIDDLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ private void populateDatatypeContext() {
String typeCode = elementDefinition.getType().get(0).getCode();
if (GeneratorUtils.getInstance().shouldReplacedByBalType(typeCode)) {
element.setDataType(GeneratorUtils.getInstance().resolveDataType(typeCode));
} else if (ToolConstants.ELEMENT.equals(typeCode)) {
element.setDataType(ToolConstants.ELEMENT + CommonUtil.toCamelCase(elementName));
} else {
element.setDataType(typeCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ private Element populateElement(String rootName, String name, ElementDefinition.
Element element = new Element();
element.setName(GeneratorUtils.getInstance().resolveSpecialCharacters(name));
element.setRootElementName(rootName);
element.setDataType(GeneratorUtils.getInstance().resolveDataType(toolConfig, type.getCode()));
if (ToolConstants.ELEMENT.equals(type.getCode())) {
element.setDataType(ToolConstants.ELEMENT + CommonUtil.toCamelCase(name));
} else {
element.setDataType(GeneratorUtils.getInstance().resolveDataType(toolConfig, type.getCode()));
}
//Adding profiles of the resource element type
List<CanonicalType> profiles = type.getProfile();
if (!profiles.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#set( $H = '#' )
Ballerina package containing FHIR resource data models
compliant with $igUrl implementation guide.

#if(!$isBasePackage)
$H FHIR R4 ${igName} package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ public void execute() {
printStream.println("Try bal health --help for more information.");
HealthCmdUtils.exitError(exitWhenFinish);
}
if (dependentPackage != null && !dependentPackage.isEmpty()) {
if (!dependentPackage.matches("^[^/]+/[^/]+$")) {
printStream.println("Format of the dependent package is incorrect.");
printStream.println("Try bal health --help for more information.");
HealthCmdUtils.exitError(exitWhenFinish);
}
}
if (this.engageSubCommand(argList)) {
if (CMD_MODE_TEMPLATE.equals(mode)) {
printStream.println("Ballerina FHIR API templates generation completed successfully. Generated templates can be found at " + targetOutputPath);
Expand Down
54 changes: 28 additions & 26 deletions native/health-cli/src/main/resources/ballerina-health.help
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAME
ballerina-health - Generate a Ballerina package or template for a
given health specification(eg.:FHIR implementation guides) files.
given health specification (eg.:FHIR implementation guides) files.

SYNOPSIS
bal health fhir [-m | --mode] package --package-name <package-name> \
Expand All @@ -9,8 +9,8 @@ SYNOPSIS
<FHIR-specification-directory-path>

DESCRIPTION
Generate a Ballerina package or template with relevant records and types
from given health specification(eg.:FHIR implementation guides) files.
Generate a Ballerina package or template with relevant records and types
from a given health specification (eg.:FHIR implementation guides) files.

The generated Ballerina sources will be written into the provided
output location. Make sure to add the directory path which contains FHIR specification,
Expand All @@ -21,7 +21,7 @@ DESCRIPTION
Implementation Guides can be found in http://fhir.org/guides/registry/)

The ballerina-health tool is compatible with Ballerina
version 2201.7.0 (Swan Lake Update 7) onwards.
version 2201.8.1 (Swan Lake Update 8) onwards.

OPTIONS
-v, --version
Expand All @@ -37,39 +37,40 @@ COMMANDS
OPTIONS
-m, --mode <mode-type>
Mode can be 'package' or 'template'. If the mode is set to 'package',
a Ballerina package will be generated including
all the records and types.
If the mode is set to ‘template’, tool will generate Ballerina templates
for each FHIR resource definition available in
the specified path. This is a MANDATORY input for fhir command.
a Ballerina package will be generated including all the records
and types. If the mode is set to ‘template’, tool will generate
Ballerina templates for each FHIR resource definition available
in the specified path. This is a MANDATORY input for fhir command.
--package-name <name-of-package>
Only applicable in ‘package’ mode. Name of the Ballerina package
to be generated. This is a MANDATORY input in ‘package’ mode.
Refer https://ballerina.io/learn/package-references/#the-name-field
--dependent-package <qualified-ballerina-package-name>
Only applicable in ‘template’ mode. Fully qualified name of the
published Ballerina package containing IG resources [eg: <org>/<package>].
This option can be used to generate templates specifically for the
resources in the given IG. The package name part of this value
will be added as a prefix to the template name.
This is a MANDATORY input in ‘template’ mode.
-o, --output <output>
Location of the generated Ballerina artifacts. If this
path is not specified, the output will be written to
the same directory from which the command is run.
--package-name <name-of-package>
Only applicable in ‘package’ mode. Name of the Ballerina package to be generated.
Refer https://ballerina.io/learn/package-references/#the-name-field
--org-name <org-name-of-the-package>
Organization name of the Ballerina package/template to be generated.
Refer https://ballerina.io/learn/package-references/#the-org-field
--package-version <version-of-the-package>
Version of the Ballerina package/template to be generated.
Refer https://semver.org/
--included-profile <profiles-to-included>
Only applicable in ‘template’ mode. If only a specific profile/s needs to be generated as
templates, specify the profile URL as the value of this parameter.
This argument can be used more than once.
Only applicable in ‘template’ mode. If only a specific profile/s
needs to be generated as templates, specify the profile URL
as the value of this parameter. This argument can be used more than once.
--excluded-profile <profiles-to-excluded>
Only applicable in ‘template’ mode. If only a specific profile/s needs to be skipped when
generating templates, specify the profile URL
as the value of this parameter.
This argument can be used more than once.
--dependent-package <qualified-ballerina-package-name>
Only applicable in ‘template’ mode. Fully qualified name of the Ballerina package containing IG
resources [eg: <org>/<package>]. This option can be used to generate templates
specifically for the resources in the given IG.
The package name part of this value will be added
as a prefix to the template name.
Only applicable in ‘template’ mode. If only a specific profile/s
needs to be skipped when generating templates, specify the
profile URL as the value of this parameter. This argument
can be used more than once.

EXAMPLES
Generate a Ballerina package for the FHIR artifacts of USCore
Expand All @@ -85,6 +86,7 @@ COMMANDS

Generate Ballerina templates for all the FHIR resource profiles
of USCore implementation guide.
$ bal health fhir -m template --dependent-package ballerinax/health.fhir.r4.uscore501 \
$ bal health fhir -m template \
--dependent-package ballerinax/health.fhir.r4.uscore501 \
./path_to_uscore_definitions

4 changes: 2 additions & 2 deletions native/health-cli/src/main/resources/tool-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"org": "healthcare",
"name": "healthcare.fhir",
"version": "1.0.0",
"ballerinaDistribution": "2201.7.0",
"ballerinaDistribution": "2201.8.1",
"authors": [
"Ballerina"
],
Expand All @@ -29,7 +29,7 @@
"org": "healthcare",
"namePrefix": "health.fhir.r4.international401",
"version": "1.0.0",
"distribution": "2201.7.0",
"distribution": "2201.8.1",
"authors": [
"Ballerina"
],
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.healthcare.tool.framework>1.0.0</version.healthcare.tool.framework>
<version.ballerina.cli>2201.6.0</version.ballerina.cli>
<version.ballerina.cli>2201.8.1</version.ballerina.cli>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
Expand Down
Loading