use of org.hl7.fhir.dstu3.model.ListResource in project kindling by HL7.
the class ResourceParser method parseExamples.
private void parseExamples(ResourceDefn r, String n, String t) throws FHIRException, Exception {
ListResource list = (ListResource) parseXml("list-" + t + "-examples.xml");
for (ListResourceEntryComponent le : list.getEntry()) {
boolean reg = le.hasExtension(BuildExtensions.EXT_NOT_REGISTERED) ? !BuildExtensions.readBoolExtension(le, BuildExtensions.EXT_NOT_REGISTERED) : true;
ExampleType type = ExampleType.XmlFile;
if (le.getFlag().hasCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "container")) {
type = ExampleType.Container;
} else if (le.getFlag().hasCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "csv")) {
type = ExampleType.CsvFile;
} else if (le.getFlag().hasCoding(BuildExtensions.EXT_EXAMPLE_TYPE, "tool")) {
type = ExampleType.Tool;
}
String id = le.getItem().getReference().substring(le.getItem().getReference().lastIndexOf("/") + 1);
String ig = le.getExtensionString(BuildExtensions.EXT_IG);
CSFile path = Utilities.noString(ig) ? new CSFile(Utilities.path(folder, le.getExtensionString(BuildExtensions.EXT_TITLE) + ".xml")) : new CSFile(Utilities.path(rootFolder(), "guides", ig, le.getExtensionString(BuildExtensions.EXT_TITLE) + "." + ext(type)));
Example ex = new Example(le.getItem().getDisplay(), id, le.getExtensionString(BuildExtensions.EXT_DESCRIPTION), path, reg, type, false);
r.getExamples().add(ex);
}
}
use of org.hl7.fhir.dstu3.model.ListResource in project kindling by HL7.
the class ResourceParser method parseOperations.
private void parseOperations(ResourceDefn r, String n, String t) throws FHIRException, Exception {
ListResource list = (ListResource) parseXml("list-" + t + "-operations.xml");
for (ListResourceEntryComponent le : list.getEntry()) {
String id = le.getItem().getReference().substring(le.getItem().getReference().indexOf("/") + 1);
OperationDefinition opd = (OperationDefinition) parseXml("operationdefinition-" + id + ".xml");
opd.setVersion(version);
r.getOperations().add(convertOperation(opd));
}
}
use of org.hl7.fhir.dstu3.model.ListResource in project kindling by HL7.
the class SpreadSheetCreator method addExamples.
private void addExamples(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
ListResource list = (ListResource) parseXml(fnExamples());
list.setText(null);
XSSFSheet sheet = excel.createSheet(SN_EXAMPLES);
addExampleColumns(sheet);
int rowCount = 0;
for (ListResourceEntryComponent li : list.getEntry()) {
rowCount++;
addExample(sheet, li, rowCount);
}
}
use of org.hl7.fhir.dstu3.model.ListResource in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeListResource.
protected void composeListResource(Complex parent, String parentType, String name, ListResource element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "List", name, element, index);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "List", "identifier", element.getIdentifier().get(i), i);
if (element.hasStatusElement())
composeEnum(t, "List", "status", element.getStatusElement(), -1);
if (element.hasModeElement())
composeEnum(t, "List", "mode", element.getModeElement(), -1);
if (element.hasTitleElement())
composeString(t, "List", "title", element.getTitleElement(), -1);
if (element.hasCode())
composeCodeableConcept(t, "List", "code", element.getCode(), -1);
if (element.hasSubject())
composeReference(t, "List", "subject", element.getSubject(), -1);
if (element.hasEncounter())
composeReference(t, "List", "encounter", element.getEncounter(), -1);
if (element.hasDateElement())
composeDateTime(t, "List", "date", element.getDateElement(), -1);
if (element.hasSource())
composeReference(t, "List", "source", element.getSource(), -1);
if (element.hasOrderedBy())
composeCodeableConcept(t, "List", "orderedBy", element.getOrderedBy(), -1);
for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "List", "note", element.getNote().get(i), i);
for (int i = 0; i < element.getEntry().size(); i++) composeListResourceListEntryComponent(t, "List", "entry", element.getEntry().get(i), i);
if (element.hasEmptyReason())
composeCodeableConcept(t, "List", "emptyReason", element.getEmptyReason(), -1);
}
use of org.hl7.fhir.dstu3.model.ListResource in project org.hl7.fhir.core by hapifhir.
the class ArgonautConverter method processAllergiesSection.
private void processAllergiesSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
scanSection("Allergies", section);
ListResource list = new ListResource();
list.setId(context.getBaseId() + "-list-allergies");
list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafallergylist");
list.setSubject(context.getSubjectRef());
list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
list.setTitle(cda.getChild(section, "title").getTextContent());
list.setStatus(ListStatus.CURRENT);
list.setDateElement(context.getNow());
list.setSource(context.getAuthorRef());
list.setMode(ListMode.SNAPSHOT);
buildNarrative(list, cda.getChild(section, "text"));
int i = 0;
for (Element c : cda.getChildren(section, "entry")) {
// allergy problem act
Element apa = cda.getChild(c, "act");
AllergyIntolerance ai = new AllergyIntolerance();
ai.setId(context.getBaseId() + "-allergy-" + i);
ai.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/allergyintolerance-daf-dafallergyintolerance");
i++;
ai.setPatient(context.getSubjectRef());
ai.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(apa, "effectiveTime"), "low")));
boolean found = false;
for (Element e : cda.getChildren(apa, "id")) {
Identifier id = convert.makeIdentifierFromII(e);
ai.getIdentifier().add(id);
}
if (!found) {
list.addEntry().setItem(new Reference().setReference("AllergyIntolerance/" + ai.getId()));
// allergy observation
Element ao = cda.getChild(cda.getChild(apa, "entryRelationship"), "observation");
if (!cda.getChild(ao, "value").getAttribute("code").equals("419511003"))
throw new Error("unexpected code");
// nothing....
// no allergy status observation
List<Element> reactions = cda.getChildren(ao, "entryRelationship");
Element pe = cda.getChild(cda.getChild(cda.getChild(ao, "participant"), "participantRole"), "playingEntity");
Element pec = cda.getChild(pe, "code");
if (pec == null || !Utilities.noString(pec.getAttribute("nullFlavor"))) {
String n = cda.getChild(pe, "name").getTextContent();
// if (n.contains("No Known Drug Allergies") && reactions.isEmpty())
// ai.setSubstance(new CodeableConcept().setText(n)); // todo: what do with this?
// else
ai.setCode(new CodeableConcept().setText(n));
} else
ai.setCode(inspectCode(convert.makeCodeableConceptFromCD(pec), null));
recordAllergyCode(ai.getCode());
if (!reactions.isEmpty()) {
AllergyIntoleranceReactionComponent aie = ai.addReaction();
for (Element er : reactions) {
Element ro = cda.getChild(er, "observation");
aie.addManifestation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(ro, "value")), null));
}
}
saveResource(ai);
}
}
saveResource(list);
}
Aggregations