src/main/java/ch/bfh/ti/i4mi/mag/mhd/iti65/Iti65RequestConverter.java
/**
	 * FHIR Reference -> XDS Identifiable
	 * Only for References to Patients or Encounters
	 * Identifier is extracted from contained resource or from Reference URL
	 * @param reference
	 * @param container
	 * @return
	 */
FHIR Reference -> XDS Identifiable
Only for References to Patients or Encounters
Identifier is extracted from contained resource or from Reference URL
@param reference
@param container
@return
FHIR Reference - > XDS Identifiable Only for References to Patients or Encounters Identifier is extracted from contained resource or from Reference URL @param reference @param container @return
public  Identifiable transformReferenceToIdentifiable(Reference reference, DomainResource container) {
		if (reference.hasReference()) {
			String targetRef = reference.getReference();		
			List<Resource> resources = container.getContained();		
			for (Resource resource : resources) {			
				if (targetRef.equals(resource.getId())) {
					if (resource instanceof Patient) {
					  return transform(((Patient) resource).getIdentifierFirstRep());
					} else if (resource instanceof Encounter) {
						return transform(((Encounter) resource).getIdentifierFirstRep());
					}
				}
			}
			Identifiable result = patientRefCreator.resolvePatientReference(reference.getReference());
			if (result != null) return result;
			MultiValueMap<String, String> vals = UriComponentsBuilder.fromUriString(targetRef).build().getQueryParams();
			if (vals.containsKey("identifier")) {
				String ids = vals.getFirst("identifier");
				if (ids == null) return null;
				String[] identifier = ids.split("\\|");
				if (identifier.length == 2) {
					return new Identifiable(identifier[1], new AssigningAuthority(noPrefix(identifier[0])));
				}
			}
		} else if (reference.hasIdentifier()) {					
	        return transform(reference.getIdentifier());
		} 
		throw new InvalidRequestException("Cannot resolve reference");
	}
public Identifiable transformReferenceToIdentifiable ( Reference reference , DomainResource container ) { if ( reference . hasReference ( ) ) { String targetRef = reference . getReference ( ) ; List < Resource > resources = container . getContained ( ) ; for ( Resource resource : resources ) { if ( targetRef . equals ( resource . getId ( ) ) ) { if ( resource instanceof Patient ) { return transform ( ( ( Patient ) resource ) . getIdentifierFirstRep ( ) ) ; } else if ( resource instanceof Encounter ) { return transform ( ( ( Encounter ) resource ) . getIdentifierFirstRep ( ) ) ; } } } Identifiable result = patientRefCreator . resolvePatientReference ( reference . getReference ( ) ) ; if ( result != null ) return result ; MultiValueMap < String , String > vals = UriComponentsBuilder . fromUriString ( targetRef ) . build ( ) . getQueryParams ( ) ; if ( vals . containsKey ( "identifier" ) ) { String ids = vals . getFirst ( "identifier" ) ; if ( ids == null ) return null ; String [ ] identifier = ids . split ( "\\|" ) ; if ( identifier . length == 2 ) { return new Identifiable ( identifier [ 1 ] , new AssigningAuthority ( noPrefix ( identifier [ 0 ] ) ) ) ; } } } else if ( reference . hasIdentifier ( ) ) { return transform ( reference . getIdentifier ( ) ) ; } throw new InvalidRequestException ( "Cannot resolve reference" ) ; }
FHIR Reference -> XDS Identifiable
 Only for References to Patients or Encounters
 Identifier is extracted from contained resource or from Reference URL
 @param reference
 @param container
 @return
FHIR Reference - > XDS Identifiable Only for References to Patients or Encounters Identifier is extracted from contained resource or from Reference URL @param reference @param container @return