use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.
the class SpreadSheetReloader method getExample.
private ListResourceEntryComponent getExample(List<ListResourceEntryComponent> oldEx, String c) {
for (ListResourceEntryComponent li : oldEx) {
if (c.equals(li.getItem().getDisplay())) {
return li;
}
}
ListResourceEntryComponent res = new ListResourceEntryComponent();
res.getItem().setDisplay(c);
return res;
}
use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.
the class SpreadSheetReloader method processExamples.
private void processExamples(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
ListResource list = (ListResource) parseXml(fnOperations());
XSSFSheet src = getSheet(excel, SN_SEARCH);
List<ListResourceEntryComponent> oldEx = list.getEntry();
list.setEntry(new ArrayList<>());
XSSFRow cols = src.getRow(0);
for (int i = 1; i < src.getLastRowNum(); i++) {
XSSFRow row = src.getRow(i);
if (row != null && hasValue(row, cols, CN_NAME)) {
String c = getValue(row, cols, CN_NAME);
ListResourceEntryComponent li = getExample(oldEx, c);
list.addEntry(li);
readExample(row, cols, li);
}
}
}
use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.
the class SpreadSheetCreator method addPacks.
private void addPacks(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
ListResource list = (ListResource) parseXml(fnPacks());
list.setText(null);
for (ListResourceEntryComponent li : list.getEntry()) {
String ref = li.getItem().getReference();
ref = ref.substring(ref.indexOf("/") + 1);
String id = ref.contains("-") ? ref.substring(ref.indexOf("-") + 1) : ref;
XSSFSheet sheet = excel.createSheet("Pack " + id);
addPackColumns(sheet);
addPack(sheet, ref);
}
}
use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.
the class SpreadSheetCreator method addOperations.
private void addOperations(XSSFWorkbook excel, XSSFSheet bindings) throws FHIRFormatError, FileNotFoundException, IOException {
ListResource list = (ListResource) parseXml(fnOperations());
list.setText(null);
XSSFSheet sheet = excel.createSheet(SN_OPERATIONS);
addOperationColumns(sheet);
int rowCount = 1;
for (ListResourceEntryComponent li : list.getEntry()) {
String ref = li.getItem().getReference();
ref = ref.substring(ref.indexOf("/") + 1);
OperationDefinition opd = (OperationDefinition) parseXml(fnOpDef(ref));
opd.setText(null);
rowCount = addOperation(sheet, bindings, opd, rowCount);
}
}
use of org.hl7.fhir.r4b.model.ListResource.ListResourceEntryComponent in project kindling by HL7.
the class Regenerator method generateExamples.
private void generateExamples(String root, ResourceDefn r) throws FileNotFoundException, IOException {
ListResource list = new ListResource();
list.setId(r.getName() + "-examples");
list.setStatus(ListStatus.CURRENT);
list.setMode(ListMode.WORKING);
for (Example ex : r.getExamples()) {
ListResourceEntryComponent li = list.addEntry();
li.getItem().setReference(ex.getResourceName() + "/" + ex.getId());
li.getItem().setDisplay(ex.getName());
if (ex.getDescription() != null) {
li.addExtension(BuildExtensions.EXT_DESCRIPTION, new StringType(ex.getDescription()));
}
if (ex.getTitle() != null) {
li.addExtension(BuildExtensions.EXT_TITLE, new StringType(ex.getTitle()));
}
switch(ex.getType()) {
case Container:
li.getFlag().addCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "container", null);
break;
case CsvFile:
li.getFlag().addCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "csv", null);
break;
case Tool:
li.getFlag().addCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "tool", null);
break;
default:
break;
}
if (!ex.isRegistered()) {
li.addExtension(BuildExtensions.EXT_NOT_REGISTERED, new BooleanType(!ex.isRegistered()));
}
if (ex.getIg() != null) {
li.addExtension(BuildExtensions.EXT_IG, new CodeType(ex.getIg()));
}
if (ex.getExampleFor() != null) {
li.addExtension(BuildExtensions.EXT_EXAMPLE_FOR, new StringType(ex.getExampleFor()));
}
}
File fn = new File(Utilities.path(root, list.fhirType().toLowerCase() + "-" + list.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), list);
fn.setLastModified(r.getTimestamp());
}
Aggregations