[507] | 1 | /*
|
---|
| 2 | * To change this template, choose Tools | Templates
|
---|
| 3 | * and open the template in the editor.
|
---|
| 4 | */
|
---|
| 5 | package gov.hhs.fha.nhinc.transform.subdisc;
|
---|
| 6 |
|
---|
| 7 | import javax.xml.bind.JAXBElement;
|
---|
| 8 | import org.hl7.v3.II;
|
---|
| 9 | import org.hl7.v3.MFMIMT700711UV01QueryAck;
|
---|
| 10 | import org.hl7.v3.PNExplicit;
|
---|
| 11 | import org.hl7.v3.PRPAIN201310UV;
|
---|
| 12 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01ControlActProcess;
|
---|
| 13 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01RegistrationEvent;
|
---|
| 14 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01Subject1;
|
---|
| 15 | import org.hl7.v3.PRPAIN201310UVMFMIMT700711UV01Subject2;
|
---|
| 16 | import org.hl7.v3.PRPAMT201304UVPatient;
|
---|
| 17 | import org.hl7.v3.PRPAMT201304UVPerson;
|
---|
| 18 | import org.hl7.v3.PRPAMT201307UVParameterList;
|
---|
| 19 | import org.hl7.v3.PRPAMT201307UVQueryByParameter;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
| 22 | *
|
---|
| 23 | * @author vvickers
|
---|
| 24 | */
|
---|
| 25 | public class HL7PRPA201310Transforms {
|
---|
| 26 |
|
---|
| 27 | private static final String PATIENT_CLASS_CODE = "PAT";
|
---|
| 28 | private static final String STATUS_CODE_VALUE = "active";
|
---|
| 29 | private static final String PATIENT_PERSON_CLASSCODE = "PSN";
|
---|
| 30 | private static final String DETERMINER_CODE = "INSTANCE";
|
---|
| 31 | private static final String INTERACTION_ID_EXTENSION = "PRPA_IN201310UV";
|
---|
| 32 | private static final String PROCESSING_CODE_VALUE = "P";
|
---|
| 33 | private static final String PROCESSING_CODE_MODE = "T";
|
---|
| 34 | private static final String ACCEPT_ACK_CODE_VALUE = "AL";
|
---|
| 35 | private static final String CONTROL_MOOD_CODE = "EVN";
|
---|
| 36 | private static final String CONTROL_CODE_CODE = "PRPA_TE201310UV";
|
---|
| 37 | private static final String REG_EVENT_CLASS_CODE = "EVN";
|
---|
| 38 | private static final String REG_EVENT_MOOD_CODE = "REG";
|
---|
| 39 | private static final String REG_EVENT_STATUS_CODE = "active";
|
---|
| 40 | private static final String CONTROL_QUERY_RESPONSE_CODE = "OK";
|
---|
| 41 |
|
---|
| 42 | public static PRPAIN201310UV createFaultPRPA201310() {
|
---|
| 43 | return createPRPA201310("", "", "", "", "", null);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public static PRPAIN201310UV createFaultPRPA201310(String senderOID, String receiverOID) {
|
---|
| 47 | return createPRPA201310("", "", "", senderOID, receiverOID, null);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | public static PRPAIN201310UV createPRPA201310(String patientId, String assigningAuthorityId, String localDeviceId, String senderOID, String receiverOID, PRPAMT201307UVQueryByParameter queryParam) {
|
---|
| 51 |
|
---|
| 52 | // Create Transmission header
|
---|
| 53 | PRPAIN201310UV ret201310 = createTransmissionWrapper(localDeviceId);
|
---|
| 54 |
|
---|
| 55 | // Create the Sender
|
---|
| 56 | ret201310.setSender(HL7SenderTransforms.createMCCIMT000300UV01Sender(senderOID));
|
---|
| 57 |
|
---|
| 58 | // Create the Receiver
|
---|
| 59 | ret201310.getReceiver().add(HL7ReceiverTransforms.createMCCIMT000300UV01Receiver(receiverOID));
|
---|
| 60 |
|
---|
| 61 | // Create the control act process
|
---|
| 62 | PRPAMT201304UVPatient patient201304 = createPRPAMT201304UVPatient(patientId, assigningAuthorityId);
|
---|
| 63 | ret201310.setControlActProcess(createMFMIMT700711UV01ControlActProcess(patient201304, localDeviceId, queryParam));
|
---|
| 64 |
|
---|
| 65 | return ret201310;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | private static PRPAIN201310UV createTransmissionWrapper(String localDeviceId) {
|
---|
| 69 | PRPAIN201310UV message = new PRPAIN201310UV();
|
---|
| 70 |
|
---|
| 71 | message.setITSVersion(HL7Constants.ITS_VERSION);
|
---|
| 72 | message.setId(HL7MessageIdGenerator.GenerateHL7MessageId(localDeviceId));
|
---|
| 73 | message.setCreationTime(HL7DataTransformHelper.CreationTimeFactory());
|
---|
| 74 | message.setInteractionId(HL7DataTransformHelper.IIFactory(HL7Constants.INTERACTION_ID_ROOT, INTERACTION_ID_EXTENSION));
|
---|
| 75 | message.setProcessingCode(HL7DataTransformHelper.CSFactory(PROCESSING_CODE_VALUE));
|
---|
| 76 | message.setProcessingModeCode(HL7DataTransformHelper.CSFactory(PROCESSING_CODE_MODE));
|
---|
| 77 | message.setAcceptAckCode(HL7DataTransformHelper.CSFactory(ACCEPT_ACK_CODE_VALUE));
|
---|
| 78 |
|
---|
| 79 | return message;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | private static PRPAMT201304UVPatient createPRPAMT201304UVPatient(String patientId, String assigningAuthorityId) {
|
---|
| 83 |
|
---|
| 84 | PRPAMT201304UVPatient patient = new PRPAMT201304UVPatient();
|
---|
| 85 | patient.setClassCode(PATIENT_CLASS_CODE);
|
---|
| 86 | if(patientId != null && assigningAuthorityId != null){
|
---|
| 87 | patient.getId().add(HL7DataTransformHelper.IIFactory(assigningAuthorityId, patientId));
|
---|
| 88 | } else {
|
---|
| 89 | patient.getId().add(HL7DataTransformHelper.IIFactoryCreateNull());
|
---|
| 90 | }
|
---|
| 91 | patient.setStatusCode(HL7DataTransformHelper.CSFactory(STATUS_CODE_VALUE));
|
---|
| 92 |
|
---|
| 93 | PRPAMT201304UVPerson patientPerson = new PRPAMT201304UVPerson();
|
---|
| 94 | // create patient person element
|
---|
| 95 | javax.xml.namespace.QName xmlqname = new javax.xml.namespace.QName("urn:hl7-org:v3", "patientPerson");
|
---|
| 96 | JAXBElement<PRPAMT201304UVPerson> patientPersonElement = new JAXBElement<PRPAMT201304UVPerson>(xmlqname, PRPAMT201304UVPerson.class, patientPerson);
|
---|
| 97 | patient.setPatientPerson(patientPersonElement);
|
---|
| 98 | patientPerson.setClassCode(PATIENT_PERSON_CLASSCODE);
|
---|
| 99 |
|
---|
| 100 | patientPerson.setDeterminerCode(DETERMINER_CODE);
|
---|
| 101 |
|
---|
| 102 | PNExplicit patientName = new PNExplicit();
|
---|
| 103 | patientName.getNullFlavor().add(HL7Constants.NULL_FLAVOR);
|
---|
| 104 | patientPerson.getName().add(patientName);
|
---|
| 105 | return patient;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | private static PRPAIN201310UVMFMIMT700711UV01ControlActProcess createMFMIMT700711UV01ControlActProcess(PRPAMT201304UVPatient patient201304, String localDeviceId, PRPAMT201307UVQueryByParameter queryParam) {
|
---|
| 109 | PRPAIN201310UVMFMIMT700711UV01ControlActProcess controlActProcess = new PRPAIN201310UVMFMIMT700711UV01ControlActProcess();
|
---|
| 110 |
|
---|
| 111 | controlActProcess.setMoodCode(CONTROL_MOOD_CODE);
|
---|
| 112 | controlActProcess.setCode(HL7DataTransformHelper.CDFactory(CONTROL_CODE_CODE));
|
---|
| 113 |
|
---|
| 114 | controlActProcess.getSubject().add(createPRPAIN201310UVMFMIMT700711UV01Subject1(patient201304, localDeviceId, queryParam));
|
---|
| 115 |
|
---|
| 116 | controlActProcess.setQueryAck(createMFMIMT700711UV01QueryAck(queryParam));
|
---|
| 117 | return controlActProcess;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | private static PRPAIN201310UVMFMIMT700711UV01Subject1 createPRPAIN201310UVMFMIMT700711UV01Subject1(PRPAMT201304UVPatient patient201304, String localDeviceId, PRPAMT201307UVQueryByParameter queryParam) {
|
---|
| 121 | PRPAIN201310UVMFMIMT700711UV01Subject1 subject1 = new PRPAIN201310UVMFMIMT700711UV01Subject1();
|
---|
| 122 |
|
---|
| 123 | subject1.getTypeCode().add("SUBJ");
|
---|
| 124 | subject1.setContextConductionInd(false);
|
---|
| 125 |
|
---|
| 126 | subject1.setRegistrationEvent(createPRPAIN201310UVMFMIMT700711UV01RegistrationEvent(patient201304, localDeviceId, queryParam));
|
---|
| 127 |
|
---|
| 128 | return subject1;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | private static PRPAIN201310UVMFMIMT700711UV01RegistrationEvent createPRPAIN201310UVMFMIMT700711UV01RegistrationEvent(PRPAMT201304UVPatient patient201304, String localDeviceId, PRPAMT201307UVQueryByParameter queryParam) {
|
---|
| 132 | PRPAIN201310UVMFMIMT700711UV01RegistrationEvent regevent = new PRPAIN201310UVMFMIMT700711UV01RegistrationEvent();
|
---|
| 133 |
|
---|
| 134 | regevent.getClassCode().add(REG_EVENT_CLASS_CODE);
|
---|
| 135 | regevent.getMoodCode().add(REG_EVENT_MOOD_CODE);
|
---|
| 136 |
|
---|
| 137 | II regId = new II();
|
---|
| 138 | regId.getNullFlavor().add(HL7Constants.NULL_FLAVOR);
|
---|
| 139 | regevent.getId().add(regId);
|
---|
| 140 |
|
---|
| 141 | regevent.setStatusCode(HL7DataTransformHelper.CSFactory(REG_EVENT_STATUS_CODE));
|
---|
| 142 |
|
---|
| 143 | regevent.setSubject1(createPRPAIN201310UVMFMIMT700711UV01Subject2(patient201304, queryParam));
|
---|
| 144 |
|
---|
| 145 | regevent.setCustodian(HL7CustodianTransforms.createMFMIMT700711UV01Custodian(localDeviceId));
|
---|
| 146 |
|
---|
| 147 | return regevent;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | private static PRPAIN201310UVMFMIMT700711UV01Subject2 createPRPAIN201310UVMFMIMT700711UV01Subject2(PRPAMT201304UVPatient patient201304, PRPAMT201307UVQueryByParameter queryParam) {
|
---|
| 151 | PRPAIN201310UVMFMIMT700711UV01Subject2 subject = new PRPAIN201310UVMFMIMT700711UV01Subject2();
|
---|
| 152 |
|
---|
| 153 | subject.setPatient(patient201304);
|
---|
| 154 | if (queryParam != null) {
|
---|
| 155 | subject.setQueryByParameter(queryParam);
|
---|
| 156 | } else {
|
---|
| 157 | subject.setQueryByParameter(createNullQueryByParameter());
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | return subject;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | private static PRPAMT201307UVQueryByParameter createNullQueryByParameter() {
|
---|
| 164 | PRPAMT201307UVQueryByParameter params = new PRPAMT201307UVQueryByParameter();
|
---|
| 165 |
|
---|
| 166 | params.setQueryId(HL7MessageIdGenerator.GenerateHL7MessageId(null));
|
---|
| 167 | params.setStatusCode(HL7DataTransformHelper.CSFactory("new"));
|
---|
| 168 |
|
---|
| 169 | PRPAMT201307UVParameterList paramList = new PRPAMT201307UVParameterList();
|
---|
| 170 | params.setParameterList(paramList);
|
---|
| 171 | return params;
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | private static MFMIMT700711UV01QueryAck createMFMIMT700711UV01QueryAck(PRPAMT201307UVQueryByParameter queryParam) {
|
---|
| 175 | MFMIMT700711UV01QueryAck queryAck = new MFMIMT700711UV01QueryAck();
|
---|
| 176 |
|
---|
| 177 | if (queryParam != null) {
|
---|
| 178 | queryAck.setQueryId(queryParam.getQueryId());
|
---|
| 179 | }
|
---|
| 180 | queryAck.setQueryResponseCode(HL7DataTransformHelper.CSFactory(CONTROL_QUERY_RESPONSE_CODE));
|
---|
| 181 | return queryAck;
|
---|
| 182 | }
|
---|
| 183 | }
|
---|