Skip to content

Commit

Permalink
Merge pull request #1400 from hapifhir/2023-08-gg-profile-code-genera…
Browse files Browse the repository at this point in the history
…tion

First cut at profile code generation
  • Loading branch information
grahamegrieve authored Aug 20, 2023
2 parents 46bae75 + 6d3e555 commit 55f4f42
Show file tree
Hide file tree
Showing 8 changed files with 1,148 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* *** NOTE: This sub-system is still under development ***
*
* This subsystem takes a profile and creates a view of the profile that stitches
* all the parts together, and presents it as a seemless tree. There's two views:
* all the parts together, and presents it as a seamless tree. There's two views:
*
* - definition: A logical view of the contents of the profile
* - instance: a logical view of a resource that conforms to the profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,26 @@ public boolean isBaseList() {
return !"1".equals(definition.getBase().getMax());
}


public StructureDefinition getProfile() {
return profile;
}


public boolean isKeyElement() {
boolean selfKey = definition.getMustSupport() || definition.getMustHaveValue() || min() > 0 || definition.hasCondition();
if (isProfiled() && !selfKey) {
if (types() != null && types().size() > 0) {
for (PEDefinition child : children()) {
if (child.isKeyElement()) {
return true;
}
}
}
}
return selfKey;
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hl7.fhir.r5.model.DataType;
import org.hl7.fhir.r5.model.DateTimeType;
import org.hl7.fhir.r5.model.HumanName;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.Address;
import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.Quantity;
Expand Down Expand Up @@ -240,4 +241,14 @@ public String getPath() {
public Base getBase() {
return data;
}

public boolean hasChild(String name) {
PEDefinition child = byName(definition.children(), name);
List<Base> instances = builder.exec(resource, data, child.fhirpath());
return !instances.isEmpty();
}

public IWorkerContext getContext() {
return builder.getContext();
}
}
Loading

0 comments on commit 55f4f42

Please sign in to comment.