use of org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindMedicationListQuery in project ipf by oehf.
the class FindMedicationListQueryTransformerTest method setUp.
@BeforeEach
public void setUp() {
transformer = new FindMedicationListQueryTransformer();
query = new FindMedicationListQuery();
query.setPatientId(new Identifiable("id1", new AssigningAuthority("uni1", "uniType1")));
query.setHomeCommunityId("12.21.41");
query.getServiceStart().setFrom("1982");
query.getServiceStart().setTo("1983");
query.getServiceEnd().setFrom("1984");
query.getServiceEnd().setTo("1985");
query.setStatus(Arrays.asList(AvailabilityStatus.APPROVED, AvailabilityStatus.SUBMITTED));
query.setFormatCodes(Arrays.asList(new Code("code13", null, "scheme13"), new Code("code14", null, "scheme14")));
query.setDocumentEntryTypes(Collections.singletonList(DocumentEntryType.STABLE));
ebXML = new EbXMLFactory30().createAdhocQueryRequest();
}
use of org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindMedicationListQuery in project ipf by oehf.
the class FindMedicationListQueryTransformerTest method testToEbXMLEmpty.
@Test
public void testToEbXMLEmpty() {
transformer.toEbXML(new FindMedicationListQuery(), ebXML);
assertEquals(0, ebXML.getSlots().size());
}
use of org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindMedicationListQuery in project ipf by oehf.
the class FindMedicationListQueryTransformerTest method testFromEbXMLNull.
@Test
public void testFromEbXMLNull() {
var result = new FindMedicationListQuery();
transformer.fromEbXML(result, null);
assertEquals(new FindMedicationListQuery(), result);
}
use of org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindMedicationListQuery in project ipf by oehf.
the class FindMedicationListQueryTransformerTest method testFromEbXMLEmpty.
@Test
public void testFromEbXMLEmpty() {
var result = new FindMedicationListQuery();
transformer.fromEbXML(result, ebXML);
assertEquals(new FindMedicationListQuery(), result);
}
use of org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindMedicationListQuery in project MobileAccessGateway by i4mi.
the class Pharm5RequestConverter method operationFindMedicationListToFindMedicationListQuery.
/**
* convert PHARM-5 request to CMPD Pharm-1
*
* @param searchParameter
* @return
*/
public QueryRegistry operationFindMedicationListToFindMedicationListQuery(@Body Parameters searchParameter) {
boolean getLeafClass = true;
FindMedicationListQuery query = new FindMedicationListQuery();
// status --> $XDSDocumentEntryStatus
List<Type> statusTypes = searchParameter.getParameters(Pharm5Constants.PHARM5_STATUS);
if (statusTypes != null) {
List<AvailabilityStatus> availabilites = new ArrayList<AvailabilityStatus>();
for (Type status : statusTypes) {
String tokenValue = status.primitiveValue();
if (tokenValue.equals("current"))
availabilites.add(AvailabilityStatus.APPROVED);
else if (tokenValue.equals("superseded"))
availabilites.add(AvailabilityStatus.DEPRECATED);
}
query.setStatus(availabilites);
}
// patient or patient.identifier --> $XDSDocumentEntryPatientId
Type patientIdentifier = searchParameter.getParameter(Pharm5Constants.PHARM5_PATIENT_IDENTIFIER);
if (patientIdentifier != null) {
Identifier patIdentifier = (Identifier) patientIdentifier;
String system = patIdentifier.getSystem();
if (system == null || !system.startsWith("urn:oid:"))
throw new InvalidRequestException("Missing OID for patient");
query.setPatientId(new Identifiable(patIdentifier.getValue(), new AssigningAuthority(system.substring(8))));
}
// patient or patient.identifier --> $XDSDocumentEntryPatientId
Type serviceStartFrom = searchParameter.getParameter(Pharm5Constants.PHARM5_SERVICE_START_FROM);
if (serviceStartFrom != null) {
query.getServiceStart().setFrom(timestampFromDate(serviceStartFrom));
}
Type serviceStartTo = searchParameter.getParameter(Pharm5Constants.PHARM5_SERVICE_START_TO);
if (serviceStartTo != null) {
query.getServiceStart().setTo(timestampFromDate(serviceStartTo));
}
Type serviceEndFrom = searchParameter.getParameter(Pharm5Constants.PHARM5_SERVICE_END_FROM);
if (serviceEndFrom != null) {
query.getServiceEnd().setFrom(timestampFromDate(serviceEndFrom));
}
Type serviceEndTo = searchParameter.getParameter(Pharm5Constants.PHARM5_SERVICE_END_TO);
if (serviceEndTo != null) {
query.getServiceEnd().setTo(timestampFromDate(serviceEndTo));
}
List<Type> formatTypes = searchParameter.getParameters(Pharm5Constants.PHARM5_FORMAT);
if (formatTypes != null && formatTypes.size() > 0) {
List<Code> formatCodes = new ArrayList<Code>();
for (Type format : formatTypes) {
Coding formatCoding = (Coding) format;
Code formatCode = new Code();
formatCode.setCode(formatCoding.getCode());
String system = formatCoding.getSystem();
if (system.startsWith("urn:oid:")) {
system = system.substring(8);
}
formatCode.setSchemeName(system);
formatCodes.add(formatCode);
}
query.setFormatCodes(formatCodes);
}
List<DocumentEntryType> documentEntryTypes = new ArrayList<DocumentEntryType>();
documentEntryTypes.add(DocumentEntryType.ON_DEMAND);
documentEntryTypes.add(DocumentEntryType.STABLE);
query.setDocumentEntryTypes(documentEntryTypes);
final QueryRegistry queryRegistry = new QueryRegistry(query);
queryRegistry.setReturnType((getLeafClass) ? QueryReturnType.LEAF_CLASS : QueryReturnType.OBJECT_REF);
return queryRegistry;
}
Aggregations