Java Code Examples for ca.uhn.hl7v2.model.AbstractSegment

The following are top voted examples for showing how to use ca.uhn.hl7v2.model.AbstractSegment. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: rassyeyanie   File: AbstractHl7Test.java   Source Code and License 6 votes vote down vote up
protected <T extends Structure> void testStructureByIndex(int index,
                                                          Class<T> clazz)
    throws HL7Exception
{
    
    List<T> exepectedSegments =
        HapiUtil.getAll(this.expectedMessage, clazz);
    // re-eval to remove cleared segments
    List<T> actualSegments =
        HapiUtil.getAll((AbstractMessage) this.pipeParser
            .parse(this.actualMessage.encode()), clazz);
    
    if (exepectedSegments.size() < index + 1 ||
        actualSegments.size() < index + 1)
        return;
    
    assertEquals(
        ((AbstractSegment) exepectedSegments.get(index)).encode(),
        ((AbstractSegment) actualSegments.get(index)).encode());
}
 
Example 2
Project: rassyeyanie   File: AbstractHl7Test.java   Source Code and License 6 votes vote down vote up
protected <T extends Structure> void
    testStructureByIndex(String groupName,
                         int groupIndex,
                         Class<T> segmentClass,
                         int segmentIndex)
        throws HL7Exception
{
    Structure expectedSegment =
        getGroupSegment(
            groupIndex,
            segmentIndex,
            segmentClass,
            groupName,
            this.expectedMessage);
    Structure actualSegment =
        getGroupSegment(
            groupIndex,
            segmentIndex,
            segmentClass,
            groupName,
            this.actualMessage);
    assertEquals(
        ((AbstractSegment) expectedSegment).encode(),
        ((AbstractSegment) actualSegment).encode());
}
 
Example 3
Project: rassyeyanie   File: AbstractHl7Test.java   Source Code and License 5 votes vote down vote up
protected <T extends AbstractSegment> void
    assertEqualFields(AbstractMessage expected,
                      AbstractMessage actual,
                      Class<T> clazz)
        throws HL7Exception
{
    Assert.assertEquals(
        HapiUtil.getWithTerser(expected, clazz).encode(),
        HapiUtil.getWithTerser(actual, clazz).encode());
}
 
Example 4
Project: rassyeyanie   File: AbstractHl7Test.java   Source Code and License 5 votes vote down vote up
protected void assertEquals(Structure expectedSegment,
                            Structure actualSegment)
    throws HL7Exception
{
    assertEquals(
        ((AbstractSegment) expectedSegment).encode(),
        ((AbstractSegment) actualSegment).encode());
}
 
Example 5
Project: rassyeyanie   File: SymA12PimsA11.java   Source Code and License 5 votes vote down vote up
public void processMessage(@Body ADT_A09 to)
    throws HL7Exception
{
    this.transform(to.getMSH());
    this.transform(to.getEVN());
    this.transform(to.getPID());
    AbstractSegment zref = (AbstractSegment) to.get("ZRF");
    this.transform(to.getPV1(), zref);
    zref.clear();
}
 
Example 6
Project: rassyeyanie   File: SymA02PimsA02.java   Source Code and License 5 votes vote down vote up
public void processMessage(@Body ADT_A02 to)
    throws HL7Exception
{
    this.transform(to.getEVN());
    this.transform(to.getPID());
    AbstractSegment zref = (AbstractSegment) to.get("ZRF");
    this.transform(to.getPV1(), zref);
    zref.clear();
}
 
Example 7
Project: rassyeyanie   File: SymA03PimsA02.java   Source Code and License 5 votes vote down vote up
public void processMessage(@Body ADT_A03 to)
    throws HL7Exception
{
    this.transform(to.getMSH());
    this.transform(to.getEVN());
    this.transform(to.getPID());
    AbstractGroup zrefParent = getZrefParent(to);
    AbstractSegment zref = (AbstractSegment) zrefParent.get("ZRF");
    this.transform(to.getPV1(), zref);
    zref.clear();
    for (int i = 0; i < to.getDG1Reps(); i++)
    {
        to.getDG1(i).clear();
    }
    
    for (Structure al1 : zrefParent.getAll("AL1"))
    {
        ((AL1) al1).clear();
    }
    
    for (Structure nte : zrefParent.getAll("NTE"))
    {
        ((NTE) nte).clear();
    }
    
    if (zrefParent instanceof ADT_A03_PROCEDURE)
    {
        zrefParent.clear();
    }
}
 
Example 8
Project: rassyeyanie   File: SymA03PimsA01.java   Source Code and License 5 votes vote down vote up
public void dispatchProcessFixture(@Body ADT_A03 to)
    throws HL7Exception
{
    AbstractGroup zrefParent = getZrefParent(to);
    AbstractSegment zref = (AbstractSegment) zrefParent.get("ZRF");
    
    this.transform(to.getPV1(), zref, to.getEVN());
    this.transform(to.getEVN());
    this.transform(to.getMSH());
    this.transform(to.getPID());
    
    for (int i = 0; i < to.getDG1Reps(); i++)
    {
        to.getDG1(i).clear();
    }
    
    for (Structure al1 : zrefParent.getAll("AL1"))
    {
        ((AL1) al1).clear();
    }
    
    for (Structure nte : zrefParent.getAll("NTE"))
    {
        ((NTE) nte).clear();
    }
    
    if (zrefParent instanceof ADT_A03_PROCEDURE)
    {
        to.addNonstandardSegment("ZRF");
        Segment zrf = (Segment) to.insertRepetition("ZRF", 0);
        DeepCopy.copy(zref, zrf);
        to.insertRepetition("ZRF", 0);
        zrefParent.clear();
    }
    
}
 
Example 9
Project: rassyeyanie   File: SymA03PimsA03.java   Source Code and License 5 votes vote down vote up
public void processMessage(@Body ADT_A03 to)
    throws HL7Exception
{
    this.transform(to.getPID());
    AbstractGroup zrefParent = getZrefParent(to);
    AbstractSegment zref = (AbstractSegment) zrefParent.get("ZRF");
    this.transform(to.getPV1(), zref, to.getEVN());
    
    for (int i = 0; i < to.getDG1Reps(); i++)
    {
        to.getDG1(i).clear();
    }
    
    for (Structure al1 : zrefParent.getAll("AL1"))
    {
        ((AL1) al1).clear();
    }
    for (Structure nte : zrefParent.getAll("NTE"))
    {
        ((NTE) nte).clear();
    }
    
    this.transformZref(zref, to.getPV1());
    
    if (zrefParent instanceof ADT_A03_PROCEDURE)
    {
        zrefParent.clear();
    }
}
 
Example 10
Project: rassyeyanie   File: AbstractHl7Test.java   Source Code and License 4 votes vote down vote up
public <T extends AbstractSegment> void segment_tester(Class<T> clazz)
    throws Exception
{
    this.assertEqualFields(this.expectedMessage, this.actualMessage, clazz);
}
 
Example 11
Project: rassyeyanie   File: SymA12PimsA11.java   Source Code and License 4 votes vote down vote up
private void transform(PV1 pv1, AbstractSegment zref)
    throws HL7Exception
{
    pv1.getPv12_PatientClass().setValue("I");
    
    pv1
        .getPv13_AssignedPatientLocation()
        .getPl4_Facility()
        .getHd1_NamespaceID()
        .setValue("KCH");
    pv1
        .getPv13_AssignedPatientLocation()
        .getPl9_LocationDescription()
        .setValue(
            pv1
                .getPv137_DischargedToLocation()
                .getDld2_EffectiveDate()
                .getTs1_TimeOfAnEvent()
                .getValue());
    
    pv1.getPv14_AdmissionType().setValue("21");
    
    for (int i = 6; i <= 8; i++)
    {
        pv1.getField(i, 0).clear();
    }
    
    CE referralBySpecialty = new CE(pv1.getMessage());
    ((Varies) zref.getField(8, 0)).setData(referralBySpecialty);
    
    pv1.getPv110_HospitalService().setValue(
        referralBySpecialty.getCe1_Identifier().getValue());
    
    XCN referredTo = new XCN(pv1.getMessage());
    ((Varies) zref.getField(7, 0)).setData(referredTo);
    pv1
        .getPv117_AdmittingDoctor(0)
        .getXcn1_IDNumber()
        .setValue(referredTo.getXcn1_IDNumber().getValue());
    
    CE admitCategory = new CE(pv1.getMessage());
    ((Varies) zref.getField(12, 0)).setData(admitCategory);
    
    pv1.getPv118_PatientType().setValue(
        admitCategory.getCe1_Identifier().getValue());
    
    pv1.getPv122_CourtesyCode().setValue("NSP");
    
    for (int i = 23; i <= 27; i++)
    {
        pv1.getField(i, 0).clear();
    }
    
    pv1.getPv128_InterestCode().setValue("NSP");
    
    for (int i = 29; i <= 39; i++)
    {
        pv1.getField(i, 0).clear();
    }
    
    pv1.getPv136_DischargeDisposition().setValue("NSP");
    pv1
        .getPv137_DischargedToLocation()
        .getDld1_DischargeLocation()
        .setValue("NSP");
    pv1.getPv138_DietType().getCe1_Identifier().setValue("NA");
    
    pv1.getPv140_BedStatus().setValue("NSP");
    
    for (int i = 45; i <= 49; i++)
    {
        pv1.getField(i, 0).clear();
    }
}
 
Example 12
Project: rassyeyanie   File: SymA02PimsA02.java   Source Code and License 4 votes vote down vote up
private void transform(PV1 pv1, AbstractSegment zref)
    throws HL7Exception
{
    pv1.getPv11_SetIDPV1().clear();
    pv1
        .getPv13_AssignedPatientLocation()
        .getPl9_LocationDescription()
        .setValue(
            pv1
                .getPv137_DischargedToLocation()
                .getDld1_DischargeLocation()
                .getValue());
    pv1
        .getPv13_AssignedPatientLocation()
        .getPl4_Facility()
        .getHd1_NamespaceID()
        .setValue("KCH");
    pv1.getPv16_PriorPatientLocation().getPl4_Facility().clear();
    pv1.getPv16_PriorPatientLocation().getPl9_LocationDescription().clear();
    
    for (int i = 7; i <= 8; i++)
    {
        pv1.getField(i, 0).clear();
    }
    
    XCN referredTo = new XCN(pv1.getMessage());
    ((Varies) zref.getField(7, 0)).setData(referredTo);
    pv1
        .getPv19_ConsultingDoctor(0)
        .getXcn1_IDNumber()
        .setValue(referredTo.getXcn1_IDNumber().getValue());
    
    CE referralBySpecialty = new CE(pv1.getMessage());
    ((Varies) zref.getField(9, 0)).setData(referralBySpecialty);
    
    if (StringUtils.isNotEmpty(referralBySpecialty
        .getCe1_Identifier()
        .getValue()))
    {
        pv1.getPv110_HospitalService().setValue(
            referralBySpecialty.getCe1_Identifier().getValue());
    }
    else
    {
        pv1.getPv110_HospitalService().setValue("NSP");
    }
    
    pv1
        .getPv117_AdmittingDoctor(0)
        .getXcn1_IDNumber()
        .setValue(referredTo.getXcn1_IDNumber().getValue());
    
    CE admitCategory = new CE(pv1.getMessage());
    ((Varies) zref.getField(12, 0)).setData(admitCategory);
    
    pv1.getPv118_PatientType().setValue(
        admitCategory.getCe1_Identifier().getValue());
    
    pv1.getPv122_CourtesyCode().setValue("NSP");
    pv1.getPv128_InterestCode().setValue("NSP");
    pv1.getPv140_BedStatus().setValue("NSP");
    
    for (int i = 46; i <= 52; i++)
    {
        pv1.getField(i, 0).clear();
    }
}