Search in sources :

Example 1 with AvailabilityStatus

use of org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus in project MobileAccessGateway by i4mi.

the class Iti67RequestConverter method searchParameterIti67ToFindDocumentsQuery.

/**
 * convert ITI-67 request to ITI-18 request
 * @param searchParameter
 * @return
 */
public QueryRegistry searchParameterIti67ToFindDocumentsQuery(@Body Iti67SearchParameters searchParameter) {
    boolean getLeafClass = true;
    Query searchQuery = null;
    if (searchParameter.get_id() != null || searchParameter.getIdentifier() != null) {
        GetDocumentsQuery query = new GetDocumentsQuery();
        if (searchParameter.getIdentifier() != null) {
            String val = searchParameter.getIdentifier().getValue();
            if (val.startsWith("urn:oid:")) {
                query.setUniqueIds(Collections.singletonList(val.substring("urn:oid:".length())));
            } else if (val.startsWith("urn:uuid:")) {
                query.setUuids(Collections.singletonList(val.substring("urn:uuid:".length())));
            }
        } else {
            query.setUuids(Collections.singletonList(searchParameter.get_id().getValue()));
        }
        searchQuery = query;
    } else {
        FindDocumentsQuery query;
        // TODO   related Note 4                  -->  $XDSDocumentEntryReferenceIdList
        TokenOrListParam related = searchParameter.getRelated();
        if (related != null) {
            FindDocumentsByReferenceIdQuery referenceIdQuery = new FindDocumentsByReferenceIdQuery();
            ;
            QueryList<ReferenceId> outerReferences = new QueryList<ReferenceId>();
            List<ReferenceId> references = new ArrayList<ReferenceId>();
            for (TokenParam token : related.getValuesAsQueryTokens()) {
                references.add(new ReferenceId(token.getValue(), null, getScheme(token.getSystem())));
            }
            outerReferences.getOuterList().add(references);
            referenceIdQuery.setTypedReferenceIds(outerReferences);
            query = referenceIdQuery;
        } else
            query = new FindDocumentsQuery();
        // query.setMetadataLevel(metadataLevel);
        // status  -->  $XDSDocumentEntryStatus
        TokenOrListParam status = searchParameter.getStatus();
        if (status != null) {
            List<AvailabilityStatus> availabilites = new ArrayList<AvailabilityStatus>();
            for (TokenParam statusToken : status.getValuesAsQueryTokens()) {
                String tokenValue = statusToken.getValue();
                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
        TokenParam tokenIdentifier = searchParameter.getPatientIdentifier();
        if (tokenIdentifier != null) {
            String system = getScheme(tokenIdentifier.getSystem());
            if (system == null)
                throw new InvalidRequestException("Missing OID for patient");
            query.setPatientId(new Identifiable(tokenIdentifier.getValue(), new AssigningAuthority(system)));
        }
        ReferenceParam patientRef = searchParameter.getPatientReference();
        if (patientRef != null) {
            Identifiable id = transformReference(patientRef.getValue());
            query.setPatientId(id);
        }
        // date Note 1 Note 5              -->  $DSDocumentEntryCreationTimeFrom
        // date Note 2 Note 5              -->  $XDSDocumentEntryCreationTimeTo
        DateRangeParam dateRange = searchParameter.getDate();
        if (dateRange != null) {
            DateParam creationTimeFrom = dateRange.getLowerBound();
            DateParam creationTimeTo = dateRange.getUpperBound();
            query.getCreationTime().setFrom(timestampFromDateParam(creationTimeFrom));
            query.getCreationTime().setTo(timestampFromDateParam(creationTimeTo));
        }
        // period Note 1                   -->  $XDSDocumentEntryServiceStartTimeFrom
        // period Note 2                   -->  $XDSDocumentEntryServiceStartTimeTo
        // period Note 1                   -->  $XDSDocumentEntryServiceStopTimeFrom
        // period Note 2                   -->  $XDSDocumentEntryServiceStopTimeTo
        DateRangeParam periodRange = searchParameter.getPeriod();
        if (periodRange != null) {
            DateParam periodFrom = periodRange.getLowerBound();
            DateParam periodTo = periodRange.getUpperBound();
            query.getServiceStopTime().setFrom(timestampFromDateParam(periodFrom));
            query.getServiceStartTime().setTo(timestampFromDateParam(periodTo));
        }
        // category                        -->  $XDSDocumentEntryClassCode
        TokenOrListParam categories = searchParameter.getCategory();
        query.setClassCodes(codesFromTokens(categories));
        // type                            -->  $XDSDocumentEntryTypeCode
        TokenOrListParam types = searchParameter.getType();
        query.setTypeCodes(codesFromTokens(types));
        // setting                         -->  $XDSDocumentEntryPracticeSettingCode
        TokenOrListParam settings = searchParameter.getSetting();
        query.setPracticeSettingCodes(codesFromTokens(settings));
        // facility                        -->  $XDSDocumentEntryHealthcareFacilityTypeCode
        TokenOrListParam facilities = searchParameter.getFacility();
        query.setHealthcareFacilityTypeCodes(codesFromTokens(facilities));
        // event                           -->  $XDSDocumentEntryEventCodeList
        TokenOrListParam events = searchParameter.getEvent();
        if (events != null) {
            QueryList<Code> eventCodeList = new QueryList<Code>();
            eventCodeList.getOuterList().add(codesFromTokens(events));
            query.setEventCodes(eventCodeList);
        }
        // security-label                  -->  $XDSDocumentEntryConfidentialityCode
        TokenOrListParam securityLabels = searchParameter.getSecurityLabel();
        if (securityLabels != null) {
            QueryList<Code> confidentialityCodes = new QueryList<Code>();
            confidentialityCodes.getOuterList().add(codesFromTokens(securityLabels));
            query.setConfidentialityCodes(confidentialityCodes);
        }
        // format                          -->  $XDSDocumentEntryFormatCode
        TokenOrListParam formats = searchParameter.getFormat();
        query.setFormatCodes(codesFromTokens(formats));
        // TODO   author.given / author.family    -->  $XDSDocumentEntryAuthorPerson
        StringParam authorGivenName = searchParameter.getAuthorGivenName();
        StringParam authorFamilyName = searchParameter.getAuthorFamilyName();
        if (authorGivenName != null || authorFamilyName != null) {
            Person person = new Person();
            XcnName name = new XcnName();
            if (authorFamilyName != null)
                name.setFamilyName(authorFamilyName.getValue());
            if (authorGivenName != null)
                name.setGivenName(authorGivenName.getValue());
            person.setName(name);
            // String author = (authorGivenName != null ? authorGivenName.getValue() : "%")+" "+(authorFamilyName != null ? authorFamilyName.getValue() : "%");
            List<Person> authorPersons = Collections.singletonList(person);
            query.setTypedAuthorPersons(authorPersons);
        }
        searchQuery = query;
    }
    final QueryRegistry queryRegistry = new QueryRegistry(searchQuery);
    queryRegistry.setReturnType((getLeafClass) ? QueryReturnType.LEAF_CLASS : QueryReturnType.OBJECT_REF);
    return queryRegistry;
}
Also used : FindDocumentsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsQuery) FindDocumentsByReferenceIdQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsByReferenceIdQuery) Query(org.openehealth.ipf.commons.ihe.xds.core.requests.query.Query) GetDocumentsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetDocumentsQuery) ArrayList(java.util.ArrayList) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FindDocumentsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsQuery) GetDocumentsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetDocumentsQuery) ReferenceId(org.openehealth.ipf.commons.ihe.xds.core.metadata.ReferenceId) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) StringParam(ca.uhn.fhir.rest.param.StringParam) QueryList(org.openehealth.ipf.commons.ihe.xds.core.requests.query.QueryList) DateParam(ca.uhn.fhir.rest.param.DateParam) QueryRegistry(org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry) FindDocumentsByReferenceIdQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsByReferenceIdQuery) XcnName(org.openehealth.ipf.commons.ihe.xds.core.metadata.XcnName) AssigningAuthority(org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority) Code(org.openehealth.ipf.commons.ihe.xds.core.metadata.Code) Identifiable(org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) AvailabilityStatus(org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus) TokenParam(ca.uhn.fhir.rest.param.TokenParam) Person(org.openehealth.ipf.commons.ihe.xds.core.metadata.Person)

Example 2 with AvailabilityStatus

use of org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus in project MobileAccessGateway by i4mi.

the class Iti66RequestConverter method searchParameterIti66ToFindSubmissionSetsQuery.

/**
 * convert ITI-66 request to ITI-18 request
 * @param searchParameter
 * @return
 */
public QueryRegistry searchParameterIti66ToFindSubmissionSetsQuery(@Body Iti66SearchParameters searchParameter) {
    boolean getLeafClass = true;
    Query searchQuery = null;
    if (searchParameter.getIdentifier() != null || searchParameter.get_id() != null) {
        final GetSubmissionSetAndContentsQuery query = new GetSubmissionSetAndContentsQuery();
        if (searchParameter.getIdentifier() != null) {
            String val = searchParameter.getIdentifier().getValue();
            if (val.startsWith("urn:oid:")) {
                query.setUniqueId(val.substring("urn:oid:".length()));
            } else if (val.startsWith("urn:uuid:")) {
                query.setUuid(val.substring("urn:uuid:".length()));
            }
        } else {
            query.setUuid(searchParameter.get_id().getValue());
        }
        searchQuery = query;
    } else {
        final FindSubmissionSetsQuery query = new FindSubmissionSetsQuery();
        if (searchParameter.getCode() != null && !searchParameter.getCode().getValue().equals("submissionset")) {
            throw new InvalidRequestException("Only search for submissionsets supported.");
        }
        // patient or patient.identifier -> $XDSSubmissionSetPatientId
        TokenParam tokenIdentifier = searchParameter.getPatientIdentifier();
        if (tokenIdentifier != null) {
            String system = getScheme(tokenIdentifier.getSystem());
            if (system == null)
                throw new InvalidRequestException("Missing OID for patient");
            /*if (system.startsWith("urn:oid:")) {
	                 system = system.substring(8);
	             }*/
            query.setPatientId(new Identifiable(tokenIdentifier.getValue(), new AssigningAuthority(system)));
        }
        ReferenceParam patientRef = searchParameter.getPatientReference();
        if (patientRef != null) {
            Identifiable id = transformReference(patientRef.getValue());
            query.setPatientId(id);
        }
        // created Note 1 -> $XDSSubmissionSetSubmissionTimeFrom
        // created Note 2 -> $XDSSubmissionSetSubmissionTimeTo
        DateRangeParam createdRange = searchParameter.getDate();
        if (createdRange != null) {
            DateParam creationTimeFrom = createdRange.getLowerBound();
            DateParam creationTimeTo = createdRange.getUpperBound();
            query.getSubmissionTime().setFrom(timestampFromDateParam(creationTimeFrom));
            query.getSubmissionTime().setTo(timestampFromDateParam(creationTimeTo));
        }
        // TODO author.given / author.family -> $XDSSubmissionSetAuthorPerson
        StringParam authorGivenName = searchParameter.getSourceGiven();
        StringParam authorFamilyName = searchParameter.getSourceFamily();
        if (authorGivenName != null || authorFamilyName != null) {
            String author = (authorGivenName != null ? authorGivenName.getValue() : "%") + " " + (authorFamilyName != null ? authorFamilyName.getValue() : "%");
            query.setAuthorPerson(author);
        }
        // type -> $XDSSubmissionSetContentType
        TokenOrListParam types = searchParameter.getDesignationType();
        query.setContentTypeCodes(codesFromTokens(types));
        // source -> $XDSSubmissionSetSourceId
        TokenOrListParam sources = searchParameter.getSourceId();
        query.setSourceIds(urisFromTokens(sources));
        // status -> $XDSSubmissionSetStatus
        TokenOrListParam status = searchParameter.getStatus();
        if (status != null) {
            List<AvailabilityStatus> availabilites = new ArrayList<AvailabilityStatus>();
            for (TokenParam statusToken : status.getValuesAsQueryTokens()) {
                String tokenValue = statusToken.getValue();
                if (tokenValue.equals("current"))
                    availabilites.add(AvailabilityStatus.APPROVED);
                else if (tokenValue.equals("superseded"))
                    availabilites.add(AvailabilityStatus.DEPRECATED);
            }
            query.setStatus(availabilites);
        }
        searchQuery = query;
    }
    final QueryRegistry queryRegistry = new QueryRegistry(searchQuery);
    queryRegistry.setReturnType((getLeafClass) ? QueryReturnType.LEAF_CLASS : QueryReturnType.OBJECT_REF);
    return queryRegistry;
}
Also used : GetSubmissionSetAndContentsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetSubmissionSetAndContentsQuery) Query(org.openehealth.ipf.commons.ihe.xds.core.requests.query.Query) FindSubmissionSetsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindSubmissionSetsQuery) QueryRegistry(org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry) ArrayList(java.util.ArrayList) FindSubmissionSetsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindSubmissionSetsQuery) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) AssigningAuthority(org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority) Identifiable(org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) AvailabilityStatus(org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus) TokenParam(ca.uhn.fhir.rest.param.TokenParam) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) StringParam(ca.uhn.fhir.rest.param.StringParam) GetSubmissionSetAndContentsQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetSubmissionSetAndContentsQuery) DateParam(ca.uhn.fhir.rest.param.DateParam)

Example 3 with AvailabilityStatus

use of org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus 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;
}
Also used : QueryRegistry(org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry) FindMedicationListQuery(org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindMedicationListQuery) ArrayList(java.util.ArrayList) AssigningAuthority(org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority) Code(org.openehealth.ipf.commons.ihe.xds.core.metadata.Code) Identifiable(org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable) DocumentEntryType(org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntryType) Type(org.hl7.fhir.r4.model.Type) DocumentEntryType(org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntryType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) QueryReturnType(org.openehealth.ipf.commons.ihe.xds.core.requests.query.QueryReturnType) Identifier(org.hl7.fhir.r4.model.Identifier) AvailabilityStatus(org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus) Coding(org.hl7.fhir.r4.model.Coding) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)

Aggregations

InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)3 ArrayList (java.util.ArrayList)3 AssigningAuthority (org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority)3 AvailabilityStatus (org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus)3 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)3 QueryRegistry (org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry)3 DateParam (ca.uhn.fhir.rest.param.DateParam)2 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)2 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)2 StringParam (ca.uhn.fhir.rest.param.StringParam)2 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)2 TokenParam (ca.uhn.fhir.rest.param.TokenParam)2 Code (org.openehealth.ipf.commons.ihe.xds.core.metadata.Code)2 Query (org.openehealth.ipf.commons.ihe.xds.core.requests.query.Query)2 Coding (org.hl7.fhir.r4.model.Coding)1 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 Type (org.hl7.fhir.r4.model.Type)1 DocumentEntryType (org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntryType)1 Person (org.openehealth.ipf.commons.ihe.xds.core.metadata.Person)1