Composition of $h(x)=f(|g(x)|)+|f(g(x))|$ 
$f(x)=\begin{cases}x-1,\ &-1\leq x\leq0\\ x^2,\ &0< x\leq1\end{cases}$ and $g(x)=\sin x$. Find $h(x)=f(|g(x)|)+|f(g(x))|$.

$$f(|g(x)|)=\begin{cases}|\sin x|-1,\ &-1\leq |\sin x|\leq0\\ \sin^2(x),\ &0< |\sin x|\leq1\end{cases}$$.$$\implies f(|g(x)|)=\begin{cases}0-1,\ &x=n\pi\\ \sin^2(x),\ &x\in R-{n\pi}\end{cases}$$
Also,$$|f(x)|=\begin{cases}1-x,\ &-1\leq x\leq0\\ x^2,\ &0< x\leq1\end{cases}$$ $$\implies|f(g(x))|=\begin{cases}1-\sin x,\ &-1\leq \sin x\leq0\\ \sin^2x,\ &0< \sin x\leq1\end{cases}$$ $$\implies|f(g(x))|=\begin{cases}1-\sin x,\ &(2n+1)\pi\leq x\leq2n\pi\\ \sin^2x,\ &2n\pi<x<(2n+1)\pi\end{cases}$$
Now how can I add these up, also answer is provided with $x$ in periods which don't incorporate $\pi's$, is any another elegant way exists to solve this problem? Please help.

I will only focus on $x \in [0, 2 \pi]$.
$\begin{align}
f(\vert g(x) \vert) & = \begin{cases}
\vert \text{sin}(x) \vert - 1,  & -1 \le \vert \text{sin}(x) \vert \le 0 \\
\vert \text{sin}(x) \vert^{2},  & 0 \lt \vert \text{sin}(x) \vert \le 1 \\
\end{cases} \\
 & = \begin{cases}
\vert \text{sin}(x) \vert - 1,  & \text{sin}(x) = 0 \\
\text{sin}^{2}(x),              & 0 \lt \vert \text{sin}(x) \vert \le 1 \\
\end{cases} \\
 & = \begin{cases}
- 1,               & x = n \pi, n\in \mathbb N\\
\text{sin}^{2}(x), & x \not = n \pi \\
\end{cases} \\
\end{align}$
Basically just trying to simplify $f(\vert g(x) \vert)$.
$\begin{align}
f(g(x)) = & \begin{cases}
\text{sin}(x) - 1, & -1 \le \text{sin}(x) \le 0 \\
\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
 & = \begin{cases}
\text{sin}(x) - 1, & \pi \le x \le 2 \pi \\
\text{sin}^{2}(x), & 0 \lt x \le \pi \\
\end{cases} \\
\end{align}$
Also just trying to simplify $f(g(x))$.
Now, a general rule to write down absolute value functions:
$$ \vert f(x) \vert = \begin{cases}
-f(x), & f(x) \lt 0 \\
f(x),  & f(x) \ge 0 \\
\end{cases}$$
So:
$\begin{align}
\vert f(g(x)) \vert = & \begin{cases}
1 - \text{sin}(x),   & -1 \le \text{sin}(x) \le 0 \\
- \text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\text{sin}(x) - 1,   & -1 \le \text{sin}(x) \le 0 \\
\text{sin}^{2}(x),   & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
 & = \begin{cases}
1 - \text{sin}(x),   & -1 \le \text{sin}(x) \le 0 \\
- \text{sin}^{2}(x), & \text{for no } x \in \mathbb R \\
\text{sin}(x) - 1,   & \text{for no } x \in \mathbb R \\
\text{sin}^{2}(x),   & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
 & = \begin{cases}
1 - \text{sin}(x), & -1 \le \text{sin}(x) \le 0 \\
\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
\end{align}$ 
Now, adding up both functions:
$\begin{align}
f(\vert g(x) \vert) + \vert f(g(x)) \vert = & \begin{cases}
- 1,               & \text{sin}(x) = 0 \\
\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} + \begin{cases}
1 - \text{sin}(x), & -1 \le \text{sin}(x) \le 0 \\
\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
 & = \begin{cases}
- 1,               & \text{sin}(x) = 0 \\
\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} + \begin{cases}
1,                 & \text{sin}(x) = 0 \\
\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
 & = \begin{cases}
0,                  & \text{sin}(x) = 0 \\
2\text{sin}^{2}(x), & 0 \lt \text{sin}(x) \le 1 \\
\end{cases} \\
 & = \begin{cases}
0,                 & x \in \{0,\pi\} \\
\text{sin}^{2}(x), & 0 \lt x \lt \pi \\
\end{cases} \\
& = \text{sin}^{2}(x), \text{for } x \in [0,\pi]
\end{align}$
I hope this is correct.
