src/main/java/ch/bfh/ti/i4mi/mag/mhd/iti66/Iti66RequestConverter.java
/**
	  * convert ITI-66 request to ITI-18 request
	  * @param searchParameter
	  * @return
	  */
convert ITI-66 request to ITI-18 request
@param searchParameter
@return
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.");
	         }
	         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);
	         }
	         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));
	         }            
	         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);
	         }
	         TokenOrListParam types = searchParameter.getDesignationType();
	         query.setContentTypeCodes(codesFromTokens(types));
	         TokenOrListParam sources = searchParameter.getSourceId();
	         query.setSourceIds(urisFromTokens(sources));
	         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;
 }
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." ) ; } 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 ) ; } 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 ) ) ; } 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 ) ; } TokenOrListParam types = searchParameter . getDesignationType ( ) ; query . setContentTypeCodes ( codesFromTokens ( types ) ) ; TokenOrListParam sources = searchParameter . getSourceId ( ) ; query . setSourceIds ( urisFromTokens ( sources ) ) ; 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 ; }
convert ITI-66 request to ITI-18 request
 @param searchParameter
 @return
convert ITI - 66 request to ITI - 18 request @param searchParameter @return
// patient or patient.identifier -> $XDSSubmissionSetPatientId // created Note 1 -> $XDSSubmissionSetSubmissionTimeFrom // created Note 2 -> $XDSSubmissionSetSubmissionTimeTo  // TODO author.given / author.family -> $XDSSubmissionSetAuthorPerson // type -> $XDSSubmissionSetContentType // source -> $XDSSubmissionSetSourceId  // status -> $XDSSubmissionSetStatus 