public void readBundleFHIRPayload()

in src/com/amazonaws/lab/CMUtil.java [2308:2352]


	public void readBundleFHIRPayload(String fileName) {
		ClassLoader classLoader = getClass().getClassLoader();
		StringBuilder result = new StringBuilder("");
		File file = new File(classLoader.getResource(fileName).getFile()); 	
		try (Scanner scanner = new Scanner(file)) {

			while (scanner.hasNextLine()) {
				String line = scanner.nextLine();
				result.append(line).append("\n");
			}

			scanner.close();

		} catch (IOException e) {
			e.printStackTrace();
		}
		
		log.debug("The bundle : "+result.toString());
		Bundle bundle = 
				FhirContext.forDstu3().newJsonParser().parseResource(Bundle.class, result.toString());
		List<BundleEntryComponent> list = bundle.getEntry();
		
		String patientId = null;
		//Patient patient = null;
		String patientFullUrl = null;
		for(BundleEntryComponent entry : list) {
			
			String fhirType = entry.getResource().fhirType();
			//System.out.println(entry.getResource().fhirType());
			
			if(fhirType.equals(ResourceType.DOCUMENTREFERENCE.getDisplay())) {
				DocumentReference docRef = (DocumentReference)entry.getResource();
				log.debug("The document data "+docRef.getDescription());
				List<DocumentReferenceContentComponent> attList = docRef.getContent();
				for(DocumentReferenceContentComponent attach:attList) {
					byte[] notesBytes = attach.getAttachment().getData();
					log.debug("The provider clinical :"+new String(notesBytes));
				}
				
			}
		}


		
	}