Menu

#258 How to instantiate a PRT segment for a A01 transaction

2.2
open
PRT (1) A01 (1)
5
2020-09-30
2020-09-30
No

hi, I want to have a PRT segment in a A01 transaction, I have the following method which creates a A01 with MSH EVN and PID but for PRT I am nots ure how to instantiate in A01. In fact I want to instantiate a PRT segment for the following transactions

A01
A03
A04
A05
A06
A07
A08

public static void main(String[] args) throws HL7Exception, IOException {
ADT_A01 a01 = new ADT_A01();
a01.initQuickstart("ADT", "A01", "P");
MSH mshSegment = a01.getMSH();

    mshSegment.getSendingApplication().getNamespaceID().setValue("DAY3-SENDERAPP");
    mshSegment.getSequenceNumber().setValue("123");

    EVN evnSegment = a01.getEVN();
    evnSegment.getEvn2_RecordedDateTime().setValue(getEventTime());
    evnSegment.getEvn6_EventOccurred().setValue(getEventTime());

    PRT prtSegment = a01.getPRT(); // error here.
    prtSegment.getActionCode().setValue("1");

    PID pid = a01.getPID();
    pid.getPid3_PatientIdentifierList(0).getIDNumber().setValue("457");
    pid.getPid3_PatientIdentifierList(0).getAssigningAuthority().getNamespaceID().setValue("28");
    pid.getPid3_PatientIdentifierList(0).getIdentifierTypeCode().setValue("ZPN");

    pid.getPid5_PatientName(0).getFamilyName().getSurname().setValue("Chakraborty");
    pid.getPid5_PatientName(0).getGivenName().setValue("Swaroop");
    pid.getPid5_PatientName(0).getSecondAndFurtherGivenNamesOrInitialsThereof().setValue("Babu");
    pid.getPid5_PatientName(0).getNameTypeCode().setValue("L");
    pid.getPid11_PatientAddress(0).getStreetAddress().getStreetOrMailingAddress().setValue("121 Demo Road");
    pid.getPid11_PatientAddress(0).getCity().setValue("Malvern");
    pid.getPid11_PatientAddress(0).getStateOrProvince().setValue("PA");
    pid.getPid11_PatientAddress(0).getZipOrPostalCode().setValue("19355");
    pid.getPid11_PatientAddress(0).getCountry().setValue("USA");
    pid.getPid11_PatientAddress(0).getAddressType().setValue("M");
    pid.getPid13_PhoneNumberHome(0).getTelecommunicationUseCode().setValue("PRN");
    pid.getPid13_PhoneNumberHome(0).getTelecommunicationEquipmentType().setValue("PH");
    pid.getPid13_PhoneNumberHome(0).getCountryCode().setValue("1");
    pid.getPid13_PhoneNumberHome(0).getAreaCityCode().setValue("91");

    HapiContext context = new DefaultHapiContext();
    Parser parser = context.getPipeParser();

    String encodedMessage = parser.encode(a01);
    System.out.println("Printing ER7 Encoded Message:");
    System.out.println(encodedMessage);

}
1 Attachments

Discussion

  • Christian Ohr

    Christian Ohr - 2020-09-30

    PRT is not a segment that is defined for the events you mentioned. Therefore you have to use a more generic way:

    You can add it to the message using addNonStandardSegment("PRT") (optionally with index position) and then obtain it with PRT prt = (PRT)a01.get("PRT")

     
  • SWAROOP CHAKRABORTY

    Thanks Chris. I get it now. Your solution worked.

     

Log in to post a comment.