Search in sources :

Example 11 with Segment

use of ca.uhn.hl7v2.model.Segment in project camel by apache.

the class HL7ValidateTest method createADT01Message.

private static Message createADT01Message() throws Exception {
    ADT_A01 adt = new ADT_A01();
    adt.initQuickstart("ADT", "A01", "P");
    // Populate the PID Segment
    PID pid = adt.getPID();
    pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
    pid.getPatientName(0).getGivenName().setValue("John");
    pid.getPhoneNumberBusiness(0).getPhoneNumber().setValue("333123456");
    pid.getPatientIdentifierList(0).getID().setValue("123456");
    return adt;
}
Also used : PID(ca.uhn.hl7v2.model.v24.segment.PID) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01)

Example 12 with Segment

use of ca.uhn.hl7v2.model.Segment 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)

Example 13 with Segment

use of ca.uhn.hl7v2.model.Segment 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 14 with Segment

use of ca.uhn.hl7v2.model.Segment in project camel by apache.

the class AckExpressionTest method createADT01Message.

private static ADT_A01 createADT01Message() throws Exception {
    ADT_A01 adt = new ADT_A01();
    adt.initQuickstart("ADT", "A01", "P");
    // Populate the PID Segment
    PID pid = adt.getPID();
    pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
    pid.getPatientName(0).getGivenName().setValue("John");
    pid.getPatientIdentifierList(0).getID().setValue("123456");
    return adt;
}
Also used : PID(ca.uhn.hl7v2.model.v24.segment.PID) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01)

Example 15 with Segment

use of ca.uhn.hl7v2.model.Segment in project camel by apache.

the class HL7RouteTest method createADR19Message.

// END SNIPPET: e2
private static Message createADR19Message() throws Exception {
    ADR_A19 adr = new ADR_A19();
    // Populate the MSH Segment
    MSH mshSegment = adr.getMSH();
    mshSegment.getFieldSeparator().setValue("|");
    mshSegment.getEncodingCharacters().setValue("^~\\&");
    mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
    mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
    mshSegment.getSequenceNumber().setValue("123");
    mshSegment.getMessageType().getMessageType().setValue("ADR");
    mshSegment.getMessageType().getTriggerEvent().setValue("A19");
    // Populate the PID Segment
    MSA msa = adr.getMSA();
    msa.getAcknowledgementCode().setValue("AA");
    msa.getMessageControlID().setValue("123");
    QRD qrd = adr.getQRD();
    qrd.getQueryDateTime().getTimeOfAnEvent().setValue("20080805120000");
    return adr.getMessage();
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) MSH(ca.uhn.hl7v2.model.v24.segment.MSH) ADR_A19(ca.uhn.hl7v2.model.v24.message.ADR_A19) MSA(ca.uhn.hl7v2.model.v24.segment.MSA)

Aggregations

MSH (ca.uhn.hl7v2.model.v24.segment.MSH)14 ADR_A19 (ca.uhn.hl7v2.model.v24.message.ADR_A19)10 MSA (ca.uhn.hl7v2.model.v24.segment.MSA)10 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)10 ADT_A01 (ca.uhn.hl7v2.model.v24.message.ADT_A01)8 PID (ca.uhn.hl7v2.model.v24.segment.PID)8 HL7Exception (ca.uhn.hl7v2.HL7Exception)4 Group (ca.uhn.hl7v2.model.Group)4 Message (ca.uhn.hl7v2.model.Message)4 Segment (ca.uhn.hl7v2.model.Segment)4 Structure (ca.uhn.hl7v2.model.Structure)4 SegmentModel (org.talend.designer.hl7.model.SegmentModel)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TypeModel (org.talend.designer.hl7.model.TypeModel)3 HashSet (java.util.HashSet)1 Set (java.util.Set)1 PrimitiveModel (org.talend.designer.hl7.model.PrimitiveModel)1