Search in sources :

Example 1 with Group

use of org.hl7.fhir.r4.model.Group in project tdi-studio-se by Talend.

the class HL7MessageTreeLabelProvider method getColumnText.

public String getColumnText(Object element, int columnIndex) {
    if (element instanceof Type) {
        Type datatype = (Type) element;
        return datatype.getName();
    }
    if (element instanceof IModel) {
        if (element instanceof TypeModel) {
            TypeModel tm = (TypeModel) element;
            allPrimitives.addAll(Arrays.asList(tm.getPrimitives()));
        }
        return ((IModel) element).getDisplayName();
    }
    // }
    if (element instanceof Group) {
        Group group = (Group) element;
        String groupName = group.getName();
        groupName = groupName.substring(groupName.lastIndexOf('.') + 1, groupName.length());
        return groupName;
    }
    if (element instanceof Structure) {
        Structure structure = (Structure) element;
        return structure.getName();
    }
    return null;
}
Also used : Group(ca.uhn.hl7v2.model.Group) Type(ca.uhn.hl7v2.model.Type) IModel(org.talend.designer.hl7.model.IModel) TypeModel(org.talend.designer.hl7.model.TypeModel) Structure(ca.uhn.hl7v2.model.Structure)

Example 2 with Group

use of org.hl7.fhir.r4.model.Group in project tdi-studio-se by Talend.

the class HL7PublicUtil method getFirstLevelChild.

public List getFirstLevelChild(Object parentElement) {
    List values = new ArrayList();
    if (parentElement instanceof Message) {
        Message messParent = (Message) parentElement;
        String[] childNames = messParent.getNames();
        if (!values.isEmpty()) {
            values.clear();
        }
        for (int i = 0; i < childNames.length; i++) {
            try {
                Structure[] childReps = messParent.getAll(childNames[i]);
                for (int j = 0; j < childReps.length; j++) {
                    if (childReps[j] instanceof Message) {
                        values.add(childReps[j]);
                    }
                    if (childReps[j] instanceof Group) {
                        values.add(childReps[j]);
                        allSegmentFromGroup.clear();
                        getAllSegmentsFromGroup((Group) childReps[j]);
                    }
                    if (childReps[j] instanceof Segment) {
                        SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
                        if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
                            values.add(sModel);
                            if (!allSegmentsForMessage.contains(sModel)) {
                                allSegmentsForMessage.add(sModel);
                            }
                        }
                    }
                }
            } catch (HL7Exception e) {
                e.printStackTrace();
            }
        }
    }
    return values;
}
Also used : Group(ca.uhn.hl7v2.model.Group) Message(ca.uhn.hl7v2.model.Message) ArrayList(java.util.ArrayList) HL7Exception(ca.uhn.hl7v2.HL7Exception) ArrayList(java.util.ArrayList) List(java.util.List) Structure(ca.uhn.hl7v2.model.Structure) SegmentModel(org.talend.designer.hl7.model.SegmentModel) Segment(ca.uhn.hl7v2.model.Segment)

Example 3 with Group

use of org.hl7.fhir.r4.model.Group in project tdi-studio-se by Talend.

the class HL7PublicUtil method cloneATreeNode.

public HL7TreeNode cloneATreeNode(Object treeNode, String label) {
    HL7TreeNode node = new Element();
    String nodeLabel = getLabel(treeNode, true);
    node.setLabel(nodeLabel);
    String rowLabel = label;
    if (treeNode instanceof SegmentModel) {
        ((Element) node).setRow(nodeLabel);
        rowLabel = nodeLabel;
    } else if (!(treeNode instanceof Group)) {
        ((Element) node).setRow(rowLabel);
    }
    node.setMain(true);
    // treeNode.getChildren();
    Object[] children = getChildList(treeNode);
    if (children != null) {
        for (Object element : children) {
            if (getChildList(element).length > 0) {
                String tlabel = getLabel(element, true);
                String childLabel = rowLabel;
                HL7TreeNode childEle = cloneATreeNode(element, rowLabel);
                if (element instanceof SegmentModel) {
                    childLabel = tlabel;
                }
                childEle.setLabel(tlabel);
                if (childEle instanceof Element) {
                    ((Element) childEle).setRow(childLabel);
                }
                node.addChild(childEle);
            } else {
                HL7TreeNode childEle = new Element();
                String tlabel = getLabel(element, false);
                childEle.setLabel(tlabel);
                if (childEle instanceof Element) {
                    ((Element) childEle).setRow(label);
                    ((Element) childEle).setColumnName(getLabel(element, true));
                }
                childEle.setMain(false);
                node.addChild(childEle);
            }
        }
    }
    return node;
}
Also used : Group(ca.uhn.hl7v2.model.Group) Element(org.talend.designer.hl7.ui.data.Element) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) SegmentModel(org.talend.designer.hl7.model.SegmentModel)

Example 4 with Group

use of org.hl7.fhir.r4.model.Group in project tdi-studio-se by Talend.

the class HL7PublicUtil method initTreeRoot.

public HL7TreeNode initTreeRoot(Object treeNode) {
    HL7TreeNode node = new Element();
    String nodeLabel = getLabel(treeNode, true);
    node.setLabel(nodeLabel);
    node.setMain(true);
    List children = getFirstLevelChild(treeNode);
    if (children != null) {
        for (Object child : children) {
            String label = getLabel(child, true);
            HL7TreeNode childEle = cloneATreeNode(child, label);
            childEle.setLabel(label);
            if (!(child instanceof Group)) {
                ((Element) childEle).setRow(label);
            }
            node.addChild(childEle);
        }
    }
    return node;
}
Also used : Group(ca.uhn.hl7v2.model.Group) Element(org.talend.designer.hl7.ui.data.Element) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with Group

use of org.hl7.fhir.r4.model.Group in project tdi-studio-se by Talend.

the class HL7PublicUtil method getChildren.

public Set getChildren(Object parentElement) {
    // List values = new ArrayList();
    Set values = new HashSet();
    if (parentElement instanceof Message) {
        Message messParent = (Message) parentElement;
        String[] childNames = messParent.getNames();
        if (!values.isEmpty()) {
            values.clear();
        }
        for (int i = 0; i < childNames.length; i++) {
            try {
                Structure[] childReps = messParent.getAll(childNames[i]);
                for (int j = 0; j < childReps.length; j++) {
                    if (childReps[j] instanceof Message) {
                        values.add(childReps[j]);
                        if (getChildren(childReps[j]).size() > 0) {
                            values.addAll(getChildren(childReps[j]));
                        }
                    }
                    if (childReps[j] instanceof Group) {
                        values.add(childReps[j]);
                        allSegmentFromGroup.clear();
                        getAllSegmentsFromGroup((Group) childReps[j]);
                    }
                    if (childReps[j] instanceof Segment) {
                        SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
                        if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
                            values.add(sModel);
                            if (getChildren(sModel).size() > 0) {
                                values.addAll(getChildren(sModel));
                            }
                            if (!allSegmentsForMessage.contains(sModel)) {
                                allSegmentsForMessage.add(sModel);
                            }
                        }
                    }
                }
            // values.addAll(Arrays.asList(childReps));
            } catch (HL7Exception e) {
                e.printStackTrace();
            }
        }
        return values;
    }
    if (parentElement instanceof Segment) {
        values.clear();
        Segment segment = (Segment) parentElement;
        SegmentModel sm = new SegmentModel(segment, segment, 0, 0);
        TypeModel[] models = sm.getTypes();
        for (TypeModel model : models) {
            values.add(model);
            if (getChildren(model).size() > 0) {
                values.addAll(getChildren(model));
            }
        }
        return values;
    }
    if (parentElement instanceof SegmentModel) {
        SegmentModel sm = (SegmentModel) parentElement;
        TypeModel[] models = sm.getTypes();
        for (TypeModel model : models) {
            values.add(model);
            if (getChildren(model).size() > 0) {
                values.addAll(getChildren(model));
            }
        }
        return values;
    }
    if (parentElement instanceof TypeModel) {
        TypeModel tm = (TypeModel) parentElement;
        PrimitiveModel[] models = tm.getPrimitives();
        for (PrimitiveModel model : models) {
            values.add(model);
            if (getChildren(model).size() > 0) {
                values.addAll(getChildren(model));
            }
        }
        return values;
    // return tm.getPrimitives();
    }
    if (parentElement instanceof Group) {
        values.clear();
        Group group = (Group) parentElement;
        String[] childNames = group.getNames();
        for (int i = 0; i < childNames.length; i++) {
            try {
                Structure[] childReps = group.getAll(childNames[i]);
                for (int j = 0; j < childReps.length; j++) {
                    if (childReps[j] instanceof Segment) {
                        SegmentModel sm = new SegmentModel((Segment) childReps[j], group, i, j);
                        if (sm.getTypes() != null && sm.getTypes().length > 0) {
                            values.add(sm);
                            if (getChildren(sm).size() > 0) {
                                values.addAll(getChildren(sm));
                            }
                        }
                    } else {
                        values.add(childReps[j]);
                        if (getChildren(childReps[j]).size() > 0) {
                            values.addAll(getChildren(childReps[j]));
                        }
                    }
                }
            // values.addAll(Arrays.asList(childReps));
            } catch (HL7Exception e) {
                e.printStackTrace();
            }
        }
        return values;
    }
    return values;
}
Also used : Group(ca.uhn.hl7v2.model.Group) Set(java.util.Set) HashSet(java.util.HashSet) Message(ca.uhn.hl7v2.model.Message) TypeModel(org.talend.designer.hl7.model.TypeModel) PrimitiveModel(org.talend.designer.hl7.model.PrimitiveModel) Segment(ca.uhn.hl7v2.model.Segment) HL7Exception(ca.uhn.hl7v2.HL7Exception) Structure(ca.uhn.hl7v2.model.Structure) SegmentModel(org.talend.designer.hl7.model.SegmentModel) HashSet(java.util.HashSet)

Aggregations

Test (org.junit.Test)106 Group (org.hl7.fhir.r4.model.Group)74 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)59 ArrayList (java.util.ArrayList)57 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)50 FHIRException (org.hl7.fhir.exceptions.FHIRException)37 Cohort (org.openmrs.Cohort)32 Group (org.hl7.fhir.dstu3.model.Group)30 Reference (org.hl7.fhir.r4.model.Reference)21 InputStream (java.io.InputStream)20 Test (org.junit.jupiter.api.Test)19 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)16 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)16 Coding (org.hl7.fhir.r4.model.Coding)16 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)15 IOException (java.io.IOException)13 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13 Group (ca.uhn.hl7v2.model.Group)12 List (java.util.List)12