Created
October 15, 2019 16:31
-
-
Save kbs5280/3efa04ec2848e3c1910299eab36c329d to your computer and use it in GitHub Desktop.
DoseSpotAPI_v12_2017_01_05.MedicationListItem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DoseSpotAPI_v12_2017_01_05.GetMedicationListResponse response = apisoap.getMedicationList(signon, DoseSpot_ID, sources, statuses); | |
response_package.json_response = JSON.serializePretty(response); | |
response_package.is_ok = (response.Result.ResultCode == 'OK') ? true : false; | |
System.debug('Response : ' + response); | |
if (response.Result.ResultCode == 'OK') { | |
Integer medication_count; | |
// Looks like the test on the next line fails in production for 'Philadelphia Test1' which is unexpected. Need to confirm it's using the correct DoseSpot Patient ID and that the API is returning values in 'response' as expected. | |
try { | |
System.debug('Response - Medications : ' + response.Medications); | |
System.debug('Response - Medications - MedicationListItem : ' + response.Medications.MedicationListItem); | |
} catch (exception e) {} | |
if (response.Medications != null && response.Medications.MedicationListItem != null) { | |
DoseSpotAPI_v12_2017_01_05.MedicationListItem[] DoseSpot_medications = response.Medications.MedicationListItem; | |
System.debug('DoseSpot Medications Size : ' + dosespot_medications.size()); | |
//System.debug('DoseSpot Medications : ' + dosespot_medications); | |
for(DoseSpotAPI_v12_2017_01_05.MedicationListItem med : DoseSpot_medications) { | |
System.debug('Dosespot MedId : ' + med.MedicationId + ' ' + med); | |
} | |
medication_count = DoseSpot_Medications.size(); | |
try {upsert_medication_list(DoseSpot_medications, patient_ID);} catch (DMLException error) {response_package.message = error.getMessage();} | |
} else {medication_count = 0;} | |
if (response_package.message == null) /* if upsert was successful */ | |
{response_package.message = medication_count + ((medication_count == 1) ? ' medication' : ' medications') + ' added/updated in patient\'s record.';} | |
} else {response_package.message = response.Result.ResultDescription;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment