Skip to content

Instantly share code, notes, and snippets.

@darrenjaworski
Last active February 11, 2020 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darrenjaworski/3aea2469ae4ac4042fae to your computer and use it in GitHub Desktop.
Save darrenjaworski/3aea2469ae4ac4042fae to your computer and use it in GitHub Desktop.
DocScores api and pagination
<?php
$orgSlug = "";
// this URL will differ for each physician profile
$jsonUrl = "http://www.docscores.com/widget/api/" . $orgSlug . "/npi/" . $pressganey . "/200";
$jsonStr = file_get_contents($jsonUrl);
$json = json_decode($jsonStr);
// get the profile
$reviews = $json->reviews;
$per_page = 10;
$pages = ceil(count($reviews) / $per_page);
$html = '';
foreach($reviews as $key=>$review) {
$body = $review->bodyForDisplay;
$date = $review->publishdate;
$date = date_create($date);
$current_page = ($key + 1) / $per_page;
if (ceil($current_page) == 1) {
$html .= '<article class="active page-'.ceil($current_page).'"><p>'.$body.'</p>';
} else {
$html .= '<article class="page-'.ceil($current_page).'"><p>'.$body.'</p>';
}
$html .= '<p><span>OU Medicine Patient</span> <span>'.date_format($date,"M n, Y").'</span></p></article>';
}
if ($pages > 1) {
$html .= '<div class="pagination"><ul><li class="active" data-page="1">Page 1</li><li data-page="2">2</li>';
if ($pages > 2) {
for ($x = 2; $x < $pages; $x++) {
$html .= '<li data-page="'.($x+1).'">'.($x+1).'</li>';
}
}
$html .='</div>';
}
return $html;
<?php
$orgSlug = "";
// this URL will differ for each physician profile
$jsonUrl = "http://www.docscores.com/widget/api/" . $orgSlug . "/npi/" . $pressganey . "/200";
$jsonStr = file_get_contents($jsonUrl);
$json = json_decode($jsonStr);
// get the profile
$profile = $json->profile;
// get the fields that are needed
$name = $profile->name;
$rating = $profile->averageRatingStr;
$starRating = $profile->averageStarRatingStr;
$ratingCount = $profile->reviewcount;
$commentCount = $profile->bodycount;
$html = '';
$html = '<span class="badge-rating">'.$rating.' / 5</span>';
$html .= '<span class="docscores-stars docscores-stars'.$starRating.'"></span>';
$html .= '<span class="badge-number">'.$ratingCount.' Ratings</span>';
$html .= '<span class="badge-comments">'.$commentCount.' Comments</span>';
return $html;
$('.pagination ul li').click(function(){
var page = $(this).data('page');
$('article').removeClass("active");
$('.page-' + page).addClass("active");
});
.pagination {
text-align: center;
ul {
&:before, &:after {
padding: 1em;
}
&:before {
content: "<<";
}
&:after {
content: ">>";
}
}
li {
margin: 0 .125em;
padding: 0 .125em;
cursor: pointer;
}
}
article {
display: none;
&.active {
display: block;
}
}
//widget
span.docscores-stars {
display: inline-block !important;
background: url(../images/sprites/star-ratings-sprite.png) 0 0 repeat-x;
width: 88px;
height: 16px;
}
span.docscores-stars {display: block; background: url(../images/sprites/star-ratings-sprite.png) 0 0 repeat-x; width: 88px; height: 16px; }
span.docscores-stars5 {background-position: 0 -160px;}
span.docscores-stars45 {background-position: 0 -144px;}
span.docscores-stars4 {background-position: 0 -128px;}
span.docscores-stars35 {background-position: 0 -112px;}
span.docscores-stars3 {background-position: 0 -96px;}
span.docscores-stars25 {background-position: 0 -80px;}
span.docscores-stars2 {background-position: 0 -64px;}
span.docscores-stars15 {background-position: 0 -48px;}
span.docscores-stars1 {background-position: 0 -32px;}
span.docscores-stars05 {background-position: 0 -16px;}
span.docscores-stars0 {background-position: 0 0px;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment