Index: trunk/BNC/src/ephemeris.cpp
===================================================================
--- trunk/BNC/src/ephemeris.cpp	(revision 10627)
+++ trunk/BNC/src/ephemeris.cpp	(revision 10628)
@@ -60,6 +60,7 @@
     bool useCorr) const {
 
-  if (_checkState == bad || _checkState == unhealthy
-      || _checkState == outdated) {
+  if (_checkState == bad ||
+      _checkState == unhealthy ||
+      _checkState == outdated) {
     return failure;
   }
@@ -1047,4 +1048,50 @@
 }
 
+// Health status of GPS Ephemeris (virtual)
+////////////////////////////////////////////////////////////////////////////
+unsigned int t_ephGPS::isUnhealthy() const {
+
+  switch (system()) {
+    case t_eph::GPS:
+    case t_eph::QZSS:
+      switch (type()) {
+        case  t_eph::LNAV:
+        case  t_eph::CNAV:
+        case  t_eph::CNV2:
+          if (_health == 0.0) {
+            return 0;
+          }
+          else {
+            return 1;
+          }
+          break;
+      }
+      break;
+    case t_eph::NavIC:
+      switch (type()) {
+        case t_eph::LNAV:
+          if (_health == 0.0) { // L1 & S healthy
+            return 0;
+          }
+          if (_health == 1.0 || // L5 healthy and S unhealthy,
+              _health == 2.0 || // L5 unhealthy and S healthy
+              _health == 3.0) { // both L5 and S unhealthy
+            return 1;
+          }
+          break;
+        case t_eph::L1NV:
+          if (_health == 0.0) { // All navigation data on L1-SPS signal OK
+            return 0;
+          }
+          if (_health == 1.0) { // Some or all navigation data on L1-SPS signal bad
+            return 1;
+          }
+          break;
+      }
+      break;
+  }
+  return 0;
+}
+
 // Constructor
 //////////////////////////////////////////////////////////////////////////////
@@ -1057,5 +1104,5 @@
   // Source RINEX version < 4
   if (type() == t_eph::undefined) {
-    // cannot be determined from input data 
+    // cannot be determined from input data
     // but is set to be able to work with old RINEX files in BNC applications
     _type = t_eph::FDMA_M;
@@ -2331,6 +2378,6 @@
 unsigned int t_ephSBAS::isUnhealthy() const {
 
-  // Bit 5
-  bool URAindexIs15 = (int(_health) & (1 << 5));
+// Bit 5
+  bool URAindexIs15 =  bitExtracted(int(_health), 1, 5);
   if (URAindexIs15) {
     // in this case it is recommended
@@ -2339,13 +2386,15 @@
   }
 
+  // Bit 4
+  bool MT17HealthIsUnavailable = bitExtracted(int(_health), 1, 4);
+  if (MT17HealthIsUnavailable) {
+    return 0;
+  }
+
   // Bit 0-3
-  int MT17health = (int(_health)) & (0x0f);
+  int MT17health = bitExtracted(int(_health), 4, 0);
   if (MT17health) {
     return 1;
   }
-
-  // Bit 4
-  //  bool MT17HealthIsUnavailable = (int(_health) & (1<<4));
-  //  is not used because the MT17health bits can be independently set if URA index is 15
 
   return 0;
@@ -2875,6 +2924,7 @@
 unsigned int t_ephBDS::isUnhealthy() const {
 
-  if (type() == t_eph::CNV1 || type() == t_eph::CNV2
-      || type() == t_eph::CNV3) {
+  if (type() == t_eph::CNV1 ||
+      type() == t_eph::CNV2 ||
+      type() == t_eph::CNV3) {
     return static_cast<unsigned int>(_health);
   }
Index: trunk/BNC/src/ephemeris.h
===================================================================
--- trunk/BNC/src/ephemeris.h	(revision 10627)
+++ trunk/BNC/src/ephemeris.h	(revision 10628)
@@ -142,5 +142,6 @@
   virtual QString toString(double version) const;
   virtual unsigned int  IOD() const { return static_cast<unsigned int>(_IODE); }
-  virtual unsigned int  isUnhealthy() const { return static_cast<unsigned int>(_health); }
+  //virtual unsigned int  isUnhealthy() const { return static_cast<unsigned int>(_health);}
+  virtual unsigned int isUnhealthy() const;
   double TGD() const {return _TGD;} // Timing Group Delay (P1-P2 DCB)
 
