Java Code Examples for com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient#withRegion()

The following examples show how to use com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient#withRegion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MCAWS.java    From aws-big-data-blog with Apache License 2.0 5 votes vote down vote up
public static void dynamoInsertHl7Json(String hl7Json, String mirthTable, String mirthId, String mirthDate) {
String firstName = "NONE";
       String lastName = "NONE";
       String dob = "NONE";
       String docType = "hl7";
String messageType = "NONE";

       AmazonDynamoDBClient client = new AmazonDynamoDBClient();
       client.withRegion(Regions.US_WEST_2);
       DynamoDB dynamoDB = new DynamoDB(client);
       Table table = dynamoDB.getTable(mirthTable);
       try {
       JSONObject obj = new JSONObject(hl7Json);

firstName = obj.getJSONObject("HL7Message").getJSONObject("PID").getJSONObject("PID.5").getString("PID.5.2");
lastName = obj.getJSONObject("HL7Message").getJSONObject("PID").getJSONObject("PID.5").getString("PID.5.1");
dob = obj.getJSONObject("HL7Message").getJSONObject("PID").getJSONObject("PID.7").getString("PID.7.1");
messageType = obj.getJSONObject("HL7Message").getJSONObject("MSH").getJSONObject("MSH.9").getString("MSH.9.1");
       } catch (org.json.JSONException e) { System.out.println("HL7 JSON ERROR"); }        

//replace empyty string with value representing blank
       hl7Json = hl7Json.replaceAll("\"\"","\"NONE\"");

       Item item =
           new Item()
               .withPrimaryKey("mirthid", mirthId)
               .withString("mirthdate", mirthDate)
               .withString("type", docType)
               .withString("FirstName", firstName)
               .withString("LastName", lastName)
               .withString("DOB", dob)
               .withString("HL7Type", messageType)
               .withString("Processed", "N")
               .withJSON("document", hl7Json);

       table.putItem(item);
   }
 
Example 2
Source File: MCAWS.java    From aws-big-data-blog with Apache License 2.0 5 votes vote down vote up
public static void dynamoInsertJson(String ccdJson, String mirthTable, String mirthId, String mirthDate) {
       System.out.println( "Performing insert into DynamoDB" );
String firstName = "NONE";
String lastName = "NONE";
String dob = "NONE";
String docType = "ccda";

       AmazonDynamoDBClient client = new AmazonDynamoDBClient();
       client.withRegion(Regions.US_WEST_2);
       DynamoDB dynamoDB = new DynamoDB(client);
       Table table = dynamoDB.getTable(mirthTable);

//System.out.println(ccdJson);

       try {
       JSONObject obj = new JSONObject(ccdJson);

       firstName = obj.getJSONObject("data").getJSONObject("demographics").getJSONObject("name").getString("first");
       lastName = obj.getJSONObject("data").getJSONObject("demographics").getJSONObject("name").getString("last");
       dob = obj.getJSONObject("data").getJSONObject("demographics").getJSONObject("dob").getJSONObject("point").getString("date");

       //System.out.println(firstName);
       } catch (org.json.JSONException e) { System.out.println("JSON ERROR"); }

ccdJson = ccdJson.replaceAll("\"\"","\"NONE\"");

       Item item = 
           new Item()
               .withPrimaryKey("mirthid", mirthId)
               .withString("mirthdate", mirthDate)
	.withString("type", docType)
               .withString("FirstName", firstName)
               .withString("LastName", lastName)
               .withString("DOB", dob)
               .withString("Processed", "N")
               .withJSON("document", ccdJson);

       table.putItem(item);
   }
 
Example 3
Source File: MCAWS.java    From aws-big-data-blog with Apache License 2.0 4 votes vote down vote up
public static void dynamoInsertDicom(String dicomJson, String mirthTable, String mirthId, String mirthDate) {
       System.out.println( "Performing insert into DynamoDB" );
       String firstName = "EMPTY";
       String lastName = "EMPTY";
       String dob = "EMPTY";
       String docType = "dicom";

       AmazonDynamoDBClient client = new AmazonDynamoDBClient();
       client.withRegion(Regions.US_WEST_2);
       DynamoDB dynamoDB = new DynamoDB(client);
       Table table = dynamoDB.getTable(mirthTable);

       try {
       JSONObject obj = new JSONObject(dicomJson);

//DICOM stores patient name in tag 00100010
       if(obj.has("00100010")) {
               if(obj.getJSONObject("00100010").has("Value")) {
                       JSONArray lastNameArray = obj.getJSONObject("00100010").getJSONArray("Value");
                       if(lastNameArray !=null) {
                               JSONObject lastNameObj = lastNameArray.getJSONObject(0);
                               if(lastNameObj.has("Alphabetic")) {
                                       String patientName = lastNameObj.getString("Alphabetic");
                                       String[] patientNameArray = patientName.split("\\^");

				//some sample DICOM files only have one name string rather than 
				//delimited strings like in production messages.
				//in that case, we use that string as the last name
				//the else statement covers when we have a first and last name
                                       if(patientNameArray.length == 1) {
                                               lastName = lastNameObj.getString("Alphabetic");
                                       } else if(patientNameArray.length > 1) {
                                               lastName = patientNameArray[0];
                                               firstName = patientNameArray[1];
                                               }
                                       }
                               }
                       }
               }

//DICOM stores Date of Birth in tag 00100030
       if(obj.has("00100030")) {
               if(obj.getJSONObject("00100030").has("Value")) {
                       JSONArray dobArray = obj.getJSONObject("00100030").getJSONArray("Value");
                       if(dobArray !=null) {
			dob = dobArray.getString(0);
                               }
                       }
               }

       } catch (org.json.JSONException e) { System.out.println("JSON ERROR"); }

       //ccdJson = ccdJson.replaceAll("\"\"","\"NONE\"");

       Item item =
           new Item()
               .withPrimaryKey("mirthid", mirthId)
               .withString("mirthdate", mirthDate)
               .withString("type", docType)
               .withString("FirstName", firstName)
               .withString("LastName", lastName)
               .withString("DOB", dob)
               .withString("Processed", "N")
               .withJSON("document", dicomJson);

       table.putItem(item);
   }