Search in sources :

Example 41 with ListResource

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);
    }
}
Also used : ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) CSFile(org.hl7.fhir.utilities.CSFile) ListResource(org.hl7.fhir.r5.model.ListResource) ExampleType(org.hl7.fhir.definitions.model.Example.ExampleType)

Example 42 with ListResource

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));
    }
}
Also used : ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition)

Example 43 with ListResource

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);
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) ListResourceEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent) ListResource(org.hl7.fhir.r5.model.ListResource)

Example 44 with ListResource

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);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 45 with ListResource

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);
}
Also used : Element(org.w3c.dom.Element) AllergyIntoleranceReactionComponent(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceReactionComponent)

Aggregations

ListResource (org.hl7.fhir.r5.model.ListResource)12 Element (org.w3c.dom.Element)12 ListResourceEntryComponent (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent)11 ListResource (org.hl7.fhir.dstu3.model.ListResource)10 Reference (org.hl7.fhir.dstu3.model.Reference)10 ListEntryComponent (org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)9 ArrayList (java.util.ArrayList)8 ListResource (org.hl7.fhir.r4.model.ListResource)8 Reference (org.hl7.fhir.r4.model.Reference)6 HashMap (java.util.HashMap)5 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)5 SectionComponent (org.hl7.fhir.dstu3.model.Composition.SectionComponent)4 Patient (org.hl7.fhir.r4.model.Patient)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 List (java.util.List)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)2