Skip to content

Commit

Permalink
Fix issues with extensions fields in generated resource records
Browse files Browse the repository at this point in the history
  • Loading branch information
sameeragunarathne committed Dec 6, 2024
1 parent cd13e9d commit ec6a9e4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ private void populateDatatypeContext() {
if (elementDefinition.getPath().contains(".")) {
String elementName = elementDefinition.getPath().substring(
elementDefinition.getPath().lastIndexOf(".") + 1);
if ("id".equals(elementName) || "extension".equals(elementName)) {
if ("id".equals(elementName) || "extension".equals(elementName)
|| elementDefinition.getPath().contains(".extension.")) {
//skipping for generating datatype extensions
continue;
}
Element element = new Element();
Expand Down Expand Up @@ -135,8 +137,7 @@ private void populateExtendedElementsMap(Element element, DatatypeTemplateContex
if (elementDataType.equals("code") && element.hasChildElements()) {
extendedElement = GeneratorUtils.getInstance().populateExtendedElement(element, BallerinaDataType.Enum, elementDataType,
context.getName());
context.getExtendedElements().putIfAbsent(extendedElement.getTypeName(), extendedElement);
element.setName(extendedElement.getTypeName());
context.getExtendedElements().putIfAbsent(element.getName(), extendedElement);
element.setExtended(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ public int compare(ElementDefinition e1, ElementDefinition e2) {
elementName = tempElement + CommonUtil.toCamelCase(type.getCode());

Element childElement = populateElement(rootElementName, elementName, type, isSlice, elementDefinition);
if (ToolConstants.DATA_TYPE_EXTENSION.equals(childElement.getDataType()) &&
!elementName.equals("extension") && !elementName.equals("modifierExtension")) {
continue;
}
if (rootElement.getChildElements() != null) {
if (!rootElement.getChildElements().containsKey(elementName)) {
rootElement.getChildElements().put(elementName, childElement);
Expand Down Expand Up @@ -480,6 +484,9 @@ private void putExtendedElementIfAbsent(Element element, ExtendedElement extende

private void populateResourceSliceElementsMap(Element element) {
LOG.debug("Started: Resource Slice Element Map population");
if (ToolConstants.DATA_TYPE_EXTENSION.equals(element.getDataType()) && element.isSlice()) {
return;
}
if (element.hasChildElements()) {
for (Map.Entry<String, Element> childEntry : element.getChildElements().entrySet()) {
populateResourceSliceElementsMap(childEntry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,49 @@ public class GeneratorUtils {
put("'type", "AddressType");
put("use", "AddressUse");
}});
put("ContactPoint", new HashMap<>() {{
put("system", "ContactPointSystem");
put("use", "ContactPointUse");
}});
put("Contributor", new HashMap<>() {{
put("type", "ContributorType");
}});
put("ElementBinding", new HashMap<>() {{
put("strength", "StrengthCode");
}});
put("ElementDiscriminator", new HashMap<>() {{
put("type", "ElementDiscriminatorType");
}});
put("ElementRepeat", new HashMap<>() {{
put("durationUnit", "Timecode");
put("periodUnit", "Timecode");
put("dayOfWeek", "Daycode");
}});
put("ElementSlicing", new HashMap<>() {{
put("rules", "ElementSlicingRules");
}});
put("ElementSort", new HashMap<>() {{
put("direction", "DirectionCode");
}});
put("ElementType", new HashMap<>() {{
put("aggregation", "TypeAggregation");
put("versioning", "TypeVersioning");
}});
put("HumanName", new HashMap<>() {{
put("use", "HumanNameUse");
}});
put("Identifier", new HashMap<>() {{
put("use", "IdentifierUse");
}});
put("Narrative", new HashMap<>() {{
put("status", "StatusCode");
}});
put("ParameterDefinition", new HashMap<>() {{
put("use", "ParameterDefinitionUse");
}});
put("Quantity", new HashMap<>() {{
put("comparator", "QuantityComparatorCode");
}});
}};

private static final GeneratorUtils instance = new GeneratorUtils();
Expand Down

0 comments on commit ec6a9e4

Please sign in to comment.