use of net.ihe.gazelle.hl7v3.datatypes.TS in project ipf by oehf.
the class PixV3QueryRequestTransformer method toPrpa.
/**
* Transforms a simplified query into the full PRPA model.
*
* @param simpleQuery The simplified query to transform.
* @return the PRPA model query or {@code null} if the input was {@code null}.
*/
public PRPAIN201309UV02Type toPrpa(final PixV3QueryRequest simpleQuery) {
if (simpleQuery == null) {
return null;
}
// Prepare query with fixed values
final PRPAIN201309UV02Type query = new PRPAIN201309UV02Type();
query.setITSVersion("XML_1.0");
query.setInteractionId(new II("2.16.840.1.113883.1.6", "PRPA_IN201309UV02"));
query.setProcessingCode(new CS("P", null, null));
query.setProcessingModeCode(new CS("T", null, null));
query.setAcceptAckCode(new CS("AL", null, null));
final PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlActProcess = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess();
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201309UV02", null, null));
query.setControlActProcess(controlActProcess);
final PRPAMT201307UV02QueryByParameter queryByParameter = new PRPAMT201307UV02QueryByParameter();
queryByParameter.setStatusCode(new CS("new", null, null));
queryByParameter.setResponsePriorityCode(new CS("I", null, null));
queryByParameter.setParameterList(new PRPAMT201307UV02ParameterList());
controlActProcess.setQueryByParameter(queryByParameter);
// Fill query with given data
query.setCreationTime(new TS());
query.getCreationTime().setValue(HL7DTM.toSimpleString(simpleQuery.getCreationTime()));
query.setId(simpleQuery.getMessageId());
query.setReceiver(List.of(this.toReceiver(simpleQuery.getReceiver())));
query.setSender(this.toSender(simpleQuery.getSender()));
queryByParameter.setQueryId(simpleQuery.getQueryId());
final PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier();
patientIdentifier.setValue(List.of(simpleQuery.getQueryPatientId()));
patientIdentifier.setSemanticsText(new ST());
patientIdentifier.getSemanticsText().mixed = List.of("Patient.id");
queryByParameter.getParameterList().setPatientIdentifier(List.of(patientIdentifier));
for (final String dataSourceOid : simpleQuery.getDataSourceOids()) {
final PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource();
dataSource.setValue(List.of(new II(dataSourceOid, null)));
dataSource.setSemanticsText(new ST());
dataSource.getSemanticsText().mixed = List.of("DataSource.id");
queryByParameter.getParameterList().getDataSource().add(dataSource);
}
return query;
}
use of net.ihe.gazelle.hl7v3.datatypes.TS in project MobileAccessGateway by i4mi.
the class Iti83RequestConverter method iti83ToIti45Converter.
public String iti83ToIti45Converter(Parameters parameters) throws JAXBException {
List<Type> targetSystemList = (List<Type>) parameters.getParameters("targetSystem");
Identifier sourceIdentifier = (Identifier) parameters.getParameter("sourceIdentifier");
PRPAIN201309UV02Type resultMsg = new PRPAIN201309UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201309UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlActProcess = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201309UV02", "2.16.840.1.113883.1.18", null));
PRPAMT201307UV02QueryByParameter queryByParameter = new PRPAMT201307UV02QueryByParameter();
controlActProcess.setQueryByParameter(queryByParameter);
queryByParameter.setQueryId(new II(config.getPixQueryOid(), uniqueId()));
queryByParameter.setStatusCode(new CS("new", null, null));
queryByParameter.setResponsePriorityCode(new CS("I", null, null));
PRPAMT201307UV02ParameterList parameterList = new PRPAMT201307UV02ParameterList();
queryByParameter.setParameterList(parameterList);
PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier();
parameterList.addPatientIdentifier(patientIdentifier);
String system = getScheme(sourceIdentifier.getSystem());
patientIdentifier.setValue(Collections.singletonList(new II(system, sourceIdentifier.getValue())));
patientIdentifier.setSemanticsText(ST("Patient.id"));
if (targetSystemList != null && (targetSystemList.size() > 0)) {
for (Type targetSystemType : targetSystemList) {
UriType targetSystem = (UriType) targetSystemType;
String sourceSystem = getScheme(targetSystem.getValue());
PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource();
parameterList.addDataSource(dataSource);
dataSource.setValue(Collections.singletonList(new II(sourceSystem, null, null)));
dataSource.setSemanticsText(ST("DataSource.id"));
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
log.debug("PRE CONVERT");
HL7V3Transformer.marshallMessage(PRPAIN201309UV02Type.class, out, resultMsg);
log.debug("POST CONVERT");
String outArray = new String(out.toByteArray());
log.debug(outArray);
return outArray;
}
use of net.ihe.gazelle.hl7v3.datatypes.TS in project MobileAccessGateway by i4mi.
the class Iti93AddRequestConverter method doCreate.
/**
* add a new patient
* @param header
* @param entriesByReference
* @return
* @throws JAXBException
*/
public String doCreate(MessageHeader header, Map<String, BundleEntryComponent> entriesByReference) throws JAXBException {
PRPAIN201301UV02Type resultMsg = new PRPAIN201301UV02Type();
resultMsg.setITSVersion("XML_1.0");
// String UUID.randomUUID().toString();
resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
// Now
resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
resultMsg.setProcessingCode(new CS("T", null, null));
resultMsg.setProcessingModeCode(new CS("T", null, null));
resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201301UV02"));
resultMsg.setAcceptAckCode(new CS("AL", null, null));
MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
resultMsg.addReceiver(receiver);
receiver.setTypeCode(CommunicationFunctionType.RCV);
MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
receiver.setDevice(receiverDevice);
receiverDevice.setClassCode(EntityClassDevice.DEV);
receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
resultMsg.setSender(sender);
sender.setTypeCode(CommunicationFunctionType.SND);
MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
sender.setDevice(senderDevice);
senderDevice.setClassCode(EntityClassDevice.DEV);
senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
PRPAIN201301UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201301UV02MFMIMT700701UV01ControlActProcess();
resultMsg.setControlActProcess(controlActProcess);
controlActProcess.setClassCode(ActClassControlAct.CACT);
controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
controlActProcess.setCode(new CD("PRPA_TE201301UV02", null, "2.16.840.1.113883.1.18"));
for (BundleEntryComponent entry : entriesByReference.values()) {
if (entry.getResource() instanceof Patient) {
HTTPVerb method = entry.getRequest().getMethod();
if (method == null)
throw new InvalidRequestException("HTTP verb missing in Bundle for Patient resource.");
Patient in = (Patient) entry.getResource();
PRPAIN201301UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201301UV02MFMIMT700701UV01Subject1();
controlActProcess.addSubject(subject);
subject.setTypeCode("SUBJ");
// ???
subject.setContextConductionInd(false);
PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent();
subject.setRegistrationEvent(registrationEvent);
registrationEvent.setClassCode(ActClass.REG);
registrationEvent.setMoodCode(ActMood.EVN);
// ???
registrationEvent.setStatusCode(new CS("active", null, null));
PRPAIN201301UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201301UV02MFMIMT700701UV01Subject2();
registrationEvent.setSubject1(subject1);
subject1.setTypeCode(ParticipationTargetSubject.SBJ);
PRPAMT201301UV02Patient patient = new PRPAMT201301UV02Patient();
subject1.setPatient(patient);
patient.setClassCode("PAT");
// ???
patient.setStatusCode(new CS("active", null, null));
PRPAMT201301UV02Person patientPerson = new PRPAMT201301UV02Person();
patient.setPatientPerson(patientPerson);
patientPerson.setClassCode(EntityClass.PSN);
patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
// TODO How is the correct mapping done?
for (Identifier id : in.getIdentifier()) {
patient.addId(patientIdentifier(id));
}
for (HumanName name : in.getName()) {
patientPerson.addName(transform(name));
}
patientPerson.setBirthTime(transform(in.getBirthDateElement()));
if (in.hasGender()) {
switch(in.getGender()) {
case MALE:
patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
break;
case FEMALE:
patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
break;
case OTHER:
patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
break;
case UNKNOWN:
patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
break;
}
}
if (in.hasAddress())
patientPerson.setAddr(new ArrayList<AD>());
for (Address address : in.getAddress()) {
patientPerson.addAddr(transform(address));
}
for (ContactPoint contactPoint : in.getTelecom()) {
patientPerson.addTelecom(transform(contactPoint));
}
List<II> orgIds = new ArrayList<II>();
Organization managingOrg = getManagingOrganization(in);
// NULL POINTER CHECK
for (Identifier id : managingOrg.getIdentifier()) {
orgIds.add(new II(getScheme(id.getSystem()), null));
}
if (in.hasDeceasedBooleanType()) {
patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
}
if (in.hasDeceasedDateTimeType()) {
patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
}
if (in.hasMultipleBirthBooleanType()) {
patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
}
if (in.hasMultipleBirthIntegerType()) {
patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
}
if (in.hasMaritalStatus()) {
patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
}
if (in.hasCommunication()) {
for (PatientCommunicationComponent pcc : in.getCommunication()) {
PRPAMT201301UV02LanguageCommunication languageCommunication = new PRPAMT201301UV02LanguageCommunication();
languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
// NULL POINTER EXCEPTION
if (pcc.hasPreferred())
languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
patientPerson.addLanguageCommunication(languageCommunication);
}
}
COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
patient.setProviderOrganization(providerOrganization);
providerOrganization.setClassCode(EntityClassOrganization.ORG);
providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
providerOrganization.setId(orgIds);
ON name = null;
if (managingOrg.hasName()) {
name = new ON();
name.setMixed(Collections.singletonList(managingOrg.getName()));
providerOrganization.setName(Collections.singletonList(name));
}
COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
contactParty.setClassCode(RoleClassContact.CON);
for (ContactPoint contactPoint : managingOrg.getTelecom()) {
contactParty.addTelecom(transform(contactPoint));
}
if (managingOrg.hasAddress())
contactParty.setAddr(new ArrayList<AD>());
for (Address address : managingOrg.getAddress()) {
contactParty.addAddr(transform(address));
}
if (managingOrg.hasContact()) {
OrganizationContactComponent occ = managingOrg.getContactFirstRep();
COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
contactPerson.setClassCode(EntityClass.PSN);
contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
if (occ.hasName())
contactPerson.setName(Collections.singletonList(transform(occ.getName())));
contactParty.setContactPerson(contactPerson);
}
providerOrganization.setContactParty(Collections.singletonList(contactParty));
MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
registrationEvent.setCustodian(custodian);
custodian.setTypeCode(ParticipationType.CST);
COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
custodian.setAssignedEntity(assignedEntity);
assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
List<II> custIds = new ArrayList<II>();
custIds.add(new II(getScheme(config.getCustodianOid()), null));
assignedEntity.setId(custIds);
// assignedEntity.setId(orgIds);
COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
assignedEntity.setAssignedOrganization(assignedOrganization);
assignedOrganization.setClassCode(EntityClassOrganization.ORG);
assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
if (managingOrg.hasName()) {
assignedOrganization.setName(Collections.singletonList(name));
}
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
HL7V3Transformer.marshallMessage(PRPAIN201301UV02Type.class, out, resultMsg);
String outArray = new String(out.toByteArray());
return outArray;
}
use of net.ihe.gazelle.hl7v3.datatypes.TS in project MobileAccessGateway by i4mi.
the class PMIRRequestConverter method transform.
public static TS transform(DateType date) {
if (date == null || !(date.hasValue()))
return null;
TS result = new TS();
result.setValue(date.getValueAsString().replace("-", ""));
return result;
}
use of net.ihe.gazelle.hl7v3.datatypes.TS in project MobileAccessGateway by i4mi.
the class Iti78ResponseConverter method translateToFhir.
public List<Patient> translateToFhir(byte[] input, Map<String, Object> parameters) {
try {
// FIX for xmlns:xmlns
String content = new String(input);
content = content.replace("xmlns:xmlns", "xmlns:xxxxx");
List<Patient> response = new ArrayList<Patient>();
PRPAIN201306UV02Type msg = HL7V3Transformer.unmarshallMessage(PRPAIN201306UV02Type.class, new ByteArrayInputStream(content.getBytes()));
PRPAIN201306UV02MFMIMT700711UV01ControlActProcess controlAct = msg.getControlActProcess();
List<MCCIMT000300UV01Acknowledgement> acks = msg.getAcknowledgement();
String errtext = "";
for (MCCIMT000300UV01Acknowledgement ack : acks) {
for (MCCIMT000300UV01AcknowledgementDetail ackDetail : ack.getAcknowledgementDetail()) {
if (ackDetail.getText() != null)
errtext += toText(ackDetail.getText());
}
}
// OK NF AE
String queryResponseCode = controlAct.getQueryAck().getQueryResponseCode().getCode();
if ("NF".equals(queryResponseCode)) {
throw new ResourceNotFoundException("sourceIdentifier Patient Identifier not found", error(IssueType.NOTFOUND, errtext.length() > 0 ? errtext : "sourceIdentifier Patient Identifier not found"));
}
if ("AE".equals(queryResponseCode)) {
throw new InvalidRequestException("sourceIdentifier Assigning Authority not found", error(IssueType.INVALID, errtext.length() > 0 ? errtext : "sourceIdentifier Assigning Authority not found"));
}
List<PRPAIN201306UV02MFMIMT700711UV01Subject1> subjects = controlAct.getSubject();
for (PRPAIN201306UV02MFMIMT700711UV01Subject1 subject : subjects) {
PRPAIN201306UV02MFMIMT700711UV01RegistrationEvent registrationEvent = subject.getRegistrationEvent();
PRPAIN201306UV02MFMIMT700711UV01Subject2 subject1 = registrationEvent.getSubject1();
PRPAMT201310UV02Patient patient = subject1.getPatient();
PRPAMT201310UV02Person patientPerson = patient.getPatientPerson();
if (patient.getId().isEmpty())
continue;
Patient result = new Patient();
boolean idadded = false;
for (II patientId : patient.getId()) {
result.addIdentifier().setSystem(getSystem(patientId.getRoot())).setValue(patientId.getExtension());
if (!idadded) {
result.setId(patientRefCreator.createPatientId(patientId.getRoot(), patientId.getExtension()));
idadded = true;
}
}
for (PRPAMT201310UV02OtherIDs otherIds : patient.getPatientPerson().getAsOtherIDs()) {
for (II patientId : otherIds.getId()) {
result.addIdentifier().setSystem(getSystem(patientId.getRoot())).setValue(patientId.getExtension());
}
}
CS statusCode = patient.getStatusCode();
if (statusCode != null && "active".equals(statusCode.getCode()))
result.setActive(true);
for (PN name : patientPerson.getName()) {
HumanName humanName = new HumanName();
for (EnFamily family : name.getFamily()) {
if ("BR".equals(family.getQualifier())) {
humanName.setUse(NameUse.MAIDEN);
}
humanName.setFamily(val(family));
}
for (EnGiven given : name.getGiven()) {
withQualifier(given, humanName.addGivenElement());
}
for (EnPrefix prefix : name.getPrefix()) {
withQualifier(prefix, humanName.addPrefixElement());
}
for (EnSuffix suffix : name.getSuffix()) {
withQualifier(suffix, humanName.addSuffixElement());
}
if (name.getValidTime() != null)
humanName.setPeriod(transform(name.getValidTime()));
result.addName(humanName);
}
CE gender = patientPerson.getAdministrativeGenderCode();
if (gender != null) {
switch(gender.getCode()) {
case "M":
result.setGender(AdministrativeGender.MALE);
break;
case "F":
result.setGender(AdministrativeGender.FEMALE);
break;
case "A":
result.setGender(AdministrativeGender.OTHER);
break;
case "U":
result.setGender(AdministrativeGender.UNKNOWN);
break;
}
}
TS birthTime = patientPerson.getBirthTime();
if (birthTime != null) {
result.setBirthDateElement(transform(birthTime));
}
for (AD ad : patientPerson.getAddr()) {
result.addAddress(transform(ad));
}
for (TEL tel : patientPerson.getTelecom()) {
result.addTelecom(transform(tel));
}
for (PRPAMT201310UV02LanguageCommunication lang : patientPerson.getLanguageCommunication()) {
CE langCode = lang.getLanguageCode();
PatientCommunicationComponent pcc = new PatientCommunicationComponent();
pcc.setLanguage(transform(langCode));
BL preferred = lang.getPreferenceInd();
if (preferred != null && preferred.getValue().booleanValue())
pcc.setPreferred(true);
result.addCommunication(pcc);
}
TS deceasedTime = patientPerson.getDeceasedTime();
if (deceasedTime != null)
result.setDeceased(transform(deceasedTime));
else {
BL deceased = patientPerson.getDeceasedInd();
if (deceased != null)
result.setDeceased(new BooleanType(deceased.getValue().booleanValue()));
}
INT multiBirthOrder = patientPerson.getMultipleBirthOrderNumber();
if (multiBirthOrder != null) {
result.setMultipleBirth(new IntegerType(multiBirthOrder.getValue()));
} else {
BL multipleBirth = patientPerson.getMultipleBirthInd();
if (multipleBirth != null)
result.setMultipleBirth(new BooleanType(multipleBirth.getValue().booleanValue()));
}
CE maritalStatus = patientPerson.getMaritalStatusCode();
result.setMaritalStatus(transform(maritalStatus));
for (PRPAMT201310UV02PersonalRelationship relationShip : patientPerson.getPersonalRelationship()) {
CE code = relationShip.getCode();
if (code != null && "MTH".equals(code.getCode()) && "2.16.840.1.113883.12.63".equals(code.getCodeSystem())) {
COCTMT030007UVPerson holder = relationShip.getRelationshipHolder1();
if (holder != null && !holder.getName().isEmpty()) {
EN name = holder.getName().get(0);
if (!name.getFamily().isEmpty()) {
String familyName = val(name.getFamily());
result.addExtension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", new StringType(familyName));
}
}
}
}
response.add(result);
}
return response;
} catch (JAXBException e) {
e.printStackTrace();
throw new InvalidRequestException("failed parsing response");
}
}
Aggregations