package ans.samples.app; /** * * Copyright (c) 2000-2002 AdvanceNet Health Solutions, Inc. All Rights Reserved. * * THIS SOFTWARE IS THE CONFIDENTIAL AND PROPRIETARY INFORMATION OF * ADVANCENET SOLUTIONS, INC. ("CONFIDENTIAL INFORMATION"). * AND IS PROTECTED BY U.S. COPYRIGHT LAW. ANY USER SHALL NOT DISCLOSE * SUCH CONFIDENTIAL INFORMATION AND SHALL USE THIS SOFTWARE IN * ACCORDANCE WITH THE TERMS OF ANY DISCLOSURES AND/OR LICENSE AGREEMENTS * ENTERED INTO WITH ADVANCENET. FAILURE TO ABIDE IS PUNISHABLE BY A COURT OF * LAW. * **/ import ans.client.nongui.ANSClient; import ans.com.message.*; import ans.com.descriptors.segment.*; import ans.com.exception.ANSException; import java.util.ArrayList; /** * ANSNewRxMessageTest1 * *

A short, simple example program of a prescriber sending a NewRx * message WITHOUT Insurance(COO) information to ePostRx to be posted to * a pharmacy's mailbox. *

================================================================= *
Modified last by:

* * 8/30/01 John Strecker Initial Creation.
*

================================================================= * * @author John Strecker * @version 1.0 */ public class ANSNewRxMessageTest1 { public static void main(String []args) throws ANSException { System.out.println("Running ANSNewRxMessageTest1 sample"); /*********************************************************** * Make sure you modify the path for the ANSClientProps file * to reflect your environment ***********************************************************/ String ansHome = "c:\\ans"; ANSClient c = new ANSClient(ansHome); // create message object ANSNewRxMessage rx = new ANSNewRxMessage(); // begin set the necessary Rx fields of the message //create control header object and set fields accordingly UIB uib = new UIB(); // set the message trace number. This is not needed if transaction is NOT being forwarded to another // third party processor(i.e. RxHub) by ePostRx. ANS will create unique trace numbers for //internal message grouping and auditing. uib.setTransactionControlReference("1234567"); // set sender info for mailbox, //no mailbox password info needed because we are using PKI authentication uib.setLevelOneSenderId("7777777"); // clinics's Id uib.setLevelOneSenderQualifier(uib.CLINIC); // qualify the id by indicating "C" for clinic // set recipient info for destiniation mailbox, // no mailbox password info needed because we are using PKI authentication uib.setLevelOneRecipientId("4162jss"); // intended recipient is Pharmacy. Indicate Pharmacy's NCPDP number uib.setLevelOneRecipientQualifier(uib.PHARMACY); // qualify the id by indicating "P" for pharmacy rx. setInterchangeControlHeader(uib); // update UIB segment of RX message //create message header object and set fields UIH uih = new UIH(); // Set Clinic’s reference number for message. Usually this is // the folio number for the patient or Rx number. However, this is the ID // by which the clinic will be able to refer to this prescription. uih.setMessageReference("110072"); rx.setMessageHeader(uih); // update UIH segment of message // create patient object info PTT ptt = new PTT(); ptt.setBirthDate("19541225"); //Patient’s date of birth 12/25/1954 ptt.setFirstName("Mary"); //Patient’s first name ptt.setMiddleName("Mary"); //Patient’s middle name ptt.setPartyName("QuiteContrary"); //Patient’s last(party) name ptt.setGender(ptt.FEMALE); //set female gender // because Patient Reference is a repeat EDI DEG (data element group), // we need create a Reference object for the patient containing unique patient data // and bind to PTT Reference r = new Reference(); r.setReference("333445555"); //Patient’s Social Security Number. This could also be the PMS patient number. r.setReferenceQualifier("SY"); //SY is the SSN qualifier. ptt.setPatientReference(r); // set patient address info ptt.setStreetNumber("1313 mockingbird lane"); ptt.setCity("Warminster"); ptt.setCountry("US"); ptt.setPostalCode("18966"); rx.setPatientData(ptt); // update PTT segment of RX message // create provider object info. Identifies info about the prescribing physician (PC) PVD pc = new PVD(); pc.setProviderCode("PC"); // because Provider Reference is a repeat EDI DEG (data element group), // we need create a Reference object that contains the // State License Number of the doctor (6666666) and qualifier. The OB indicates that // it is the State ID rather than some other. Then bind it to the PVD object. If multiple // physicians are to be provided, create another Reference object and bind to PVD. Reference doc = new Reference(); doc.setReference("6666666"); doc.setReferenceQualifier("OB"); pc.setProviderReference(doc); pc.setFirstName("DOCTOR"); // Physician First Name pc.setPartyName("J"); // Physician Last Name pc.setProviderSpeciality("FP"); // provider speciality code as Family Practice // because Contact is a repeat EDI DEG (data element group), // we need create a Contact object that contains the physician phone number and Qualifier Contact cd = new Contact(); cd.setContactNumber("6152219800"); // Phone Number of Physician (615) 221-98ØØ. cd.setContactQualifier("TE"); // TE is the qualifier. pc.setContactInfo(cd); // create another provider object info. Qualifier P1 Identifies this PVD segment as referring to pharmacy. // Note: This is really NOT required because ePostRx uses the NCPDP number to lookup information // about the target pharmacy. If this transaction is being sent to another third party processor(i.e. RxHub) // by ePostRx. PVD p1 = new PVD(); p1.setProviderCode("P1"); // because Provider Reference is a repeat EDI DEG (data element group), // we need create a Reference object that contains the // NCPDP Pharmacy Number (7701630) and qualifier. The D3 indicates that // it is the NCPDP ID number. Then bind it to the PVD object. If multiple // physicians are to be provided, create another Reference object and bind to PVD. Reference pharm = new Reference(); pharm.setReference("7701630"); pharm.setReferenceQualifier("D3"); p1.setProviderReference(pharm); p1.setProviderName("MAIN STREET PHARMACY"); // Name of Pharmacy // because Contact is a repeat EDI DEG (data element group), // we need create a Contact object that contains the the pharmacy phone number and Qualifier Contact cp = new Contact(); cp.setContactNumber("6152205656"); // Phone Number of Pharmacy (615) 22Ø-5656. TE is the qualifier. cp.setContactQualifier("TE"); // Qualifier as Telephone p1.setContactInfo(cp); p1.setProviderSpeciality("FP"); // provider speciality code // create collection of provider objects, max is 2! ArrayList p = new ArrayList(2); p.add(p1); p.add(pc); rx.setProviderData(p); // update PVD segments in message // create drug object info. Identifies info about the perscription DRU drug = new DRU(); drug.setDruSegmentID("P"); // id qualifies the drug segment info as "Prescribed" drug drug.setDrugName("CALAN SR 240MG"); // drug name drug.setDrugStrength("240"); // drug strength drug.setDrugStrengthQualifier("ME"); // ME means milligram // Dispense Quantityis a repeat EDI DEG. // This means dispense 60 tablets. (EA means each). 38 is the code value for Original Qty. Quantity dispense = new Quantity(); dispense.setQuantityForm("EA"); dispense.setQuantity("60"); dispense.setQuantityQualifier(dispense.ORIGINAL_QUANTITY); drug.setDispenseQuantity(dispense); // Dispense Quantityis a repeat EDI DEG. // This means dispense 60 tablets. (EA means each). 38 is the code value for Original Qty. Quantity dispense1 = new Quantity(); dispense1.setQuantityForm("EA"); dispense1.setQuantity("160"); dispense1.setQuantityQualifier(dispense1.ORIGINAL_QUANTITY); drug.setDispenseQuantity(dispense1); // set the SIG info drug.setDosageId("1TID"); drug.setDosageDirections1("TAKE ONE TABLET"); // DateTime is a repeat EDI DEG. set the Rx date info. 85 is the qualifier for Date Written 10/1/2001. 102 is the qualifier for the date format. DateTime dt = new DateTime(); dt.setDateTimeQualifier(dt.DATE_ISSUED); dt.setDateTime("20011001"); dt.setDateTimeFormatQualifier(dt.CCYYMMDD); drug.setDateTime(dt); //DRU Ø Product/Service Substitution, coded. 0 is No Product //Selection Indicated, which means substitution is allowed. drug.setProductServiceSubstitution(drug.NO_PRODUCT_SUBSTITUION); // Refill Quantity is a repeat EDI DEG field. DRU R:1 R is the code for Refills. One refill is allowed. // This means dispense 60 tablets. (EA means each). 38 is the code value for Original Qty. Quantity refill = new Quantity(); refill.setQuantity("1"); refill.setQuantityQualifier(refill.NUMBER_OF_REFILLS); drug.setRefillQuantity(refill); rx.setDrugData(drug); // update DRUG segment of message // Message complete - send NewRx Message request to ePostRx for validation and posting ANSClientResponse res = c.send(rx); System.out.println("EDI Response MESSAGE " + res.getEDIResponse()); // check response from ePostRx if (res.getResponseCode() >= res.SUCCESS) { // check message response Id to cast response appropriately. A STATUS response indicates message was // posted successfully to pharmacy mailbox. if (res.getResponseMessageId().equals(res.STATUS)){ // cast STATUS message to get at message object ANSStatusMessage ans = (ANSStatusMessage)res. getMessageResponseObject(); // get Status segment object of message STS sts = ans.getMessageStatus(); // look at STS segment status type field for code. System.out.println("Message Posted successfully, status ->" + sts.getStatusType()); } // message sent, but rejected by ePostRx }else if (res.getResponseCode() == res.FAILURE) { // cast ERROR message to get at message object ANSErrorMessage ans = (ANSErrorMessage)res. getMessageResponseObject(); // get Status segment object of message STS sts = ans.getMessageStatus(); // look at STS segment status type field of ERROR for reject code indicating error code. System.out.println("Error Response reject code ->" + sts.getStatusType()); System.out.println("Error Response reject message ->" + sts.getFreeText()); //OR you can just look at the response object for these fields as well, like: System.out.println("Error Response reject code ->" + res.getRejectCode()); System.out.println("Error Response reject message ->" + res.getRejectMessage()); System.out.println("Error Response log - " + res.getResponseLog()); // fatal error will NOT create a message object to cast because error is of unkown origin. }else if (res.getResponseCode() == res.FATAL_ERROR) { // Just look at responseLog to get general error description System.out.println("Error Log -> " + res.getResponseLog()); }// endif }// end main }// end class